public void Select_should_equal_Select() { IEnumerable <int> items = IntGenerator.Range(1, 12); IEnumerable <int> others = IntGenerator.Range(1, 12); Assert.Equal(items, others); }
public void Int32Int64Comparison() { long l64 = 0; int i32 = 0; Assert.Equal <long>(l64, i32); }
public void UInt64EqualsFails() { UInt64 expected = 25; UInt64 actual = 42; Assert.Throws <EqualException>(() => Assert.Equal(expected, actual)); }
public void DecimalEqualsFails() { decimal expected = 25; decimal actual = 42; Assert.Throws <EqualException>(() => Assert.Equal(expected, actual)); }
public void IsNotTypeThrowsExceptionWhenWrongType() { AssertException exception = Assert.Throws <IsNotTypeException>(() => Assert.IsNotType <InvalidCastException>(new InvalidCastException())); Assert.Equal("Assert.IsNotType() Failure", exception.UserMessage); }
public void DoubleEqualsFails() { double expected = 25.3; double actual = 42.0; Assert.Throws <EqualException>(() => Assert.Equal(expected, actual)); }
public void NullableValueTypesCanBeNull() { DateTime?dt1 = null; DateTime?dt2 = null; Assert.Equal(dt1, dt2); }
public void String() { string s1 = "test"; string s2 = new StringBuilder(s1).ToString(); Assert.True(s1.Equals(s2)); Assert.Equal(s2, s1); }
public void NullValuesInArraysCreateCorrectExceptionMessage() { Exception ex = Record.Exception( () => Assert.Equal(new [] { null, "hello" }, new [] { null, "world" })); Assert.IsType <EqualException>(ex); Assert.Equal("Assert.Equal() Failure\r\nPosition: First difference is at position 1\r\nExpected: System.String[] { (null), hello }\r\nActual: System.String[] { (null), world }", ex.Message); }
public void ArrayValuesAreDifferentNotEqual() { string[] expected = { "@", "d", "v", "d" }; string[] actual = { "@", "a", "ab", "b" }; Assert.Throws <EqualException>(() => Assert.Equal(expected, actual)); Assert.NotEqual(expected, actual); }
public void ArraysOfDifferentLengthsAreNotEqual() { string[] expected = { "@", "a", "ab", "b", "c" }; string[] actual = { "@", "a", "ab", "b" }; Assert.Throws <EqualException>(() => Assert.Equal(expected, actual)); Assert.NotEqual(expected, actual); }
public void When_comparing_base_Generic_IComparable_object_Should_equate() { EquatableObject baseObj = new EquatableObject(); DerivedEquatableObject derivedObj = new DerivedEquatableObject(); Assert.Equal(derivedObj, baseObj); Assert.True(baseObj.Equals__Called); }
public void When_comparing_object_with_default_equality_behavior_to_derived_class_Should_fail() { var obj = new DefaultEqualityObject(); var derivedObj = new DerivedDefaultEqualityObject(); var ex = Record.Exception(() => Assert.Equal(obj, derivedObj)); Assert.IsType <EqualException>(ex); }
public void Array() { string[] expected = { "@", "a", "ab", "b" }; string[] actual = { "@", "a", "ab", "b" }; Assert.Equal(expected, actual); Assert.Throws <NotEqualException>(() => Assert.NotEqual(expected, actual)); }
public void SingleWithSingleItemCollectionReturnsTheItem() { string[] collection = new[] { "Hello" }; string result = Assert.Single(collection); Assert.Equal("Hello", result); }
public void TraceAssertFailureWithFullDetails() { TraceAssertException ex = Assert.Throws <TraceAssertException>(() => Trace.Assert(false, "message", "detailed message")); Assert.Equal("message", ex.AssertMessage); Assert.Equal("detailed message", ex.AssertDetailedMessage); Assert.Equal("Debug.Assert() Failure : message" + Environment.NewLine + "Detailed Message:" + Environment.NewLine + "detailed message", ex.Message); }
public void TraceAssertFailureWithNoMessage() { TraceAssertException ex = Assert.Throws <TraceAssertException>(() => Trace.Assert(false)); Assert.Equal("", ex.AssertMessage); Assert.Equal("", ex.AssertDetailedMessage); Assert.Equal("Debug.Assert() Failure", ex.Message); }
public void ItemNotInContainer() { List <int> list = new List <int>(); ContainsException ex = Assert.Throws <ContainsException>(() => Assert.Contains(42, list)); Assert.Equal("Assert.Contains() failure: Not found: 42", ex.Message); }
public void IsAssignableFromThrowsExceptionWhenWrongType() { AssertException exception = Assert.Throws <IsAssignableFromException>( () => Assert.IsAssignableFrom <InvalidCastException>(new InvalidOperationException())); Assert.Equal("Assert.IsAssignableFrom() Failure", exception.UserMessage); }
public void When_copmaring_derived_IEquitable_object_Should_equate() { EquatableObject baseObj = new EquatableObject(); DerivedEquatableObject derivedObj = new DerivedEquatableObject(); Assert.Equal(baseObj, derivedObj); Assert.True(baseObj.Equals__Called); }
public void ContainerIsEmpty() { List <int> list = new List <int>(); NotEmptyException ex = Assert.Throws <NotEmptyException>(() => Assert.NotEmpty(list)); Assert.Equal("Assert.NotEmpty() failure", ex.Message); }
public void SingleWithMultiItemCollectionThrows() { string[] collection = new[] { "Hello", "World!" }; Exception ex = Record.Exception(() => Assert.Single(collection)); Assert.IsType <SingleException>(ex); Assert.Equal("The collection contained 2 elements instead of 1.", ex.Message); }
public void SingleWithEmptyCollectionThrows() { object[] collection = new object[0]; Exception ex = Record.Exception(() => Assert.Single(collection)); Assert.IsType <SingleException>(ex); Assert.Equal("The collection contained 0 elements instead of 1.", ex.Message); }
public void PreservesExpectedAndActual() { AssertActualExpectedException ex = new AssertActualExpectedException(2, 1, null); Assert.Equal("1", ex.Actual); Assert.Equal("2", ex.Expected); Assert.Null(ex.UserMessage); }
public void NotEqualWithCustomComparer() { string expected = "TestString"; string actual = "testString"; Assert.False(actual == expected); Assert.Equal(expected, actual, StringComparer.CurrentCultureIgnoreCase); Assert.NotEqual(expected, actual, StringComparer.CurrentCulture); }
public void EqualsString() { string testString = "Test String"; string expected = testString; string actual = testString; Assert.True(actual == expected); Assert.Equal(expected, actual); }
public void SingleWithSingleItemCollectionReturnsTheItem() { ArrayList collection = new ArrayList { "Hello" }; object result = Assert.Single(collection); Assert.Equal("Hello", result); }
public void IsNotEmpty() { List <int> list = new List <int>(); list.Add(42); EmptyException ex = Assert.Throws <EmptyException>(() => Assert.Empty(list)); Assert.Equal("Assert.Empty() failure", ex.Message); }
public void EqualsUInt64() { ulong valueType = 35; UInt64 referenceValue = 35; Assert.True(valueType == referenceValue); Assert.Equal(referenceValue, valueType); Assert.Equal <ulong>(valueType, 35); Assert.Equal <ulong>(referenceValue, 35); }
public void When_comparing_object_with_overriden_equality_behavior_to_derived_object_Should_use_overriden_behavior() { var obj = new CustomEqualityObject(); var derivedObj = new DerivedCustomEqualityObject(); Assert.Equal(obj, derivedObj); Assert.True(obj.EqualsCalled); Assert.Equal(obj.EqualsCalledOn, derivedObj); }