Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
build:
strategy:
fail-fast: false
matrix:
dotnet-version: [8.0.x]
runs-on: windows-latest
steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
build:
strategy:
fail-fast: false
matrix:
dotnet-version: [8.0.x]
runs-on: windows-latest
steps:
- name: Checkout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="[14,)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageReference Include="AutoMapper" Version="[15.0.1,)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Default : AutoMapperSpecBase
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand All @@ -57,7 +57,7 @@ public class ByName : AutoMapperSpecBase
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByName());
});
}, _loggerFactory);

protected override void Because_of()
{
Expand All @@ -84,7 +84,7 @@ public class ByValue : AutoMapperSpecBase
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByValue());
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class Default : AutoMapperSpecBase
{
cfg.EnableEnumMappingValidation();
cfg.CreateMap<object, object>();
});
}, _loggerFactory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum Destination { Default, Bar, Foo }
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByName());
});
}, _loggerFactory);

protected override void Because_of()
{
Expand All @@ -44,7 +44,7 @@ public enum Destination { fOObAR, DefaulT, Bar, Foo }
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByName(true));
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -73,7 +73,7 @@ public enum Destination { Default, Foo }
.ConvertUsingEnumMapping(opt => opt
.MapByName()
.MapValue(Source.Bar, Destination.Foo));
});
}, _loggerFactory);

protected override void Because_of()
{
Expand All @@ -97,7 +97,7 @@ public enum Destination { Default, Bar }
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByName());
});
}, _loggerFactory);

[Fact]
public void Should_fail_validation() =>
Expand All @@ -118,7 +118,7 @@ public enum Destination { Default, Foo }
.ConvertUsingEnumMapping(opt => opt
.MapByName()
.MapValue(Source.Bar, Destination.Foo));
});
}, _loggerFactory);

[Fact]
public void Should_fail_validation() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum Destination { Default, Bar, Foo }
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByValue());
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -47,7 +47,7 @@ public enum Destination { Default, Bar }
.ConvertUsingEnumMapping(opt => opt
.MapByValue()
.MapValue(Source.Bar, Destination.Bar));
});
}, _loggerFactory);

protected override void Because_of()
{
Expand All @@ -71,7 +71,7 @@ public enum Destination { Default, Bar }
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByValue());
});
}, _loggerFactory);

[Fact]
public void Should_fail_validation() =>
Expand All @@ -92,7 +92,7 @@ public enum Destination { Default, Bar }
.ConvertUsingEnumMapping(opt => opt
.MapByValue()
.MapValue(Source.Bar, Destination.Bar));
});
}, _loggerFactory);

[Fact]
public void Should_fail_validation() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum Destination { A = 2 }
.MapValue(Source.A, Destination.A)
.MapException(Source.B, () => new NotSupportedException($"B is not valid value"))
);
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -49,7 +49,7 @@ public enum Destination { A = 2 }
.MapValue(Source.A, Destination.A)
.MapException(Source.B, () => new NotSupportedException($"B is not valid value"))
);
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum Destination : byte { Default, Bar, Foo }
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByValue());
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
namespace AutoMapper.Extensions.EnumMapping.Tests.Internal
using Microsoft.Extensions.Logging;

namespace AutoMapper.Extensions.EnumMapping.Tests.Internal
{
public abstract class SpecBaseBase
{
protected static ILoggerFactory _loggerFactory;

static SpecBaseBase()
{
_loggerFactory = new LoggerFactory();
}

protected virtual void MainSetup()
{
Establish_context();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum Destination { A = 2 }
.MapException(Source.B, () => new NotSupportedException($"B is not valid value"))
)
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public TestEnumProfile()
{
cfg.EnableEnumMappingValidation();
cfg.AddMaps(typeof(ReverseCustomEnumMappingByCustom).GetTypeInfo().Assembly);
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum Destination { Default, Foo }
.ConvertUsingEnumMapping(opt => opt.MapByValue()
.MapValue(Source.OnlyInSource, Destination.Foo))
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand All @@ -48,7 +48,7 @@ public enum Destination { Default, Foo, OnlyInDestination }
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByValue())
.ReverseMap();
});
}, _loggerFactory);

[Fact]
public void Should_fail_validation() =>
Expand All @@ -71,7 +71,7 @@ public enum Destination { Default, OnlyInDestination }
.ConvertUsingEnumMapping(opt => opt.MapByValue()
.MapValue(Source.OnlyInSource, Destination.OnlyInDestination))
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -103,7 +103,7 @@ public enum Destination { A, B, C, D, InSourceAndDestionation }
.MapValue(Source.InSourceAndDestionation, Destination.D)
.MapValue(Source.OnyInSource, Destination.InSourceAndDestionation))
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -144,7 +144,7 @@ public enum Destination { A, B, C, D, E, F }
.MapValue(Source.E, Destination.A)
)
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -187,7 +187,7 @@ public enum Destination { C = 2 }
.MapValue(Source.F, Destination.C)
)
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Default : AutoMapperSpecBase
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping()
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand All @@ -58,7 +58,7 @@ public class ByName : AutoMapperSpecBase
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByName());
});
}, _loggerFactory);

protected override void Because_of()
{
Expand All @@ -85,7 +85,7 @@ public class ByValue : AutoMapperSpecBase
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByValue());
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public enum Destination { Default, Bar, Foo }
.MapValue(Source.Bar, Destination.Bar)
)
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -56,7 +56,7 @@ public enum Destination { Default, Bar }
.MapValue(Source.Bar, Destination.Bar)
)
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -85,7 +85,7 @@ public enum Destination { Default, Bar }
.MapValue(Source.Bar, Destination.Bar)
)
.ReverseMap();
});
}, _loggerFactory);

[Fact]
public void Should_fail_validation() =>
Expand All @@ -109,7 +109,7 @@ public enum Destination { Default, Bar }
.MapException(Source.Foo, () => new NotSupportedException($"Foo is not valid value"))
.MapValue(Source.Bar, Destination.Bar))
.ReverseMap();
});
}, _loggerFactory);

[Fact]
public void Should_fail_validation() =>
Expand All @@ -135,7 +135,7 @@ public enum Destination { Default, Foo, Bar }
.MapValue(Source.Default, Destination.Default)
.MapValue(Source.Bar, Destination.Bar))
.ReverseMap(optr => optr.MapByCustom().MapValue(Destination.Foo, Source.Bar));
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public enum Destination { Default, Bar, Foo }
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByName())
.ReverseMap();
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -54,7 +54,7 @@ public enum Destination { Default, Foo, Bar }
.ConvertUsingEnumMapping(opt => opt.MapByName())
.ReverseMap(opt => opt.
MapValue(Destination.Bar, Source.Foo));
});
}, _loggerFactory);

protected override void Because_of()
{
Expand Down Expand Up @@ -83,7 +83,7 @@ public enum Destination { Default, Bar }
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByName())
.ReverseMap();
});
}, _loggerFactory);

[Fact]
public void Should_fail_validation() =>
Expand All @@ -103,7 +103,7 @@ public enum Destination { Default, Foo, Bar, Error }
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByName())
.ReverseMap(opt => opt.MapValue(Destination.Bar, Source.Foo));
});
}, _loggerFactory);

[Fact]
public void Should_fail_validation() =>
Expand Down
Loading
Loading