public void DeleteItem() { // Arrange PersonRepository repository = new PersonRepository(connection); Person person = new Person { Id = 0, PersonName = "chiko", Age = 5 }; repository.AddItem(person); var chiko = repository.GetItemsByKeyword(person.PersonName).First(); // Act int res = repository.DeleteItem(chiko); // Assert Assert.AreEqual(1, res); }
public void AddItem() { // Arrange PersonRepository repository = new PersonRepository(connection); var pbObj = new PrivateObject(repository); int newId = (int)pbObj.Invoke("GetNextId", null); // Act Person person = new Person { Id = 0, PersonName = "Goro", Age = 3 }; int res = repository.AddItem(person); // Assert Assert.AreEqual(0, newId - res); Console.WriteLine("NewId:" + newId + " Res:" + res); }
public void UpdateItem() { // Arrange PersonRepository repository = new PersonRepository(connection); Person person = new Person { PersonName = "hachi", Age = 32 }; repository.AddItem(person); Person hachi = repository.GetItemsByKeyword("hachi").FirstOrDefault(); Assert.AreEqual(32, hachi.Age); // Act hachi.Age = 28; repository.UpdateItem(hachi); // Assert var res = repository.GetItemsByKeyword("hachi").FirstOrDefault(); Assert.AreEqual(28, res.Age); }