public void Remove_Deletes_RentalOrder() { using (var context = new VivesRentalDbContext()) { //Arrange var userRepository = new UserRepository(context); var rentalOrderRepository = new RentalOrderRepository(context); var user = UserFactory.CreateValidEntity(); userRepository.Add(user); var rentalOrderToAdd = RentalOrderFactory.CreateValidEntity(user); rentalOrderRepository.Add(rentalOrderToAdd); var rentalOrderId = rentalOrderToAdd.Id; context.SaveChanges(); //Act rentalOrderRepository.Remove(rentalOrderToAdd); context.SaveChanges(); var rentalOrder = rentalOrderRepository.Get(rentalOrderId); //Assert Assert.IsNull(rentalOrder); } }
public void Get_Returns_Null_When_Not_Found() { using (var context = new VivesRentalDbContext()) { //Arrange var rentalOrderRepository = new RentalOrderRepository(context); //Act var rentalOrder = rentalOrderRepository.Get(1); //Assert Assert.IsNull(rentalOrder); } }
public void Get_Returns_RentalOrder_When_Found() { using (var context = new VivesRentalDbContext()) { //Arrange var userRepository = new UserRepository(context); var rentalOrderRepository = new RentalOrderRepository(context); var user = UserFactory.CreateValidEntity(); userRepository.Add(user); var rentalOrderToAdd = RentalOrderFactory.CreateValidEntity(user); rentalOrderRepository.Add(rentalOrderToAdd); context.SaveChanges(); //Act var rentalOrder = rentalOrderRepository.Get(rentalOrderToAdd.Id); //Assert Assert.IsNotNull(rentalOrder); } }