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

Also v2.6.2 breaks existing test (Assert.Equal on Dictionary with null values) #2837

Closed
gioce90 opened this issue Dec 5, 2023 · 1 comment

Comments

@gioce90
Copy link

gioce90 commented Dec 5, 2023

I have a similar problem to #2821.
Every version of xunit.assert and xunit > 2.5.3 give me an error, also with the 2.6.2.

I tested with version 2.6.2 (of both xunit.assert and xunit), and I think there is still a problem with collections like Dictionary when there is a Value field with null value.

This is my first test, that is totally fine:

        [Fact]
        public void MyTest__OKAY()
        {
            IDictionary<string, string> dict1 = new Dictionary<string, string>
            {
                { "A", "The" },
                { "B", "empty" },
                { "C", "" },
                { "D", "test" },
                { "E", "is" },
                { "F", "OKAY" },
            };
            IDictionary<string, string> dict2 = new Dictionary<string, string>
            {
                { "A", "The" },
                { "B", "empty" },
                { "C", "" },
                { "D", "test" },
                { "E", "is" },
                { "F", "OKAY" },
            };
            Assert.Equal(dict1, dict2);
            Assert.Equal(dict2, dict1);
        }

This second one instead, where i just put a null value, fails:

        [Fact]
        public void MyTest__WRONG()
        {
            IDictionary<string, string> dict1 = new Dictionary<string, string>
            {
                { "A", "The" },
                { "B", "null" },
                { "C", null },
                { "D", "test" },
                { "E", "is" },
                { "F", "NOT" },
            };
            IDictionary<string, string> dict2 = new Dictionary<string, string>
            {
                { "A", "The" },
                { "B", "null" },
                { "C", null },
                { "D", "test" },
                { "E", "is" },
                { "F", "NOT" },
            };
            Assert.Equal(dict2, dict1);
            Assert.Equal(dict1, dict2);
        }

But if I go back to version "2.5.3", both tests are fine. I think I've found another regression here.

@ladeak
Copy link

ladeak commented Dec 5, 2023

Duplicate of #2824

@bradwilson bradwilson closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants