public void SendsGetActivitiesWithUnlockedCampaignsQuery() { var mediator = new Mock<IMediator>(); var sut = new ActivityApiController(mediator.Object); sut.Get(); mediator.Verify(x => x.Send(It.IsAny<ActivitiesWithUnlockedCampaignsQuery>()), Times.Once); }
public void GetByIdReturnsCorrectViewModel() { var mediator = new Mock<IMediator>(); mediator.Setup(x => x.Send(It.IsAny<ActivityByActivityIdQuery>())).Returns(new Activity { Campaign = new Campaign { ManagingOrganization = new Organization() }}); var sut = new ActivityApiController(mediator.Object); var result = sut.Get(It.IsAny<int>()); Assert.IsType<ActivityViewModel>(result); }
public void GetReturnsCorrectModel() { var mediator = new Mock<IMediator>(); mediator.Setup(x => x.Send(It.IsAny<ActivitiesWithUnlockedCampaignsQuery>())).Returns(new List<ActivityViewModel>()); var sut = new ActivityApiController(mediator.Object); var results = sut.Get(); Assert.IsType<List<ActivityViewModel>>(results); }
public void GetByIdSendsActivityByActivityIdQueryWithCorrectData() { const int activityId = 1; var mediator = new Mock<IMediator>(); mediator.Setup(x => x.Send(It.IsAny<ActivityByActivityIdQuery>())).Returns(new Activity { Campaign = new Campaign { ManagingOrganization = new Organization() }}); var sut = new ActivityApiController(mediator.Object); sut.Get(activityId); mediator.Verify(x => x.Send(It.Is<ActivityByActivityIdQuery>(y => y.ActivityId == activityId))); }
public void GetAllActivities() { // Arrange var AllReadyContext = _serviceProvider.GetService<AllReadyContext>(); var controller = new ActivityApiController(AllReadyContext, null, null); PopulateData(AllReadyContext); // Act var result = new List<ActivityViewModel>(controller.Get().AsEnumerable()); // Assert var viewResult = Assert.IsType<List<ActivityViewModel>>(result); Assert.Equal(result.Count(), 10); }
public void GetSingleActivity() { // Arrange var AllReadyContext = _serviceProvider.GetService<AllReadyContext>(); var controller = new ActivityApiController(AllReadyContext, null, null); PopulateData(AllReadyContext); // Act var result = controller.Get(5); // Assert var viewResult = Assert.IsType<ActivityViewModel>(result); Assert.Equal(viewResult.Id, 5); Assert.Equal(viewResult.CampaignName, "Campaign 4"); Assert.Equal(viewResult.CampaignId, 4); Assert.Equal(viewResult.Description, "ActivityViewModel.cs: Needs a Description"); Assert.Equal(viewResult.EndDateTime, DateTime.MaxValue.ToUniversalTime()); Assert.Equal(viewResult.StartDateTime, DateTime.MinValue.ToUniversalTime()); }