Exemplo n.º 1
0
        public async Task Result_ShouldBe_Success_IfTaskIsNotClosed()
        {
            var mockMediator = new Mock<IMediator>();
            var message = new TaskSignupCommandAsync { TaskSignupModel = new EventSignupViewModel { TaskId = 2, EventId = 1, UserId = "abc" } };

            var sut = new TaskSignupHandlerAsync(mockMediator.Object, Context);
            var result = await sut.Handle(message);

            Assert.Equal(TaskSignupResult.SUCCESS, result.Status);
            Assert.Equal(1, Context.TaskSignups.Count());
        }
Exemplo n.º 2
0
        public async Task Result_ShouldBe_TaskNotFound_IfTaskIdDoesNotExist()
        {
            var mockMediator = new Mock<IMediator>();
            var message = new TaskSignupCommandAsync { TaskSignupModel = new EventSignupViewModel { TaskId = 100, EventId = 1, UserId = "abc" } };

            var sut = new TaskSignupHandlerAsync(mockMediator.Object, Context);
            var result = await sut.Handle(message);

            Assert.Equal(TaskSignupResult.FAILURE_TASKNOTFOUND, result.Status);
            Assert.Equal(0, Context.TaskSignups.Count());
        }
Exemplo n.º 3
0
        public async Task Result_ShouldBe_ClosedTaskFailure_IfTaskIsClosed()
        {
            var mockMediator = new Mock<IMediator>();
            var message = new TaskSignupCommandAsync { TaskSignupModel = new EventSignupViewModel { TaskId = 1, EventId = 1, UserId = "abc" } };

            var sut = new TaskSignupHandlerAsync(mockMediator.Object, Context);
            var result = await sut.Handle(message);

            Assert.Equal(TaskSignupResult.FAILURE_CLOSEDTASK, result.Status);
            Assert.Equal(0, Context.TaskSignups.Count());
        }
Exemplo n.º 4
0
        public async Task Result_ShouldBe_Success_IfTaskIsNotClosed()
        {
            var mockMediator = new Mock <IMediator>();
            var message      = new TaskSignupCommandAsync {
                TaskSignupModel = new EventSignupViewModel {
                    TaskId = 2, EventId = 1, UserId = "abc"
                }
            };

            var sut    = new TaskSignupHandlerAsync(mockMediator.Object, Context);
            var result = await sut.Handle(message);

            Assert.Equal(TaskSignupResult.SUCCESS, result.Status);
            Assert.Equal(1, Context.TaskSignups.Count());
        }
Exemplo n.º 5
0
        public async Task Result_ShouldBe_TaskNotFound_IfTaskIdDoesNotExist()
        {
            var mockMediator = new Mock <IMediator>();
            var message      = new TaskSignupCommandAsync {
                TaskSignupModel = new EventSignupViewModel {
                    TaskId = 100, EventId = 1, UserId = "abc"
                }
            };

            var sut    = new TaskSignupHandlerAsync(mockMediator.Object, Context);
            var result = await sut.Handle(message);

            Assert.Equal(TaskSignupResult.FAILURE_TASKNOTFOUND, result.Status);
            Assert.Equal(0, Context.TaskSignups.Count());
        }
Exemplo n.º 6
0
        public async Task Result_ShouldBe_ClosedTaskFailure_IfTaskIsClosed()
        {
            var mockMediator = new Mock <IMediator>();
            var message      = new TaskSignupCommandAsync {
                TaskSignupModel = new EventSignupViewModel {
                    TaskId = 1, EventId = 1, UserId = "abc"
                }
            };

            var sut    = new TaskSignupHandlerAsync(mockMediator.Object, Context);
            var result = await sut.Handle(message);

            Assert.Equal(TaskSignupResult.FAILURE_CLOSEDTASK, result.Status);
            Assert.Equal(0, Context.TaskSignups.Count());
        }