示例#1
0
        public async Task Match_TheoryMatchSnapshotInSeperateClassMethodAsync_OneFieldNotEqual(int age, decimal size)
        {
            // arrange
            await Task.Delay(1);

            TestPerson testPerson = TestDataBuilder.TestPersonMarkWalton()
                                    .WithAge(age).WithSize(size).Build();

            testPerson.Address.Country.CountryCode = CountryCode.EN;

            SnapshotFullName snapshotFullName =
                Snapshot.FullName(SnapshotNameExtension.Create(age, size));

            var testClass = new AsyncSnapshotMatchTestClass();

            // act
            Func <Task> asyncMatch =
                () => testClass.AsyncMatchMethodWithFullName(testPerson, snapshotFullName);

            // assert
            EqualException exception =
                await Assert.ThrowsAsync <EqualException>(asyncMatch);

            Assert.Contains(CountryCode.EN.ToString(), exception.Message);
        }
示例#2
0
        public void BuiltInAssertionException()
        {
            var ex = new EqualException(42, 2112);

            var failed = _TestFailed.FromException(ex, "asm-id", "coll-id", "class-id", "method-id", "case-id", "test-id", 21.12M, null);

            Assert.Equal(FailureCause.Assertion, failed.Cause);
        }
示例#3
0
            public void EnumerableInequivalence()
            {
                int[]      expected = new[] { 1, 2, 3, 4, 5 };
                List <int> actual   = new List <int>(new[] { 1, 2, 3, 4, 6 });

                EqualException ex = Assert.Throws <EqualException>(() => Assert.Equal(expected, actual));

                Assert.Contains("First difference is at position 4\r\n", ex.Message);
            }
示例#4
0
        public void FailureCases(string expected, string actual, bool ignoreCase, bool ignoreLineEndingDifferences, bool ignoreWhiteSpaceDifferences, int expectedIndex, int actualIndex)
        {
            Exception ex = Record.Exception(
                () => Assert.Equal(expected, actual, ignoreCase, ignoreLineEndingDifferences, ignoreWhiteSpaceDifferences)
            );

            EqualException eqEx = Assert.IsType<EqualException>(ex);
            Assert.Equal(expectedIndex, eqEx.ExpectedIndex);
            Assert.Equal(actualIndex, eqEx.ActualIndex);
        }
示例#5
0
            public void EnumerableEquivalenceWithFailedComparer()
            {
                int[]      expected = new[] { 1, 2, 3, 4, 5 };
                List <int> actual   = new List <int>(new int[] { 1, 2, 3, 4, 5 });

                EqualException ex = Assert.Throws <EqualException>(() => Assert.Equal(expected, actual, new IntComparer(false)));

                // TODO: When we fix up the assert exception messages, we should allow the enumerator who
                // did the comparisons to tell us exactly where the error was, rather than determining the
                // inequivalence after the fact.

                // Assert.Contains("First difference is at position 0\r\n", ex.Message);
            }
        public void CreatePerson_MismatchingSnapshot_ThrowsException()
        {
            // arrange
            var serviceClient = new ServiceClient();

            string lastName = "Snapshot" + "Wrong";

            // act
            TestPerson person = serviceClient.CreatePerson(
                Guid.Parse("5592F21C-8501-4771-A070-C79C7C7EF478"), "Mismatch", lastName);

            // assert
            EqualException exception =
                Assert.Throws <EqualException>(() => Snapshot.Match(person));

            Assert.Contains("Lastname", exception.Message);
        }
示例#7
0
        public async Task Match_FactMatchSnapshotInAsncMethod_OneFieldNotEqual()
        {
            // arrange
            await Task.Delay(1);

            TestPerson testPerson = TestDataBuilder.TestPersonSandraSchneider()
                                    .WithAge(4055).Build();

            SnapshotFullName snapshotFullName = Snapshot.FullName();

            // act
            Func <Task> asyncMatch = () => AsyncMatchWithFullName(testPerson, snapshotFullName);

            // assert
            EqualException exception =
                await Assert.ThrowsAsync <EqualException>(asyncMatch);

            Assert.Contains("4055", exception.Message);

            await Task.Delay(1);
        }
示例#8
0
        public async Task Match_FactMatchSnapshotInSeperateClassMethodAsync_OneFieldNotEqual()
        {
            // arrange
            await Task.Delay(1);

            TestPerson testPerson = TestDataBuilder.TestPersonSandraSchneider()
                                    .WithAge(255).Build();

            SnapshotFullName snapshotFullName = Snapshot.FullName();

            var testClass = new AsyncSnapshotMatchTestClass();

            // act
            Func <Task> asyncMatch =
                () => testClass.AsyncMatchMethodWithFullName(testPerson, snapshotFullName);

            // assert
            EqualException exception =
                await Assert.ThrowsAsync <EqualException>(asyncMatch);

            Assert.Contains("255", exception.Message);

            await Task.Delay(1);
        }