public async Task EventGridServiceSendEventAsyncReturnsSuccess() { // arrange var contentPageModel = BuildValidContentPageModel(); var eventGridService = new EventGridService(fakeLogger, fakeEventGridClientService, eventGridPublishClientOptions); // act await eventGridService.SendEventAsync(WebhookCacheOperation.CreateOrUpdate, contentPageModel).ConfigureAwait(false); // assert A.CallTo(() => fakeEventGridClientService.SendEventAsync(A <List <EventGridEvent> > .Ignored, A <string> .Ignored, A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); }
public async Task EventGridServiceSendEventAsyncRaisesExceptionWhenInvalidEventGridPublishClientOptions() { // arrange var contentPageModel = BuildValidContentPageModel(); var eventGridService = new EventGridService(fakeLogger, fakeEventGridClientService, eventGridPublishClientOptions); eventGridPublishClientOptions.TopicEndpoint = string.Empty; // act await eventGridService.SendEventAsync(WebhookCacheOperation.CreateOrUpdate, contentPageModel).ConfigureAwait(false); // assert A.CallTo(() => fakeEventGridClientService.SendEventAsync(A <List <EventGridEvent> > .Ignored, A <string> .Ignored, A <string> .Ignored, A <string> .Ignored)).MustNotHaveHappened(); }
public async Task EventGridServiceSendEventAsyncRaisesExceptionWhenNullContentPageModel() { // arrange ContentPageModel?contentPageModel = null; var eventGridService = new EventGridService(fakeLogger, fakeEventGridClientService, eventGridPublishClientOptions); // act var exceptionResult = await Assert.ThrowsAsync <ArgumentNullException>(async() => await eventGridService.SendEventAsync(WebhookCacheOperation.CreateOrUpdate, contentPageModel).ConfigureAwait(false)).ConfigureAwait(false); // assert A.CallTo(() => fakeEventGridClientService.SendEventAsync(A <List <EventGridEvent> > .Ignored, A <string> .Ignored, A <string> .Ignored, A <string> .Ignored)).MustNotHaveHappened(); Assert.Equal("Value cannot be null. (Parameter 'updatedContentPageModel')", exceptionResult.Message); }