예제 #1
0
        public async Task Get_TodoItem_Complete()
        {
            var dbContext  = DbMock.CreateTestingDatabase(nameof(Get_TodoItem_Complete));
            var mockTodoes = new List <TodoItem>()
            {
                new TodoItem()
                {
                    Id    = Guid.NewGuid(),
                    Title = "Test1",
                },
                new TodoItem()
                {
                    Id    = Guid.NewGuid(),
                    Title = "Test2",
                }
            };

            dbContext.Seed(mockTodoes);
            var service = new TodoService(dbContext);
            var result  = await service.GetTodoItem(mockTodoes.First().Id);

            //release the allocated memory
            dbContext.Dispose();
            Assert.NotNull(result);
            Assert.IsType <TodoItem>(result);
        }
예제 #2
0
        public async Task Get_TodoItems_NotFound()
        {
            var dbContext = DbMock.CreateTestingDatabase(nameof(Get_TodoItems_NotFound));
            var service   = new TodoService(dbContext);
            var result    = await service.GetTodoItems();

            //release the allocated memory
            dbContext.Dispose();
            Assert.Empty(result);
        }