public void ShouldCloneCircularLists() { var circularList = CircularList.CreateStartingFrom0("a", "b", "c"); var clone = Clone.Of(circularList); XAssert.Alike(circularList, clone); XAssert.NotSame(circularList, clone); }
public void ShouldHaveNotPropagateChangesFromClonedInstancesToOriginals() { var data = Any.Instance <ConcreteDataStructure>(); var prevData = Clone.Of(data); Do(data); Assert.Throws <AssertionException>(() => { XAssert.Alike(prevData, data); }); }
public void ShouldAllowGeneratingDummyObjectsBypassingConstructors() { XAssert.Alike(new List <string>(), Any.Dummy <IEnumerable <string> >()); XAssert.Alike(new List <string>(), Any.Dummy <List <string> >()); XAssert.Alike(new List <string>(), Any.Dummy <IList <string> >()); XAssert.Alike(new List <string>(), Any.Dummy <ICollection <string> >()); XAssert.Alike(new string[] {}, Any.Dummy <string[]>()); XAssert.Alike(new RecursiveClass[] {}, Any.Dummy <RecursiveClass[]>()); XAssert.Alike(new Dictionary <int, int>(), Any.Dummy <IDictionary <int, int> >()); XAssert.Alike(new Dictionary <int, int>(), Any.Dummy <IDictionary <int, int> >()); Assert.Multiple(() => { Assert.Throws <TargetInvocationException>(() => Any.Instance <ThrowingInConstructor>()); Assert.NotNull(Any.Dummy <ThrowingInConstructor>()); Assert.NotNull(Any.Dummy <string>()); Assert.NotNull(Any.Dummy <int>()); }); }
public void ShouldAllowToSkipSomePropertiesWhenComparingLikeness() { var tp1 = new TwoProp() { X1 = 123, X2 = 345, X3 = 999, x4 = 123 }; var tp2 = Clone.Of(tp1); tp2.X2 = 346; tp2.X3 = 346; tp2.x4 = 346; XAssert.Alike(tp2, tp1, "X2", "<X2>k__BackingField", "X3", "<X3>k__BackingField", "x4"); XAssert.Alike(tp2, tp1, tp => tp.X2, tp => tp.X3, tp => tp.x4); tp1.X1 = 0; XAssert.NotAlike(tp2, tp1, "X2", "<X2>k__BackingField", "X3", "<X3>k__BackingField", "x4"); XAssert.NotAlike(tp2, tp1, tp => tp.X2, tp => tp.X3, tp => tp.x4); }
public static T IsLike <T>(T expected) { return(Passing <T>(actual => XAssert.Alike(expected, actual))); }
public void Alike <T>(T expected, T actual) { LogException(() => XAssert.Alike(expected, actual)); }
public static AndConstraint <ObjectAssertions> BeLike(this ObjectAssertions o, object expected) { XAssert.Alike(expected, o.Subject); return(new AndConstraint <ObjectAssertions>(o)); }