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); }
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); }
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); }
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); }
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); }
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); }
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); }