-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from codecentric/verify_for_testing
feat: Reorganize tests to use Verify.
- Loading branch information
Showing
73 changed files
with
2,903 additions
and
3,016 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
AutomaticInterface/Tests/Events/Events.CopiesEventsToInterface.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
/// <summary> | ||
/// Bla bla | ||
/// </summary> | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.ShapeChanged" /> | ||
event global::System.EventHandler ShapeChanged; | ||
|
||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
AutomaticInterface/Tests/Events/Events.NullableEvent.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
#nullable enable | ||
namespace AutomaticInterfaceExample | ||
{ | ||
/// <summary> | ||
/// Bla bla | ||
/// </summary> | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.ShapeChangedNullable" /> | ||
event global::System.EventHandler? ShapeChangedNullable; | ||
|
||
} | ||
} | ||
#nullable restore |
23 changes: 23 additions & 0 deletions
23
AutomaticInterface/Tests/Events/Events.NullableEvent2.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
#nullable enable | ||
namespace AutomaticInterfaceExample | ||
{ | ||
/// <summary> | ||
/// Bla bla | ||
/// </summary> | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.ShapeChangedNullable" /> | ||
event global::System.EventHandler<string?> ShapeChangedNullable; | ||
|
||
} | ||
} | ||
#nullable restore |
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Events/Events.WorksWithEventOverrides.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.AnEvent" /> | ||
event global::System.EventHandler AnEvent; | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
AutomaticInterface/Tests/Events/Events.WorksWithEventShadowing.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//-------------------------------------------------------------------------------------------------- | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//-------------------------------------------------------------------------------------------------- | ||
|
||
namespace AutomaticInterfaceExample | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")] | ||
public partial interface IDemoClass | ||
{ | ||
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.AnEvent" /> | ||
event global::System.EventHandler AnEvent; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
namespace Tests.Events; | ||
|
||
public class Events | ||
{ | ||
[Fact] | ||
public async Task CopiesEventsToInterface() | ||
{ | ||
const string code = """ | ||
using AutomaticInterface; | ||
using System; | ||
namespace AutomaticInterfaceExample | ||
{ | ||
/// <summary> | ||
/// Bla bla | ||
/// </summary> | ||
[GenerateAutomaticInterface] | ||
class DemoClass | ||
{ | ||
/// <summary> | ||
/// Bla bla | ||
/// </summary> | ||
public event EventHandler ShapeChanged; // included | ||
private event EventHandler ShapeChanged2; // ignored because not public | ||
} | ||
} | ||
"""; | ||
|
||
await Verify(Infrastructure.GenerateCode(code)); | ||
} | ||
|
||
[Fact] | ||
public async Task NullableEvent() | ||
{ | ||
const string code = """ | ||
using AutomaticInterface; | ||
using System; | ||
namespace AutomaticInterfaceExample | ||
{ | ||
/// <summary> | ||
/// Bla bla | ||
/// </summary> | ||
[GenerateAutomaticInterface] | ||
class DemoClass | ||
{ | ||
/// <summary> | ||
/// Bla bla | ||
/// </summary> | ||
public event EventHandler? ShapeChangedNullable; | ||
} | ||
} | ||
"""; | ||
|
||
await Verify(Infrastructure.GenerateCode(code)); | ||
} | ||
|
||
[Fact] | ||
public async Task NullableEvent2() | ||
{ | ||
const string code = """ | ||
using AutomaticInterface; | ||
using System; | ||
namespace AutomaticInterfaceExample | ||
{ | ||
/// <summary> | ||
/// Bla bla | ||
/// </summary> | ||
[GenerateAutomaticInterface] | ||
class DemoClass | ||
{ | ||
/// <summary> | ||
/// Bla bla | ||
/// </summary> | ||
public event EventHandler<string?> ShapeChangedNullable; | ||
} | ||
} | ||
"""; | ||
|
||
await Verify(Infrastructure.GenerateCode(code)); | ||
} | ||
|
||
[Fact] | ||
public async Task WorksWithEventOverrides() | ||
{ | ||
const string code = """ | ||
using AutomaticInterface; | ||
using System; | ||
namespace AutomaticInterfaceExample; | ||
public class BaseClass | ||
{ | ||
public virtual event EventHandler AnEvent; | ||
} | ||
[GenerateAutomaticInterface] | ||
public class DemoClass : BaseClass | ||
{ | ||
public override event EventHandler AnEvent; | ||
} | ||
"""; | ||
|
||
await Verify(Infrastructure.GenerateCode(code)); | ||
} | ||
|
||
[Fact] | ||
public async Task WorksWithEventShadowing() | ||
{ | ||
const string code = """ | ||
using AutomaticInterface; | ||
using System; | ||
namespace AutomaticInterfaceExample; | ||
public class BaseClass | ||
{ | ||
public event EventHandler AnEvent; | ||
} | ||
[GenerateAutomaticInterface] | ||
public class DemoClass : BaseClass | ||
{ | ||
public new event EventHandler AnEvent; | ||
} | ||
"""; | ||
|
||
await Verify(Infrastructure.GenerateCode(code)); | ||
} | ||
} |
Oops, something went wrong.