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); }
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); }
private void DeleteInitialData() { ICostTypeRepository repository = new CostTypeRepository(); foreach (var costType in _costTypes) { CostType fromDb = repository.GetById(costType.CostTypeId); if (fromDb != null) { repository.Remove(costType); } } }
public void Can_add_new_costType() { var costType = new CostType ("test new cost name"); ICostTypeRepository repository = new CostTypeRepository(); repository.Add(costType); // use session to try to load the costType 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); } repository.Remove(costType); }
public void Can_remove_existing_costType() { var costType = _costTypes[0]; ICostTypeRepository repository = new CostTypeRepository(); repository.Remove(costType); using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<CostType>(costType.CostTypeId); Assert.IsNull(fromDb); } }