public void Publishing_Should_Fail_If_Upload_Fails() { var campaign = Campaigns.FirstOrDefault(); campaign.Screens = new List <Screen> { new Screen() }; // Setup the mock data store to return our campaign DataStoreMockObject.Setup(x => x.GetCampaign(It.IsAny <int>())).Returns(campaign); PublishingService = new PublishingService(DataStoreMock, new UploadServiceFactory()); PublishingService.PublishPosterToScreen(new PublishPosterRequest()).Success.ShouldBeFalse(); }
public void Publishing_Should_Throw_Exception_On_Unknown_Publish_Type() { var campaign = Campaigns.FirstOrDefault(); campaign.Screens = new List <Screen> { new Screen { PublishType = PublishTypes.Unknown } }; // Setup the mock data store to return our campaign DataStoreMockObject.Setup(x => x.GetCampaign(It.IsAny <int>())).Returns(campaign); PublishingService = new PublishingService(DataStoreMock, new UploadServiceFactory()); Assert.Throws <ArgumentOutOfRangeException>(() => PublishingService.PublishPosterToScreen(new PublishPosterRequest())); }
public void Publishing_Should_Fail_For_Campaign_With_No_Matching_Screens() { var campaign = Campaigns.FirstOrDefault(); campaign.Screens = new List <Screen> { new Screen() { Id = 1 } }; // Setup the mock data store to return our campaign DataStoreMockObject.Setup(x => x.GetCampaign(It.IsAny <int>())).Returns(campaign); SetupService(); PublishingService.PublishPosterToScreen(new PublishPosterRequest()).Success.ShouldBeFalse(); }
public void Campaign_Should_Not_Be_Updated_If_Upload_Fails() { var campaign = Campaigns.FirstOrDefault(); campaign.Screens = new List <Screen> { new Screen() }; var defaultLastPublishDateTime = campaign.Screens.FirstOrDefault().LastPublishDateTime; // Setup the mock data store to return our campaign DataStoreMockObject.Setup(x => x.GetCampaign(It.IsAny <int>())).Returns(campaign); var service = new PublishingService(DataStoreMock, new UploadServiceFactory()); var lastPublishDateTime = campaign.Screens.FirstOrDefault().LastPublishDateTime; // Success should be false service.PublishPosterToScreen(new PublishPosterRequest()).Success.ShouldBeFalse(); // The last publish date/time should be the default lastPublishDateTime.ShouldEqual(defaultLastPublishDateTime); // The UpdateCampaign method should have never been called DataStoreMockObject.Verify(x => x.UpdateCampaign(new Campaign()), Times.Never()); }