public void TodoItem_GetById_Test() { // Arrange var expected = new TodoItem { Description = "Todo Item", DueDate = _sourceDate.AddDays(5), Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.High), Notes = null, Completed = false, CompletedDate = null }; // Arrange - Add new item var list = _uow1.TodoLists.GetById(1); list.Items.Add(expected); _uow1.Commit(); // Act _uow2.TodoItems.EagerLoad(i => i.Priority, i => i.List); var actual = _uow2.TodoItems.GetById(expected.Id); // Assert Assert.IsNotNull(actual); Assert.AreEqual(expected.Id, actual.Id); Assert.AreEqual(expected.Description, actual.Description); Assert.AreEqual(expected.DueDate, actual.DueDate); Assert.AreEqual(expected.Priority.Id, actual.Priority.Id); Assert.AreEqual(expected.Priority.Name, actual.Priority.Name); Assert.AreEqual(expected.Notes, actual.Notes); Assert.AreEqual(expected.Completed, actual.Completed); Assert.AreEqual(expected.CompletedDate, actual.CompletedDate); }
public void TodoItem_Add_Single_Test() { // Arrange var expected = new TodoItem { Description = "New Item 1", List = _uow2.TodoLists.GetById(1), DueDate = DateTime.Parse("2013-11-04 11:07:26"), Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.Medium), Notes = "Test Notes", Completed = false, CompletedDate = null, CreatedDate = DateTime.Now }; // Act _uow1.TodoItems.Add(expected); _uow1.Commit(); // Assert - Get the newly added item _uow2.TodoItems.EagerLoad(i => i.List, i => i.Priority); var actual = _uow2.TodoItems.GetById(expected.Id); // Assert Assert.IsNotNull(actual); Assert.AreEqual(expected.Id, actual.Id); Assert.AreEqual(expected.List.Id, actual.List.Id); Assert.AreEqual(expected.Description, actual.Description); Assert.AreEqual(expected.DueDate, actual.DueDate); Assert.AreEqual(expected.Priority.Id, actual.Priority.Id); Assert.AreEqual(expected.Priority.Name, actual.Priority.Name); Assert.AreEqual(expected.Notes, actual.Notes); Assert.AreEqual(expected.Completed, actual.Completed); Assert.AreEqual(expected.CompletedDate, actual.CompletedDate); }
public void TodoItem_Add_Multiple_Test() { // Arrange var expected1 = new TodoItem { Description = "New Item 1", List = _uow2.TodoLists.GetById(1), DueDate = DateTime.Now.AddDays(-2), Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.Medium), Notes = "Test Notes", Completed = false, CompletedDate = null, CreatedDate = DateTime.Now }; var expected2 = new TodoItem { Description = "New Item 2", List = _uow2.TodoLists.GetById(1), DueDate = DateTime.Now.AddDays(-2), Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.High), Notes = "Test Notes", Completed = true, CompletedDate = DateTime.Now.AddDays(-1), CreatedDate = DateTime.Now }; var expectedList = new List<TodoItem> { expected1, expected2 }; // Act _uow1.TodoItems.Add(expectedList); _uow1.Commit(); // Assert - Get the newly added item _uow2.TodoItems.EagerLoad(i => i.List, i => i.Priority); var actual1 = _uow2.TodoItems.GetById(expected1.Id); var actual2 = _uow2.TodoItems.GetById(expected2.Id); // Assert - Check entity 1 Assert.IsNotNull(actual1); Assert.AreEqual(expected1.Id, actual1.Id); Assert.AreEqual(expected1.List.Id, actual1.List.Id); Assert.AreEqual(expected1.Description, actual1.Description); Assert.AreEqual(expected1.DueDate, actual1.DueDate); Assert.AreEqual(expected1.Priority.Id, actual1.Priority.Id); Assert.AreEqual(expected1.Priority.Name, actual1.Priority.Name); Assert.AreEqual(expected1.Notes, actual1.Notes); Assert.AreEqual(expected1.Completed, actual1.Completed); Assert.AreEqual(expected1.CompletedDate, actual1.CompletedDate); // Assert - Check entity 2 Assert.IsNotNull(actual2); Assert.AreEqual(expected2.Id, actual2.Id); Assert.AreEqual(expected2.List.Id, actual2.List.Id); Assert.AreEqual(expected2.Description, actual2.Description); Assert.AreEqual(expected2.DueDate, actual2.DueDate); Assert.AreEqual(expected2.Priority.Id, actual2.Priority.Id); Assert.AreEqual(expected2.Priority.Name, actual2.Priority.Name); Assert.AreEqual(expected2.Notes, actual2.Notes); Assert.AreEqual(expected2.Completed, actual2.Completed); Assert.AreEqual(expected2.CompletedDate, actual2.CompletedDate); }