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); }
public void Delete() { // Arrange InMemoryRepository <Object1> controller = new InMemoryRepository <Object1>(); Object1 test = GetObject1("Test1", 4, true); // Act controller.Save(test); IEnumerable <Object1> resultTest = controller.dbRepository.Values; controller.Commmit(); CollectionAssert.Contains(resultTest, test); controller.Delete(test.Id); controller.Commmit(); resultTest = controller.dbRepository.Values; // Assert CollectionAssert.DoesNotContain(resultTest, test); }
public void AddObject() { // Arrange InMemoryRepository <Object1> controller = new InMemoryRepository <Object1>(); // Act Object1 test = GetObject1("Test1", 4, true); controller.Save(test); controller.Commmit(); Dictionary <Guid, Object1> results = controller.dbRepository; // Assert CollectionAssert.Contains(results.Values, test); }
public void GetAll() { // Arrange InMemoryRepository <Object1> controller = new InMemoryRepository <Object1>(); List <Object1> objectList = GetListObjects(); // Act foreach (Object1 item in objectList) { controller.Save(item); } controller.Commmit(); IEnumerable <Object1> results = controller.All(); IEnumerable <Object1> resultTest = controller.dbRepository.Values; // Assert CollectionAssert.AreEqual(results, resultTest); }
public void FindById() { // Arrange InMemoryRepository <Object1> controller = new InMemoryRepository <Object1>(); List <Object1> objectList = GetListObjects(); // Act foreach (Object1 item in objectList) { controller.Save(item); } Object1 test = objectList[1]; controller.Commmit(); Object1 results = controller.FindById(test.Id); // Assert Assert.AreEqual(results, test); }
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); }
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]); }