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); }
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); }
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); }
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); }
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); }