public void GetHashCode_WithEqualityComponentsNull_ShouldThrow() { var instance = new Dummy1(); Action action = () => instance.GetHashCode(); action.ShouldThrow <InvalidOperationException>() .Message.ShouldBe("GetEqualityComponents must return at least one component."); }
public void TestSameValueDifferentTypeUsingGenericTypes() { var d1 = new Dummy(12); var d2 = new Dummy1(12); var dc1 = new DummyGenericClass <Dummy>(d1); var dc2 = new DummyGenericClass <Dummy1>(d2); var ex = Assert.Throws <AssertionException>(() => Assert.AreEqual(dc1, dc2)); var expectedMsg = " Expected: <Dummy 12> (EqualConstraintTests+DummyGenericClass`1[EqualConstraintTests+Dummy])" + Environment.NewLine + " But was: <Dummy 12> (EqualConstraintTests+DummyGenericClass`1[EqualConstraintTests+Dummy1])" + Environment.NewLine; Assert.AreEqual(expectedMsg, ex.Message); }
public void GetIdValue_WhenIntNotOnFirstLevel_ThrowsSisoDbException() { var dummy2PropertyInfo = typeof(Dummy1).GetProperty("Item"); var dummy2Property = new Property(dummy2PropertyInfo); var intPropertyInfo = typeof(Dummy2).GetProperty("Id"); var intProperty = new Property(1, dummy2Property, intPropertyInfo); var item = new Dummy1 { Item = new Dummy2 { Id = 42 } }; var ex = Assert.Throws<SisoDbException>(() => intProperty.GetIdValue<Dummy1, int>(item)); Assert.AreEqual(ExceptionMessages.Property_GetIdValue_InvalidLevel, ex.Message); }
public void GetIdValue_WhenGuidNotOnFirstLevel_ThrowsSisoDbException() { var dummy2PropertyInfo = typeof (Dummy1).GetProperty("Item1"); var dummy2Property = new Property(dummy2PropertyInfo); var guidPropertyInfo = typeof(Dummy2).GetProperty("Id"); var guidProperty = new Property(1, dummy2Property,guidPropertyInfo); var item = new Dummy1 { Item1 = new Dummy2 { Id = Guid.NewGuid() } }; var ex = CustomAssert.Throws<SisoDbException>(() => guidProperty.GetIdValue<Dummy1, Guid>(item)); Assert.AreEqual(ExceptionMessages.Property_GetIdValue_InvalidLevel, ex.Message); }
public static void Main() { Dummy1 obj = new Dummy1(); GC.Collect(); GC.WaitForPendingFinalizers(); if((Dummy1.visited == false) && (Dummy2.visited == false)) { // has not visited the Finalize() Environment.ExitCode = 0; Console.WriteLine("Test passed!"); } else { Environment.ExitCode = 1; Console.WriteLine("Test failed!"); } GC.KeepAlive(obj); }
public static void Main() { Dummy1 obj = new Dummy1(); GC.Collect(); GC.WaitForPendingFinalizers(); if ((Dummy1.visited == false) && (Dummy2.visited == false)) // has not visited the Finalize() { Environment.ExitCode = 0; Console.WriteLine("Test passed!"); } else { Environment.ExitCode = 1; Console.WriteLine("Test failed!"); } GC.KeepAlive(obj); }
public static int Main() { int returnValue = 0; Dummy1 obj = new Dummy1(); GC.Collect(); GC.WaitForPendingFinalizers(); if((Dummy1.visited == false) && (Dummy2.visited == false)) { // has not visited the Finalize() returnValue = 100; Console.WriteLine("Test passed!"); } else { returnValue = 1; Console.WriteLine("Test failed!"); } GC.KeepAlive(obj); return returnValue; }
public static int Main() { int returnValue = 0; Dummy1 obj = new Dummy1(); GC.Collect(); GC.WaitForPendingFinalizers(); if ((Dummy1.visited == false) && (Dummy2.visited == false)) // has not visited the Finalize() { returnValue = 100; Console.WriteLine("Test passed!"); } else { returnValue = 1; Console.WriteLine("Test failed!"); } GC.KeepAlive(obj); return(returnValue); }