|
| 1 | +extern alias sourcegen; |
| 2 | + |
| 3 | +namespace Visus.AddressValidation.SourceGeneration.Tests; |
| 4 | + |
| 5 | +using CustomResponseDataGenerator = sourcegen::Visus.AddressValidation.SourceGeneration.CustomResponseDataGenerator; |
| 6 | + |
| 7 | +internal sealed class CustomResponseDataGeneratorTests : SourceGeneratorTestBase |
| 8 | +{ |
| 9 | + protected override IEnumerable<Type> RequiredAssemblies => |
| 10 | + [ |
| 11 | + typeof(CustomResponseDataGenerator), |
| 12 | + typeof(CustomResponseDataPropertyAttribute), |
| 13 | + ]; |
| 14 | + |
| 15 | + [Test] |
| 16 | + public Task Should_Generate_GetCustomResponseData_For_Nested_Class() |
| 17 | + { |
| 18 | + const string source = """ |
| 19 | + using Visus.AddressValidation; |
| 20 | + |
| 21 | + namespace Visus.AddressValidation.SourceGeneration.Tests; |
| 22 | +
|
| 23 | + partial class Response |
| 24 | + { |
| 25 | + public string FirstName { get; set; } |
| 26 | + |
| 27 | + public string LastName { get; set; } |
| 28 | + |
| 29 | + partial class ApiData |
| 30 | + { |
| 31 | + [CustomResponseDataProperty] |
| 32 | + public string ResponseId { get; set; } |
| 33 | + |
| 34 | + [CustomResponseDataProperty("response")] |
| 35 | + public string ResponseText { get; set; } |
| 36 | + } |
| 37 | + } |
| 38 | + """; |
| 39 | + |
| 40 | + return VerifyGenerateSourcesAsync(source, new CustomResponseDataGenerator()); |
| 41 | + } |
| 42 | + |
| 43 | + [Test] |
| 44 | + public Task Should_Generate_GetCustomResponseData_For_Root_Class() |
| 45 | + { |
| 46 | + const string source = """ |
| 47 | + using Visus.AddressValidation; |
| 48 | + |
| 49 | + namespace Visus.AddressValidation.SourceGeneration.Tests; |
| 50 | +
|
| 51 | + partial class ApiResponse |
| 52 | + { |
| 53 | + [CustomResponseDataProperty] |
| 54 | + public string ResponseId { get; set; } |
| 55 | +
|
| 56 | + [CustomResponseDataProperty("response")] |
| 57 | + public string ResponseText { get; set; } |
| 58 | + } |
| 59 | + """; |
| 60 | + |
| 61 | + return VerifyGenerateSourcesAsync(source, new CustomResponseDataGenerator()); |
| 62 | + } |
| 63 | +} |
0 commit comments