Exemplo n.º 1
0
        public void NotEqualToAnyThingElse()
        {
            var e1 = EntityStub.NewWithId(1);

            Assert.That((object)null, Is.Not.EqualTo(e1));
            Assert.That(new object(), Is.Not.EqualTo(e1));
        }
Exemplo n.º 2
0
        public void HashDontChange()
        {
            var e       = new EntityStub();
            var oldHash = e.GetHashCode();

            e.SetId(100);
            e.GetHashCode().Should().Be.EqualTo(oldHash);
        }
Exemplo n.º 3
0
        public void PersistentWithDifferentId()
        {
            const int id1 = 1;
            const int id2 = 2;
            var       e1  = EntityStub.NewWithId(id1);
            var       e2  = EntityStub.NewWithId(id2);

            e2.Should().Not.Be.EqualTo(e1);
            e2.Should().Be.EqualTo(e2);
            Assert.That(1, Is.Not.EqualTo(e1));
        }
Exemplo n.º 4
0
        public void HashCode()
        {
            const int id1 = 1;

            (new EntityStub()).GetHashCode()
            .Should("transients should not have same hash")
            .Not.Be.EqualTo((new EntityStub()).GetHashCode());

            EntityStub.NewWithId(id1).GetHashCode()
            .Should("persistent should have same hash.")
            .Be.EqualTo(EntityStub.NewWithId(id1).GetHashCode());

            EntityStub.NewWithId(id1).GetHashCode()
            .Should("persistent inherited should have same hash.")
            .Be.EqualTo(EntityStubInherit.NewWithId(id1).GetHashCode());
        }
Exemplo n.º 5
0
 public void PersistentInheritedWithSameId()
 {
     EntityStubInherit.NewWithId(1).Should().Be.EqualTo(EntityStub.NewWithId(1));
 }
Exemplo n.º 6
0
 public void PersistentOfDifferentClassAndSameId()
 {
     EntityStubA.NewWithId(1).Should().Not.Be.EqualTo(EntityStub.NewWithId(1));
 }