Exemplo n.º 1
0
        public async Task UnregisterTaskSendsTaskUnenrollCommandAsyncWithCorrectTaskIdAndUserId()
        {
            const string userId = "1";
            const int    taskId = 1;

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <TaskUnenrollCommand>())).ReturnsAsync(new TaskUnenrollResult());

            var sut = new TaskApiController(null, mediator.Object, null);

            sut.SetFakeUser(userId);

            await sut.UnregisterTask(taskId);

            mediator.Verify(x => x.SendAsync(It.Is <TaskUnenrollCommand>(y => y.TaskId == taskId && y.UserId == userId)));
        }
Exemplo n.º 2
0
        public async Task UnregisterTaskSendsTaskUnenrollCommandWithCorrectTaskIdAndUserId()
        {
            const string userId = "1";
            const int    taskId = 1;

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <TaskUnenrollCommand>())).ReturnsAsync(new TaskUnenrollResult());

            var userManager = MockHelper.CreateUserManagerMock();

            userManager.Setup(x => x.GetUserId(It.IsAny <ClaimsPrincipal>())).Returns(userId);

            var sut = new TaskApiController(mediator.Object, null, userManager.Object);

            sut.SetFakeUser(userId);

            await sut.UnregisterTask(taskId);

            mediator.Verify(x => x.SendAsync(It.Is <TaskUnenrollCommand>(y => y.TaskId == taskId && y.UserId == userId)));
        }