public void Can_add_new_cost() { var cost = new Cost(100.50); ICostRepository repository = new CostRepository(); repository.Add(cost); // use session to try to load the cost using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<Cost>(cost.CostId); // Test that the cost was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(cost, fromDb); Assert.AreEqual(cost.CostValue, fromDb.CostValue); } repository.Remove(cost); }
private void DeleteInitialData() { ITrainingRepository trainingRepository = new TrainingRepository(); foreach (var training in _trainings) { Training fromDb = trainingRepository.GetById(training.TrainingId); if (fromDb != null) { trainingRepository.Remove(training); } } IUserRepository userRepository = new UserRepository(); userRepository.Remove(_user1); userRepository.Remove(_user2); IDogRepository dogRepository = new DogRepository(); dogRepository.Remove(_dog1); dogRepository.Remove(_dog2); ICostRepository costRepository = new CostRepository(); costRepository.Remove(_classCost); costRepository.Remove(_preK9DaycareCost); costRepository.Remove(_newClassCost); ICostTypeRepository costTypeRepository = new CostTypeRepository(); costTypeRepository.Remove(_classType); }
private void DeleteInitialData() { IDaycareRepository daycareRepository = new DaycareRepository(); foreach (var daycare in _daycares) { Daycare fromDb = daycareRepository.GetById(daycare.DaycareId); if (fromDb != null) { daycareRepository.Remove(daycare); } } IUserRepository userRepository = new UserRepository(); userRepository.Remove(_user1); userRepository.Remove(_user2); IDogRepository dogRepository = new DogRepository(); dogRepository.Remove(_dog1); dogRepository.Remove(_dog2); ICostRepository costRepository = new CostRepository(); costRepository.Remove(_daycareCost); }
private void DeleteInitialData() { IPickupDropoffRepository pickupDropoffRepository = new PickupDropoffRepository(); foreach (var pickupDropoff in _pickupDropoffs) { PickupDropoff fromDb = pickupDropoffRepository.GetById(pickupDropoff.PickupDropoffId); if (fromDb != null) { pickupDropoffRepository.Remove(pickupDropoff); } } IUserRepository userRepository = new UserRepository(); userRepository.Remove(_user1); userRepository.Remove(_user2); IDogRepository dogRepository = new DogRepository(); dogRepository.Remove(_dog1); dogRepository.Remove(_dog2); ICostRepository costRepository = new CostRepository(); costRepository.Remove(_pickupCost); costRepository.Remove(_dropoffCost); costRepository.Remove(_newPickupCost); }
public void Can_add_new_cost_type_with_new_costs() { var costType = new CostType("new cost type"); ICostTypeRepository costTypeRepository = new CostTypeRepository(); costTypeRepository.Add(costType); var cost1 = new Cost(1000.11); var cost2 = new Cost(1500.11); ICostRepository costRepository = new CostRepository(); costRepository.Add(cost1); costRepository.Add(cost2); IList<Cost> possibleCosts = new List<Cost>(); possibleCosts.Add(cost1); possibleCosts.Add(cost2); costType.PossibleCosts = possibleCosts; costTypeRepository.Update(costType); // use session to try to load the cost type using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<CostType>(costType.CostTypeId); // Test that the costType was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(costType, fromDb); Assert.AreEqual(costType.CostName, fromDb.CostName); Assert.AreEqual(possibleCosts.Count, fromDb.PossibleCosts.Count); } costTypeRepository.Remove(costType); costRepository.Remove(cost1); costRepository.Remove(cost2); }
public void Can_remove_existing_cost() { var cost = _costs[0]; ICostRepository repository = new CostRepository(); repository.Remove(cost); using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<Cost>(cost.CostId); Assert.IsNull(fromDb); } }
private void DeleteInitialData() { ICostRepository repository = new CostRepository(); foreach (var cost in _costs) { Cost fromDb = repository.GetById(cost.CostId); if (fromDb != null) { repository.Remove(cost); } } }
private void DeleteInitialData() { IBoardingRepository boardingRepository = new BoardingRepository(); foreach (var boarding in _boardings) { Boarding fromDb = boardingRepository.GetById(boarding.BoardingId); if (fromDb != null) { boardingRepository.Remove(boarding); } } IUserRepository userRepository = new UserRepository(); userRepository.Remove(_user1); userRepository.Remove(_user2); IDogRepository dogRepository = new DogRepository(); dogRepository.Remove(_dog1); dogRepository.Remove(_dog2); ICostRepository costRepository = new CostRepository(); costRepository.Remove(_boardingCost); costRepository.Remove(_sundayDaycareCost); }