Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Values not mapping correctly after Adapt #282

Closed
dylanvdmerwe opened this issue Nov 25, 2020 · 0 comments
Closed

Values not mapping correctly after Adapt #282

dylanvdmerwe opened this issue Nov 25, 2020 · 0 comments

Comments

@dylanvdmerwe
Copy link

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);
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant