Esempio n. 1
0
        public void DBEmptyContextMockerIsEmpty()
        {
            //Arrange
            var db = new DbContextMock.DbEmptyContextMocker().GetContext();

            //Assert
            Assert.Empty(db.TaskLists);
            Assert.Empty(db.TaskItems);
            Assert.Empty(db.TaskLists);
            db.Dispose();
        }
Esempio n. 2
0
        public void AddingTaskInListAndTask()
        {
            //Arrange
            var db = new DbContextMock.DbEmptyContextMocker().GetContext();

            db.TaskLists.Add(new Models.TaskList()
            {
                ListID    = 1,
                ListName  = "test list",
                ProjectID = 5
            });
            db.SaveChanges();

            //Act
            var list = db.TaskLists.Find(1);
            var task = new Models.TaskItem()
            {
                ID                = 1,
                TaskName          = "test task",
                OriginalProjectID = 5,
                TasksInLists      = new List <Models.TaskInList>()
                {
                    new Models.TaskInList()
                    {
                        List    = list,
                        OrderNo = 1
                    }
                }
            };

            db.Add(task);
            db.SaveChanges();

            //Assert

            //task and taskinlist added
            Assert.NotEmpty(db.TaskItems);
            Assert.NotEmpty(db.TasksInLists);

            var taskinlistindb = db.TasksInLists.First();
            var taskindb       = db.TaskItems.First();

            Assert.Equal(taskindb.ID, taskinlistindb.TaskID);

            db.Dispose();
        }