예제 #1
0
        public async Task GetSendsEventsWithUnlockedCampaignsQuery()
        {
            var mediator = new Mock <IMediator>();
            var sut      = new EventApiController(mediator.Object);
            await sut.Get();

            mediator.Verify(x => x.SendAsync(It.IsAny <EventsWithUnlockedCampaignsQuery>()), Times.Once);
        }
예제 #2
0
        public void GetSendsEventsWithUnlockedCampaignsQuery()
        {
            var mediator = new Mock <IMediator>();
            var sut      = new EventApiController(mediator.Object, null);

            sut.Get();

            mediator.Verify(x => x.Send(It.IsAny <EventsWithUnlockedCampaignsQuery>()), Times.Once);
        }
예제 #3
0
        public void GetReturnsCorrectModel()
        {
            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.Send(It.IsAny <EventsWithUnlockedCampaignsQuery>())).Returns(new List <EventViewModel>());

            var sut     = new EventApiController(mediator.Object);
            var results = sut.Get();

            Assert.IsType <List <EventViewModel> >(results);
        }
예제 #4
0
        public async Task GetByIdReturnsCorrectViewModel()
        {
            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <EventByEventIdQuery>())).ReturnsAsync(new Event {
                Campaign = new Campaign {
                    ManagingOrganization = new Organization()
                }
            });
            var sut    = new EventApiController(mediator.Object);
            var result = await sut.Get(It.IsAny <int>());

            Assert.IsType <EventViewModel>(result);
        }
예제 #5
0
        public async Task GetByIdSendsEventByEventIdQueryWithCorrectData()
        {
            const int eventId = 1;

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny <EventByEventIdQuery>())).ReturnsAsync(new Event {
                Campaign = new Campaign {
                    ManagingOrganization = new Organization()
                }
            });
            var sut = new EventApiController(mediator.Object);

            await sut.Get(eventId);

            mediator.Verify(x => x.SendAsync(It.Is <EventByEventIdQuery>(y => y.EventId == eventId)), Times.Once);
        }