A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/MapsterMapper/Mapster/issues/282 below:

Values not mapping correctly after Adapt · Issue #282 · MapsterMapper/Mapster · GitHub

Updating from 6.5.1 to 7.0.0 caused one of our unit tests to fail. Running Net Core 3.1.

You will see the cloneTest in the test below does not contain the decimal or enum values from the original.

    [Flags]
    public enum CloneTestEnum
    {
        Value1 = 1,
        Value2 = 2,
        Value3 = 100,
        Value4 = 200,
        Value5 = 300
    }

    public class CloneTestEnumContainer
    {
        public CloneTestEnumContainer()
        {

        }

        public CloneTestEnumContainer(CloneTestEnum type, decimal value)
        {
            Type = type;
            Value = value;
        }

        public CloneTestEnum Type { get; set; }
        public decimal Value { get; set; }
    }

    public class CloneTestEnumContainerListContainer
    {
        public List<CloneTestEnumContainer> List1 { get; set; } = new List<CloneTestEnumContainer>(); //parts of the pricing calcs that need VAT added
        public List<CloneTestEnumContainer> List2 { get; set; } = new List<CloneTestEnumContainer>(); //parts of the pricing calcs that must NOT have VAT
        public ReadOnlyCollection<CloneTestEnumContainer> CombinedLists => List1.Concat(List2).ToList().AsReadOnly();
    }
        [Fact]
        public void TestEnumList()
        {
            var testClass = new CloneTestEnumContainerListContainer
            {
                List1 = new List<CloneTestEnumContainer>
                {
                    new CloneTestEnumContainer
                    {
                        Type = CloneTestEnum.Value1,
                        Value = 500
                    }
                },
                List2 = new List<CloneTestEnumContainer>
                {
                    new CloneTestEnumContainer
                    {
                        Type = CloneTestEnum.Value5,
                        Value = 500
                    }
                }
            };

            var cloneTest = testClass.Adapt<CloneTestEnumContainerListContainer>();
            foreach (var paymentCompoent in testClass.CombinedLists)
            {
                Assert.Contains(cloneTest.CombinedLists, x => x.Type == paymentCompoent.Type && x.Value == paymentCompoent.Value);
            }
        }

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4