예제 #1
0
        public async Task RegisterEventReturnsSuccess()
        {
            var sut    = new EventApiController(Mock.Of <IMediator>());
            var result = await sut.RegisterEvent(new EventSignupViewModel());

            Assert.True(result.ToString().Contains("success"));
        }
예제 #2
0
        public async Task RegisterEventReturnsHttpBadRequetWhenSignupModelIsNull()
        {
            var sut    = new EventApiController(null);
            var result = await sut.RegisterEvent(null);

            Assert.IsType <BadRequestResult>(result);
        }
예제 #3
0
        public async Task RegisterEventSendsEventSignupCommandAsyncWithCorrectData()
        {
            var model    = new EventSignupViewModel();
            var mediator = new Mock <IMediator>();

            var sut = new EventApiController(mediator.Object);
            await sut.RegisterEvent(model);

            mediator.Verify(x => x.SendAsync(It.Is <EventSignupCommand>(command => command.EventSignup.Equals(model))));
        }
예제 #4
0
        public async Task RegisterEventReturnsCorrectJsonWhenModelStateIsNotValid()
        {
            const string modelStateErrorMessage = "modelStateErrorMessage";

            var sut = new EventApiController(null);

            sut.AddModelStateErrorWithErrorMessage(modelStateErrorMessage);

            var jsonResult = (JsonResult)await sut.RegisterEvent(new EventSignupViewModel());

            var result = jsonResult.GetValueForProperty <List <string> >("errors");

            Assert.IsType <JsonResult>(jsonResult);
            Assert.IsType <List <string> >(result);
            Assert.Equal(result.First(), modelStateErrorMessage);
        }