예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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);
        }