Exemplo n.º 1
0
        public void EqualsMethodsTest()
        {
            // Arrange:
            var newA = new TestBusinessObject {
                Name = "A"
            };
            var newB = new TestBusinessObject {
                Name = "B"
            };
            var savedA1 = new TestBusinessObject {
                Id = 1, Name = "A"
            };
            var savedA2 = new TestBusinessObject {
                Id = 2, Name = "A"
            };
            var savedB = new TestBusinessObject {
                Id = 3, Name = "B"
            };

            // Act/Assert:
            EqualityMethodsTestHelper(newA, null, false);
            EqualityMethodsTestHelper(newA, newA, true);
            EqualityMethodsTestHelper(newA, "String", false);
            EqualityMethodsTestHelper(newA, newB, false);
            EqualityMethodsTestHelper(newB, savedB, false);
            EqualityMethodsTestHelper(savedA1, savedA1, true);
            EqualityMethodsTestHelper(savedA1, savedA2, false);
            EqualityMethodsTestHelper(savedA1, savedB, false);
        }
Exemplo n.º 2
0
        public void ShouldSave()
        {
            // Arrange
            var entity = new TestBusinessObject();

            // Act
            _repository.Save(entity);
            _unitOfWork.Commit();
        }
Exemplo n.º 3
0
 public StudentPassTestViewModel(TestBusinessObject test, StudentTestBusinessObject testDetails)
 {
     Test        = test;
     TestDetails = testDetails;
     InitializeContainers();
     ResolveContainers();
     InitializeServices();
     InitializeProperties();
     InitializeTest();
 }
Exemplo n.º 4
0
        public void GetHashCodeTest()
        {
            // Arrange:
            var newItem1 = new TestBusinessObject {
                Name = "A"
            };
            var newItem2 = new TestBusinessObject {
                Name = "A"
            };
            var savedItem = new TestBusinessObject {
                Id = 1, Name = "A"
            };

            // Act/Assert:
            Assert.AreNotEqual(newItem1.GetHashCode(), newItem2.GetHashCode());
            Assert.AreEqual(savedItem.Id.GetHashCode(), savedItem.GetHashCode());
        }
Exemplo n.º 5
0
        public void IsNewTest()
        {
            // Arrange:
            var target1 = new TestBusinessObject {
                Name = "Name"
            };
            var target2 = new TestBusinessObject {
                Id = 1, Name = "Name"
            };

            // Act:
            var target1IsNew = target1.IsNew;
            var target2IsNew = target2.IsNew;

            // Assert:
            Assert.IsTrue(target1IsNew);
            Assert.IsFalse(target2IsNew);
        }
Exemplo n.º 6
0
        public void ShouldLoad()
        {
            // Arrange
            const string TestString = "TEST";
            var          entity     = new TestBusinessObject
            {
                TestProperty = TestString
            };

            _repository.Save(entity);
            _unitOfWork.Commit();

            // Act
            var entityFromStorage = _repository.Get(entity.Id);

            // Assert
            Assert.Equal(entity.Id, entityFromStorage.Id);
            Assert.Equal(entity.TestProperty, TestString);
        }