public void ReferenceInequality()
    {
        object act = new object();
        object exp = act;

        // MSTest
        MSTestAssert.AreNotSame(exp, act, "Some context");
        // Assert.AreNotSame failed. Some context

        // NUnit
        Assert.That(act, Is.Not.SameAs(exp), () => "Some context");
        // Some context
        //  Expected: not same as <System.Object>
        //  But was: <System.Object>

        // XUnit
        XUnitAssert.NotSame(exp, act);
        // Assert.NotSame() Failure

        // Fluent
        act.Should().NotBeSameAs(exp, "SOME REASONS");
        // Did not expect act to refer to System.Object (HashCode=63566392) because SOME REASONS.

        // Shouldly
        act.ShouldNotBeSameAs(exp, "Some context");
        // act
        //   should not be same as
        // System.Object (48874361)
        //   but was
        // System.Object (48874361)
        //
        // Additional Info:
        //  Some context
    }
Ejemplo n.º 2
0
        public void SerializeDeserializeList1()
        {
            var l  = new List <string>();
            var l2 = l.Serialize().Deserialize <List <string> >();

            Assert.IsTrue(l.SequenceEqual(l2));
            Assert.AreNotSame(l, l2);
        }
Ejemplo n.º 3
0
        public void SerializeDeserializeString()
        {
            const string s  = "testString";
            var          s2 = s.Serialize().Deserialize <string>();

            Assert.AreEqual(s, s2);
            Assert.AreNotSame(s, s2);
        }
Ejemplo n.º 4
0
        public void GetBookReturnsDifferentObjects()
        {
            var book1 = GetBook("Book 1");
            var book2 = GetBook("Book 2");

            Assert.AreEqual("Book 1", book1.Name);
            Assert.AreEqual("Book 2", book2.Name);
            Assert.AreNotSame(book1, book2);
        }
Ejemplo n.º 5
0
 /// <summary>Assert.AreNotSame</summary>
 public static void IsNotSameReferenceAs <T>(this T actual, T notExpected, string message = "")
 {
     Assert.AreNotSame(notExpected, actual, message);
 }
Ejemplo n.º 6
0
 public void AreThereTwoRoots()
 {
     Assert.AreNotSame(Program.Roots(2, 10, 7).X1, Program.Roots(2, 5, 7).X2);
 }