public async Task GetAllIncludingTasksAsync()
        {
            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var conn = databaseOptions.GetDbConnection;
                userDapper     = new UserRepository(conn);
                taskToDoDapper = new TaskToDoRepository(conn);

                var user1 = await userDapper.AddAsync(userBuilder.CreateUser());

                var user2 = await userDapper.AddAsync(userBuilder.CreateUser());

                var task1 = await taskToDoDapper.AddRangeAsync(taskToDoBuilder.CreateTaskToDoListWithUser(1, user1.Id));

                var task2 = await taskToDoDapper.AddRangeAsync(taskToDoBuilder.CreateTaskToDoListWithUser(2, user2.Id));

                var result = await userDapper.GetAllIncludingTasksAsync();

                var result1 = result.OrderBy(u => u.Id).FirstOrDefault();
                var result2 = result.OrderBy(u => u.Id).LastOrDefault();

                Assert.AreEqual(result1.Id, user1.Id);
                Assert.AreEqual(result2.Id, user2.Id);

                Assert.AreEqual(result1.TasksToDo.Count(), 1);
                Assert.AreEqual(result2.TasksToDo.Count(), 2);
            }
        }
コード例 #2
0
        public async Task GetAllIncludingUserAsync()
        {
            var user = await userDapper.AddAsync(userBuilder.CreateUser());

            var task = await taskToDoDapper.AddRangeAsync(taskToDoBuilder.CreateTaskToDoListWithUser(2, user.Id));

            var result = await taskToDoDapper.GetAllIncludingUserAsync();

            Assert.AreEqual(result.FirstOrDefault().UserId, user.Id);
            Assert.AreEqual(result.LastOrDefault().UserId, user.Id);
        }
コード例 #3
0
        public async Task GetAllIncludingTasksAsync()
        {
            var user1 = await userDapper.AddAsync(userBuilder.CreateUser());

            var user2 = await userDapper.AddAsync(userBuilder.CreateUser());

            var task1 = await taskToDoDapper.AddRangeAsync(taskToDoBuilder.CreateTaskToDoListWithUser(1, user1.Id));

            var task2 = await taskToDoDapper.AddRangeAsync(taskToDoBuilder.CreateTaskToDoListWithUser(2, user2.Id));

            var result = await userDapper.GetAllIncludingTasksAsync();

            var result1 = result.OrderBy(u => u.Id).FirstOrDefault();
            var result2 = result.OrderBy(u => u.Id).LastOrDefault();

            Assert.AreEqual(result1.Id, user1.Id);
            Assert.AreEqual(result2.Id, user2.Id);

            Assert.AreEqual(result1.TasksToDo.Count(), 1);
            Assert.AreEqual(result2.TasksToDo.Count(), 2);
        }
コード例 #4
0
        public async Task GetAllIncludingUserAsync()
        {
            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var conn = databaseOptions.GetDbConnection;
                userDapper     = new UserRepository(conn);
                taskToDoDapper = new TaskToDoRepository(conn);

                var user = await userDapper.AddAsync(userBuilder.CreateUser());

                var task = await taskToDoDapper.AddRangeAsync(taskToDoBuilder.CreateTaskToDoListWithUser(2, user.Id));

                var result = await taskToDoDapper.GetAllIncludingUserAsync();

                Assert.AreEqual(result.FirstOrDefault().UserId, user.Id);
                Assert.AreEqual(result.LastOrDefault().UserId, user.Id);
            }
        }