示例#1
0
        private ToDoService GetToDoService(MsSqlLiteDatabaseContext context, List <ToDoDbModel> toDos)
        {
            context.Database.OpenConnection();
            context.Database.EnsureCreated();
            context.ToDos.AddRange(toDos);
            context.SaveChanges();

            var toDoRepository = new ToDoRepository(context, kernel.Get <IToDoEntityConverter>());

            return(new ToDoService(toDoRepository));
        }
示例#2
0
        public async Task GetToDosFromContext()
        {
            using MsSqlLiteDatabaseContext context = new MsSqlLiteDatabaseContext(optionsSnapShotMock.Object);
            var toDoService = GetToDoService(context, toDosForContextLoading);
            var toDo        = await toDoService.GetToDoItemByIdAsync(id : 2);

            Assert.IsNotNull(toDo);
            Assert.AreEqual(2, toDo.Id);
            Assert.AreEqual("Second Task", toDo.Description);
            Assert.IsFalse(toDo.IsCompleted);

            context.Database.CloseConnection();
        }
示例#3
0
        public async Task GetAllPagingTest()
        {
            using MsSqlLiteDatabaseContext context = new MsSqlLiteDatabaseContext(optionsSnapShotMock.Object);
            var toDoService = GetToDoService(context, toDosForPaging);
            var paging      = new PagingDto {
                PageNumber = 2, PageSize = 5
            };

            int expectedToDosCount = 2;
            int actualToDosCount   = (await toDoService.GetAllAsync(null, paging)).Count();

            Assert.AreEqual(expectedToDosCount, actualToDosCount);

            context.Database.CloseConnection();
        }
示例#4
0
        public async Task GetAllFilteringTest(int rowNumber, int expectedCount, int pageNumber, FilterDto filter)
        {
            using MsSqlLiteDatabaseContext context = new MsSqlLiteDatabaseContext(optionsSnapShotMock.Object);
            var toDoService = GetToDoService(context, toDosForFiltering);
            var paging      = new PagingDto {
                PageNumber = pageNumber, PageSize = 5
            };

            int actualCount = (await toDoService.GetAllAsync(filter, paging)).Count();

            Assert.AreEqual(expectedCount, actualCount);

            Debug.WriteLine($"TestCase row {rowNumber} completed.");

            context.Database.CloseConnection();
        }
示例#5
0
 public ToDoRepository(MsSqlLiteDatabaseContext dbContext, IToDoEntityConverter toDoEntityConverter)
 {
     this.dbContext           = dbContext;
     this.toDoEntityConverter = toDoEntityConverter;
 }
示例#6
0
 public TimeReportRepository(MsSqlLiteDatabaseContext dbContext, ITimeReportEntityConverter timeReportEntityConverter)
 {
     this.dbContext = dbContext;
     this.timeReportEntityConverter = timeReportEntityConverter;
 }