public async Task RemoveAsync_EmptyGroup_RemovePerformed()
        {
            ITasksGroup tasksGroup = mTasksGroupFactory.CreateGroup("emptyGroup");

            IDbRepository <ITasksGroup> dbRepository = A.Fake <IDbRepository <ITasksGroup> >();

            A.CallTo(() => dbRepository.FindAsync(tasksGroup.ID)).Returns(tasksGroup);
            TasksGroupService tasksGroupService =
                new TasksGroupService(dbRepository, mTasksGroupFactory, NullLogger <TasksGroupService> .Instance);

            await tasksGroupService.RemoveAsync(tasksGroup.ID).ConfigureAwait(false);

            A.CallTo(() => dbRepository.RemoveAsync(A <ITasksGroup> .Ignored)).MustHaveHappenedOnceExactly();
        }
        public async Task RemoveAsync_IdNotExists_RemoveNotPerformed()
        {
            const string wrongID = "wrongID";

            IDbRepository <ITasksGroup> dbRepository = A.Fake <IDbRepository <ITasksGroup> >();

            A.CallTo(() => dbRepository.FindAsync(wrongID)).Returns <ITasksGroup>(null);
            TasksGroupService tasksGroupService =
                new TasksGroupService(dbRepository, mTasksGroupFactory, NullLogger <TasksGroupService> .Instance);

            await tasksGroupService.RemoveAsync(wrongID).ConfigureAwait(false);

            A.CallTo(() => dbRepository.RemoveAsync(A <ITasksGroup> .Ignored)).MustNotHaveHappened();
        }
        public async Task RemoveAsync_IdNotExists_FailResponseReturned()
        {
            const string wrongID = "wrongID";

            IDbRepository <ITasksGroup> dbRepository = A.Fake <IDbRepository <ITasksGroup> >();

            A.CallTo(() => dbRepository.FindAsync(wrongID)).Returns <ITasksGroup>(null);
            TasksGroupService tasksGroupService =
                new TasksGroupService(dbRepository, mTasksGroupFactory, NullLogger <TasksGroupService> .Instance);

            IResponse <ITasksGroup> response = await tasksGroupService.RemoveAsync(wrongID).ConfigureAwait(false);

            Assert.False(response.IsSuccess);
            Assert.Null(response.ResponseObject);
        }
        public async Task RemoveAsync_EmptyGroup_SuccessResponseReturned()
        {
            ITasksGroup tasksGroup = mTasksGroupFactory.CreateGroup("emptyGroup");

            IDbRepository <ITasksGroup> dbRepository = A.Fake <IDbRepository <ITasksGroup> >();

            A.CallTo(() => dbRepository.FindAsync(tasksGroup.ID)).Returns(tasksGroup);
            TasksGroupService tasksGroupService =
                new TasksGroupService(dbRepository, mTasksGroupFactory, NullLogger <TasksGroupService> .Instance);

            IResponse <ITasksGroup> response = await tasksGroupService.RemoveAsync(tasksGroup.ID).ConfigureAwait(false);

            Assert.True(response.IsSuccess);
            Assert.Equal(tasksGroup, response.ResponseObject);
        }
        public async Task RemoveAsync_GroupWithChildren_RemoveNotPerformed()
        {
            ITasksGroup tasksGroup = mTasksGroupFactory.CreateGroup("group");

            mTasksGroupFactory.CreateTask(tasksGroup, "task1");

            IDbRepository <ITasksGroup> dbRepository = A.Fake <IDbRepository <ITasksGroup> >();

            A.CallTo(() => dbRepository.FindAsync(tasksGroup.ID)).Returns(tasksGroup);
            TasksGroupService tasksGroupService =
                new TasksGroupService(dbRepository, mTasksGroupFactory, NullLogger <TasksGroupService> .Instance);

            await tasksGroupService.RemoveAsync(tasksGroup.ID).ConfigureAwait(false);

            A.CallTo(() => dbRepository.RemoveAsync(A <ITasksGroup> .Ignored)).MustNotHaveHappened();
        }