public async Task RegisterEventReturnsSuccess()
        {
            var sut = new EventApiController(Mock.Of<IMediator>(), null);
            var result = await sut.RegisterEvent(new EventSignupViewModel());

            Assert.True(result.ToString().Contains("success"));
        }
        public async Task RegisterEventReturnsCorrectJsonWhenModelStateIsNotValid()
        {
            const string modelStateErrorMessage = "modelStateErrorMessage";

            var sut = new EventApiController(null, 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);
        }
        public async Task RegisterEventSendsEventSignupCommandAsyncWithCorrectData()
        {
            var model = new EventSignupViewModel();
            var mediator = new Mock<IMediator>();

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

            mediator.Verify(x => x.SendAsync(It.Is<EventSignupCommand>(command => command.EventSignup.Equals(model))));
        }
 public async Task RegisterEventReturnsHttpBadRequetWhenSignupModelIsNull()
 {
     var sut = new EventApiController(null, null);
     var result = await sut.RegisterEvent(null);
     Assert.IsType<BadRequestResult>(result);
 }