예제 #1
0
        public void Update()
        {
            InMemoryRepository <Object1> controller = new InMemoryRepository <Object1>();
            Object1 test = GetObject1("Test1", 4, true);

            // Act
            controller.Save(test);
            controller.Commmit();
            test.Item2 = 5;
            controller.Update(test);
            controller.Commmit();
            Object1 result = controller.FindById(test.Id);

            // Assert
            Assert.AreEqual(result.Item2, test.Item2);
        }
예제 #2
0
        public void Rollback()
        {
            InMemoryRepository <Object1> controller = new InMemoryRepository <Object1>();
            List <Object1> objectList = GetListObjects();


            // Act
            foreach (Object1 item in objectList)
            {
                controller.Save(item);
            }
            controller.Delete(objectList[2].Id);
            objectList[2].Item2 = 2;
            controller.Update(objectList[2]);
            controller.RollBack();
            controller.Commmit();
            IEnumerable <Object1> check = controller.All();

            // Act

            // Assert
            CollectionAssert.IsEmpty(check);
        }
예제 #3
0
        public void CompletedTest()
        {
            // Arrange
            InMemoryRepository <Object1> controller = new InMemoryRepository <Object1>();
            List <Object1>        objectList        = GetListObjects();
            IEnumerable <Object1> repoList          = controller.dbRepository.Values;

            // Save Act
            foreach (Object1 item in objectList)
            {
                controller.Save(item);
            }

            // Delete Act
            controller.Delete(objectList[2].Id);
            objectList[0].Item2 = 25;
            controller.Update(objectList[0]);
            controller.Commmit();

            //Embty Assert
            CollectionAssert.Contains(repoList, objectList[0]);
            CollectionAssert.Contains(repoList, objectList[1]);
            CollectionAssert.DoesNotContain(repoList, objectList[2]);
        }