public void UpdateAndInsertItems() { var list = new List <TimeEntry>(); var timeEntryToAdd = new TimeEntry() { Id = ObjectId.GenerateNewId(), Date = DateTime.Now, Project = "project 2", Quantity = 8 }; timeEntryToUpdate.Quantity = 8; list.Add(timeEntryToUpdate); list.Add(timeEntryToAdd); var command = new CreateOrUpdateTimeSheet(list, "FakeUser"); var commandHandler = new CreateOrUpdateTimeSheetHandler(mockSession); commandHandler.Execute(command); Assert.AreEqual(2, ((MockSession)mockSession).collection.Count); Assert.AreEqual(8, mockSession.GetQueryable <TimeEntry>().Single(c => c.Id == timeEntryToUpdate.Id).Quantity); Assert.AreEqual(8, mockSession.GetQueryable <TimeEntry>().Single(c => c.Id == timeEntryToAdd.Id).Quantity); Assert.AreEqual("project 2", mockSession.GetQueryable <TimeEntry>().Single(c => c.Id == timeEntryToAdd.Id).Project); Assert.AreEqual(timeEntryToUpdate.Date, mockSession.GetQueryable <TimeEntry>().Single(c => c.Id == timeEntryToUpdate.Id).Date); Assert.AreEqual(timeEntryToAdd.Date, mockSession.GetQueryable <TimeEntry>().Single(c => c.Id == timeEntryToAdd.Id).Date); }
public void UpdateItemWithQuantityNull() { var list = new List <TimeEntry>(); timeEntryToUpdate.Quantity = null; list.Add(timeEntryToUpdate); var command = new CreateOrUpdateTimeSheet(list, "FakeUser"); var commandHandler = new CreateOrUpdateTimeSheetHandler(mockSession); commandHandler.Execute(command); Assert.AreEqual(1, ((MockSession)mockSession).collection.Count); Assert.AreEqual(null, mockSession.GetQueryable <TimeEntry>().Single(c => c.Id == timeEntryToUpdate.Id).Quantity); }