public void TryValidateModelReturnsArgumentNullException() { //Arrange var service = new StaticContentReloadService(fakeLogger, fakeMapper, fakeStaticContentDocumentService, fakeCmsApiService, fakeCmsApiClientOptions); StaticContentItemModel model = null; // Act & Assert Assert.Throws <ArgumentNullException>(() => service.TryValidateModel(model)); }
public void TryValidateModelReturnsArgumentNullException() { //Arrange var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService); StaticContentItemModel model = null; // Act & Assert Assert.Throws <ArgumentNullException>(() => service.TryValidateModel(model)); }
public void TryValidateModelForValidAndInvalid(StaticContentItemModel model, bool expectedResult) { //Arrange var service = new StaticContentReloadService(fakeLogger, fakeMapper, fakeStaticContentDocumentService, fakeCmsApiService, fakeCmsApiClientOptions); //Act var result = service.TryValidateModel(model); //Assert Assert.Equal(expectedResult, result); }
public void TryValidateModelForValidAndInvalid(StaticContentItemModel model, bool expectedResult) { //Arrange var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService); //Act var result = service.TryValidateModel(model); //Assert Assert.Equal(expectedResult, result); }
public async Task ProcessContentItemAsyncReturnsNoContent() { //Arrange const HttpStatusCode expectedResult = HttpStatusCode.NoContent; var service = new WebhooksService(fakeLogger, fakeMapper, fakeCmsApiService, fakeConfigurationSetDocumentService); var dummyStaticContentItemApiDataModel = A.Dummy <StaticContentItemApiDataModel>(); StaticContentItemModel nullStaticContentItemModel = null; A.CallTo(() => fakeCmsApiService.GetItemAsync <StaticContentItemApiDataModel>(A <Uri> .Ignored)).Returns(dummyStaticContentItemApiDataModel); A.CallTo(() => fakeMapper.Map <StaticContentItemModel>(A <StaticContentItemApiDataModel> .Ignored)).Returns(nullStaticContentItemModel); //Act var result = await service.ProcessContentItemAsync(new Uri("https://somewhere.com", UriKind.Absolute)).ConfigureAwait(false); //Assert A.CallTo(() => fakeCmsApiService.GetItemAsync <StaticContentItemApiDataModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => fakeMapper.Map <StaticContentItemModel>(A <StaticContentItemApiDataModel> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => fakeConfigurationSetDocumentService.UpsertAsync(A <StaticContentItemModel> .Ignored)).MustNotHaveHappened(); Assert.Equal(expectedResult, result); }