Ejemplo n.º 1
0
        public void TodoList_Add_Multiple_Test()
        {
            // Arrange
            var expected1 = new TodoList
            {
                Name = "New Todo List 1",
                Items = new List<TodoItem>
                {
                    new TodoItem { Description = "New Todo Item 1 1", Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.High), CreatedDate = DateTime.Now },
                    new TodoItem { Description = "New Todo Item 1 2", Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.Medium), CreatedDate = DateTime.Now },
                    new TodoItem { Description = "New Todo Item 1 3", Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.Low), CreatedDate = DateTime.Now }
                }
            };

            var expected2 = new TodoList
            {
                Name = "New Todo List 2",
                Items = new List<TodoItem>
                {
                    new TodoItem { Description = "New Todo Item 2 1", Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.High), CreatedDate = DateTime.Now },
                    new TodoItem { Description = "New Todo Item 2 2", Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.Medium), CreatedDate = DateTime.Now },
                    new TodoItem { Description = "New Todo Item 2 3", Priority = _uow2.TodoPriorities.GetById((int)TodoPriorities.Low), CreatedDate = DateTime.Now }
                }
            };

            var expectedList = new List<TodoList>();
            expectedList.Add(expected1);
            expectedList.Add(expected2);

            // Act
            _uow1.TodoLists.Add(expectedList);
            _uow1.Commit();

            // Assert
            var actual1 = _uow2.TodoLists.GetById(expected1.Id);
            Assert.IsNotNull(actual1);
            Assert.AreEqual(expected1.Id, actual1.Id);
            Assert.AreEqual(expected1.Name, actual1.Name);
            Assert.AreEqual(expected1.Items.Count, actual1.Items.Count);

            var actual2 = _uow2.TodoLists.GetById(expected2.Id);
            Assert.IsNotNull(actual2);
            Assert.AreEqual(expected2.Id, actual2.Id);
            Assert.AreEqual(expected2.Name, actual2.Name);
            Assert.AreEqual(expected2.Items.Count, actual2.Items.Count);
        }
Ejemplo n.º 2
0
        public void TodoList_Add_Single_Test()
        {
            // Arrange
            var expected = new TodoList
            {
                Name = "New Todo List",
                Items = new List<TodoItem>
                {
                    new TodoItem { Description = "New Todo Item 1" },
                    new TodoItem { Description = "New Todo Item 2" },
                    new TodoItem { Description = "New Todo Item 3" }
                }
            };

            // Act
            _uow1.TodoLists.Add(expected);

            // Assert
            var actual = _uow2.TodoLists.GetById(expected.Id);
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Items.Count, actual.Items.Count);
        }