Skip to content

Commit

Permalink
Fix tests for net48, net6.0, net 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TonEnfer committed Dec 9, 2024
1 parent c9c8845 commit e0ac3e4
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/Riok.Mapperly.IntegrationTests/BaseMapperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public static TestObject NewTestObj()
DateTimeValue = new DateTime(2020, 1, 3, 15, 10, 5, DateTimeKind.Utc),
DateTimeValueTargetDateOnly = new DateTime(2020, 1, 3, 15, 10, 5, DateTimeKind.Utc),
DateTimeValueTargetTimeOnly = new DateTime(2020, 1, 3, 15, 10, 5, DateTimeKind.Utc),
#if NET5_0_OR_GREATER
ToByteArrayWithInstanceMethod = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11),
#endif
WithCreateMethod = ConvertWithStaticMethodObject.Create(10),
WithCreateFromMethod = ConvertWithStaticMethodObject.Create(20),
WithFromSingleMethod = ConvertWithStaticMethodObject.Create(30),
Expand Down
2 changes: 2 additions & 0 deletions test/Riok.Mapperly.IntegrationTests/Dto/TestObjectDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ public TestObjectDto(int ctorValue, int unknownValue = 10, int ctorValue2 = 100)

public TimeOnly DateTimeValueTargetTimeOnly { get; set; }

#if NET5_0_OR_GREATER
public byte[]? ToByteArrayWithInstanceMethod { get; set; }
#endif

public int WithCreateMethod { get; set; }

Expand Down
2 changes: 2 additions & 0 deletions test/Riok.Mapperly.IntegrationTests/Mapper/TestMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public TestMapper()

public partial DateTime DirectDateTime(DateTime dateTime);

#if NET5_0_OR_GREATER
public partial byte[] ConvertWithInstanceMethod(Guid id);
#endif

public partial IEnumerable<TestObjectDto> MapAllDtos(IEnumerable<TestObject> objects);

Expand Down
2 changes: 2 additions & 0 deletions test/Riok.Mapperly.IntegrationTests/Models/TestObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ public TestObject(int ctorValue, int unknownValue = 10, int ctorValue2 = 100)

public DateTime DateTimeValueTargetTimeOnly { get; set; }

#if NET5_0_OR_GREATER
public Guid ToByteArrayWithInstanceMethod { get; set; }
#endif

public ConvertWithStaticMethodObject? WithCreateMethod { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,27 @@
DateTimeValue: 2020-01-03 15:10:05 Utc,
DateTimeValueTargetDateOnly: 2020-01-03 15:10:05 Utc,
DateTimeValueTargetTimeOnly: 2020-01-03 15:10:05 Utc,
WithCreateMethod: {
Value: 10
},
WithCreateFromMethod: {
Value: 20
},
WithFromSingleMethod: {
Value: 30
},
WithCreateParamsMethod: {
Value: 40
},
WithCreateFromParamsMethod: {
Value: 50
},
WithFromShortParamsMethod: {
Value: 60
},
WithToDecimalMethod: {
Value: 70
},
ExposePrivateValue: 18,
SumComponent1: 32,
SumComponent2: 64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,62 @@ public static partial class DeepCloningMapper
target.DateTimeValue = src.DateTimeValue;
target.DateTimeValueTargetDateOnly = src.DateTimeValueTargetDateOnly;
target.DateTimeValueTargetTimeOnly = src.DateTimeValueTargetTimeOnly;
if (src.WithCreateMethod != null)
{
target.WithCreateMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToConvertWithStaticMethodObject(src.WithCreateMethod);
}
else
{
target.WithCreateMethod = null;
}
if (src.WithCreateFromMethod != null)
{
target.WithCreateFromMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToConvertWithStaticMethodObject(src.WithCreateFromMethod);
}
else
{
target.WithCreateFromMethod = null;
}
if (src.WithFromSingleMethod != null)
{
target.WithFromSingleMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToConvertWithStaticMethodObject(src.WithFromSingleMethod);
}
else
{
target.WithFromSingleMethod = null;
}
if (src.WithCreateParamsMethod != null)
{
target.WithCreateParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToConvertWithStaticMethodObject(src.WithCreateParamsMethod);
}
else
{
target.WithCreateParamsMethod = null;
}
if (src.WithCreateFromParamsMethod != null)
{
target.WithCreateFromParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToConvertWithStaticMethodObject(src.WithCreateFromParamsMethod);
}
else
{
target.WithCreateFromParamsMethod = null;
}
if (src.WithFromShortParamsMethod != null)
{
target.WithFromShortParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToConvertWithStaticMethodObject(src.WithFromShortParamsMethod);
}
else
{
target.WithFromShortParamsMethod = null;
}
if (src.WithToDecimalMethod != null)
{
target.WithToDecimalMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToConvertWithStaticMethodObject(src.WithToDecimalMethod);
}
else
{
target.WithToDecimalMethod = null;
}
target.SumComponent1 = src.SumComponent1;
target.SumComponent2 = src.SumComponent2;
return target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@
},
DateTimeValueTargetDateOnly: 2020-01-03,
DateTimeValueTargetTimeOnly: 3:10 PM,
WithCreateMethod: 10,
WithCreateFromMethod: 20,
WithFromSingleMethod: 30.0,
WithCreateParamsMethod: 40.0,
WithCreateFromParamsMethod: 50,
WithFromShortParamsMethod: 60,
WithToDecimalMethod: 70.0,
FormattedIntValue: CHF 10.00,
FormattedDateValue: Friday, January 3, 2020,
ExposePrivateValue: 28,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
EnumName: Value30,
EnumStringValue: 0,
EnumReverseStringValue: DtoValue3,
ToByteArrayWithInstanceMethod: AAAAAAAAAAAAAAAAAAAAAA==,
FormattedIntValue: CHF 0.00,
FormattedDateValue: Monday, January 1, 0001,
ExposePrivateValue: 26
Expand Down Expand Up @@ -194,6 +195,14 @@
},
DateTimeValueTargetDateOnly: 2020-01-03,
DateTimeValueTargetTimeOnly: 3:10 PM,
ToByteArrayWithInstanceMethod: AQAAAAIAAwAEBQYHCAkKCw==,
WithCreateMethod: 10,
WithCreateFromMethod: 20,
WithFromSingleMethod: 30.0,
WithCreateParamsMethod: 40.0,
WithCreateFromParamsMethod: 50,
WithFromShortParamsMethod: 60,
WithToDecimalMethod: 70.0,
FormattedIntValue: CHF 10.00,
FormattedDateValue: Friday, January 3, 2020,
ExposePrivateValue: 28,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,34 @@ public partial int ParseableInt(string value)
}
target.DateTimeValueTargetDateOnly = global::System.DateOnly.FromDateTime(testObject.DateTimeValueTargetDateOnly);
target.DateTimeValueTargetTimeOnly = global::System.TimeOnly.FromDateTime(testObject.DateTimeValueTargetTimeOnly);
if (testObject.WithCreateMethod != null)
{
target.WithCreateMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToInt32(testObject.WithCreateMethod);
}
if (testObject.WithCreateFromMethod != null)
{
target.WithCreateFromMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToByte(testObject.WithCreateFromMethod);
}
if (testObject.WithFromSingleMethod != null)
{
target.WithFromSingleMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToSingle(testObject.WithFromSingleMethod);
}
if (testObject.WithCreateParamsMethod != null)
{
target.WithCreateParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToDouble(testObject.WithCreateParamsMethod);
}
if (testObject.WithCreateFromParamsMethod != null)
{
target.WithCreateFromParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToUInt32(testObject.WithCreateFromParamsMethod);
}
if (testObject.WithFromShortParamsMethod != null)
{
target.WithFromShortParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToInt16(testObject.WithFromShortParamsMethod);
}
if (testObject.WithToDecimalMethod != null)
{
target.WithToDecimalMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToDecimal(testObject.WithToDecimalMethod);
}
target.FormattedIntValue = testObject.IntValue.ToString("C", _formatDeCh);
target.FormattedDateValue = testObject.DateTimeValue.ToString("D", _formatEnUs);
target.Sum = ComputeSum(testObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public partial int ParseableInt(string value)
return dateTime;
}

[global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "0.0.1.0")]
public partial byte[] ConvertWithInstanceMethod(global::System.Guid id)
{
return id.ToByteArray();
}

[global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "0.0.1.0")]
public partial global::System.Collections.Generic.IEnumerable<global::Riok.Mapperly.IntegrationTests.Dto.TestObjectDto> MapAllDtos(global::System.Collections.Generic.IEnumerable<global::Riok.Mapperly.IntegrationTests.Models.TestObject> objects)
{
Expand Down Expand Up @@ -213,6 +219,35 @@ public partial int ParseableInt(string value)
}
target.DateTimeValueTargetDateOnly = global::System.DateOnly.FromDateTime(testObject.DateTimeValueTargetDateOnly);
target.DateTimeValueTargetTimeOnly = global::System.TimeOnly.FromDateTime(testObject.DateTimeValueTargetTimeOnly);
target.ToByteArrayWithInstanceMethod = ConvertWithInstanceMethod(testObject.ToByteArrayWithInstanceMethod);
if (testObject.WithCreateMethod != null)
{
target.WithCreateMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToInt32(testObject.WithCreateMethod);
}
if (testObject.WithCreateFromMethod != null)
{
target.WithCreateFromMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToByte(testObject.WithCreateFromMethod);
}
if (testObject.WithFromSingleMethod != null)
{
target.WithFromSingleMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToSingle(testObject.WithFromSingleMethod);
}
if (testObject.WithCreateParamsMethod != null)
{
target.WithCreateParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToDouble(testObject.WithCreateParamsMethod);
}
if (testObject.WithCreateFromParamsMethod != null)
{
target.WithCreateFromParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToUInt32(testObject.WithCreateFromParamsMethod);
}
if (testObject.WithFromShortParamsMethod != null)
{
target.WithFromShortParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToInt16(testObject.WithFromShortParamsMethod);
}
if (testObject.WithToDecimalMethod != null)
{
target.WithToDecimalMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToDecimal(testObject.WithToDecimalMethod);
}
target.FormattedIntValue = testObject.IntValue.ToString("C", _formatDeCh);
target.FormattedDateValue = testObject.DateTimeValue.ToString("D", _formatEnUs);
target.Sum = ComputeSum(testObject);
Expand Down Expand Up @@ -352,6 +387,17 @@ public partial int ParseableInt(string value)
{
target.SubObject = null;
}
if (dto.ToByteArrayWithInstanceMethod != null)
{
target.ToByteArrayWithInstanceMethod = new global::System.Guid(dto.ToByteArrayWithInstanceMethod);
}
target.WithCreateMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.Create(dto.WithCreateMethod);
target.WithCreateFromMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.CreateFrom(dto.WithCreateFromMethod);
target.WithFromSingleMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.FromSingle(dto.WithFromSingleMethod);
target.WithCreateParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.Create(dto.WithCreateParamsMethod);
target.WithCreateFromParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.CreateFrom(dto.WithCreateFromParamsMethod);
target.WithFromShortParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.FromInt16(dto.WithFromShortParamsMethod);
target.WithToDecimalMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.CreateFromDecimal(dto.WithToDecimalMethod);
return target;
}

Expand Down Expand Up @@ -495,6 +541,35 @@ public partial void UpdateDto(global::Riok.Mapperly.IntegrationTests.Models.Test
}
target.DateTimeValueTargetDateOnly = global::System.DateOnly.FromDateTime(source.DateTimeValueTargetDateOnly);
target.DateTimeValueTargetTimeOnly = global::System.TimeOnly.FromDateTime(source.DateTimeValueTargetTimeOnly);
target.ToByteArrayWithInstanceMethod = ConvertWithInstanceMethod(source.ToByteArrayWithInstanceMethod);
if (source.WithCreateMethod != null)
{
target.WithCreateMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToInt32(source.WithCreateMethod);
}
if (source.WithCreateFromMethod != null)
{
target.WithCreateFromMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToByte(source.WithCreateFromMethod);
}
if (source.WithFromSingleMethod != null)
{
target.WithFromSingleMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToSingle(source.WithFromSingleMethod);
}
if (source.WithCreateParamsMethod != null)
{
target.WithCreateParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToDouble(source.WithCreateParamsMethod);
}
if (source.WithCreateFromParamsMethod != null)
{
target.WithCreateFromParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToUInt32(source.WithCreateFromParamsMethod);
}
if (source.WithFromShortParamsMethod != null)
{
target.WithFromShortParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToInt16(source.WithFromShortParamsMethod);
}
if (source.WithToDecimalMethod != null)
{
target.WithToDecimalMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToDecimal(source.WithToDecimalMethod);
}
}

[global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "0.0.1.0")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@
},
DateTimeValueTargetDateOnly: 2020-01-03,
DateTimeValueTargetTimeOnly: 3:10 PM,
WithCreateMethod: 10,
WithCreateFromMethod: 20,
WithFromSingleMethod: 30.0,
WithCreateParamsMethod: 40.0,
WithCreateFromParamsMethod: 50,
WithFromShortParamsMethod: 60,
WithToDecimalMethod: 70.0,
FormattedIntValue: ,
FormattedDateValue: ,
ExposePrivateValue: 28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@
},
DateTimeValueTargetDateOnly: 2020-01-03,
DateTimeValueTargetTimeOnly: 3:10 PM,
WithCreateMethod: 10,
WithCreateFromMethod: 20,
WithFromSingleMethod: 30.0,
WithCreateParamsMethod: 40.0,
WithCreateFromParamsMethod: 50,
WithFromShortParamsMethod: 60,
WithToDecimalMethod: 70.0,
FormattedIntValue: ,
FormattedDateValue: ,
ExposePrivateValue: 28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,34 @@ public static partial void MapIdTargetFirst(global::Riok.Mapperly.IntegrationTes
}
target.DateTimeValueTargetDateOnly = global::System.DateOnly.FromDateTime(src.DateTimeValueTargetDateOnly);
target.DateTimeValueTargetTimeOnly = global::System.TimeOnly.FromDateTime(src.DateTimeValueTargetTimeOnly);
if (src.WithCreateMethod != null)
{
target.WithCreateMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToInt32(src.WithCreateMethod);
}
if (src.WithCreateFromMethod != null)
{
target.WithCreateFromMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToByte(src.WithCreateFromMethod);
}
if (src.WithFromSingleMethod != null)
{
target.WithFromSingleMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToSingle(src.WithFromSingleMethod);
}
if (src.WithCreateParamsMethod != null)
{
target.WithCreateParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToDouble(src.WithCreateParamsMethod);
}
if (src.WithCreateFromParamsMethod != null)
{
target.WithCreateFromParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToUInt32(src.WithCreateFromParamsMethod);
}
if (src.WithFromShortParamsMethod != null)
{
target.WithFromShortParamsMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToInt16(src.WithFromShortParamsMethod);
}
if (src.WithToDecimalMethod != null)
{
target.WithToDecimalMethod = global::Riok.Mapperly.IntegrationTests.Models.ConvertWithStaticMethodObject.ToDecimal(src.WithToDecimalMethod);
}
return target;
}

Expand Down

0 comments on commit e0ac3e4

Please sign in to comment.