public void Can_add_new_grooming() { DateTime date = DateTime.Now; // Set the Milliseconds to 0 since MySQL DATETIME does not support milliseconds. date = DateTime.ParseExact(date.ToString(), "M/d/yyyy h:mm:ss tt", null); var grooming = new Grooming(_groomingType1, 245.50, date, _dog1, _user1); IGroomingRepository repository = new GroomingRepository(); repository.Add(grooming); // use session to try to load the grooming using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<Grooming>(grooming.GroomingId); // Test that the grooming was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(grooming, fromDb); Assert.AreEqual(grooming.GroomingType, fromDb.GroomingType); Assert.AreEqual(grooming.Cost, fromDb.Cost); Assert.AreEqual(grooming.Date, fromDb.Date); Assert.AreEqual(grooming.Dog, fromDb.Dog); Assert.AreEqual(grooming.User, fromDb.User); } repository.Remove(grooming); }
public void PayrollTracker_SaveButtonClickedEventHandler(object sender, EventArgs e) { GroomingRepository repository = new GroomingRepository(); foreach (KeyValuePair<int, Grooming> entry in dirtyObjectsMap) { Grooming grooming = entry.Value; bool isValid = groomingDataGridView_RowValidating(entry.Key, grooming); if (isValid) { if (grooming.GroomingId == null) { repository.Add(grooming); } else { repository.Update(grooming); } dirtyObjectsMap = new Dictionary<int, Grooming>(); refreshDisplayFromDatabase(); } } }