Пример #1
0
        public async Task UnregisterEventSendsEventSignupByEventIdAndUserIdQueryWithCorrectEventIdAndUserId()
        {
            const int eventId = 1;
            const string userId = "1";

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventSignupByEventIdAndUserIdQuery>()))
                .Returns(new EventSignup { Event = new Event(), User = new ApplicationUser() });

            var controller = new EventApiController(mediator.Object, null);
            controller.SetFakeUser(userId);

            await controller.UnregisterEvent(eventId);

            mediator.Verify(x => x.Send(It.Is<EventSignupByEventIdAndUserIdQuery>(y => y.EventId == eventId && y.UserId == userId)));
        }
Пример #2
0
        public async Task UnregisterEventSendsUnregisterEventWithCorrectEventSignupId()
        {
            const int eventId = 1;
            const int eventSignupId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventSignupByEventIdAndUserIdQuery>()))
                .Returns(new EventSignup { Id = eventSignupId, Event = new Event(), User = new ApplicationUser() });

            var controller = new EventApiController(mediator.Object, null);
            controller.SetDefaultHttpContext();

            await controller.UnregisterEvent(eventId);

            mediator.Verify(x => x.SendAsync(It.Is<UnregisterEvent>(y => y.EventSignupId == eventSignupId)));
        }
Пример #3
0
        public async Task UnregisterEventReturnsHttpNotFoundWhenUnableToGetEventSignupByEventSignupIdAndUserId()
        {
            var controller = new EventApiController(Mock.Of<IMediator>(), null);
            controller.SetDefaultHttpContext();

            var result = await controller.UnregisterEvent(It.IsAny<int>());
            Assert.IsType<NotFoundResult>(result);
        }