Ejemplo n.º 1
0
        public async Task WebhooksServiceProcessMessageAsyncContentUpdateConfigurationSetReturnsSuccess()
        {
            // Arrange
            const HttpStatusCode expectedResponse         = HttpStatusCode.OK;
            var expectedValidConfigurationSetApiDataModel = BuildValidConfigurationSetApiDataModel();
            var expectedValidConfigurationSetModel        = BuildValidConfigurationSetModel();
            var url     = "https://somewhere.com";
            var service = BuildWebhooksService();

            A.CallTo(() => FakeCmsApiService.GetItemAsync <ConfigurationSetApiDataModel>(A <Uri> .Ignored)).Returns(expectedValidConfigurationSetApiDataModel);
            A.CallTo(() => FakeMapper.Map <ConfigurationSetModel>(A <ConfigurationSetApiDataModel> .Ignored)).Returns(expectedValidConfigurationSetModel);
            A.CallTo(() => FakeConfigurationSetDocumentService.UpsertAsync(A <ConfigurationSetModel> .Ignored)).Returns(HttpStatusCode.OK);

            // Act
            var result = await service.ProcessMessageAsync(WebhookCacheOperation.CreateOrUpdate, Guid.NewGuid(), ContentIdForConfigurationSetUpdate, url).ConfigureAwait(false);

            // Assert
            A.CallTo(() => FakeCmsApiService.GetItemAsync <EmailApiDataModel>(A <Uri> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeCmsApiService.GetItemAsync <ConfigurationSetApiDataModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => FakeMapper.Map <ConfigurationSetModel>(A <ConfigurationSetApiDataModel> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => FakeConfigurationSetDocumentService.UpsertAsync(A <ConfigurationSetModel> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => FakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened();

            Assert.Equal(expectedResponse, result);
        }
Ejemplo n.º 2
0
        public async Task WebhooksServiceProcessConfigurationSetAsyncForUpdateReturnsSuccess()
        {
            // Arrange
            const HttpStatusCode expectedResponse         = HttpStatusCode.OK;
            var expectedValidConfigurationSetApiDataModel = BuildValidConfigurationSetApiDataModel();
            var expectedValidConfigurationSetModel        = BuildValidConfigurationSetModel();
            var url     = new Uri("https://somewhere.com");
            var service = BuildWebhooksService();

            A.CallTo(() => FakeCmsApiService.GetItemAsync <ConfigurationSetApiDataModel>(A <Uri> .Ignored)).Returns(expectedValidConfigurationSetApiDataModel);
            A.CallTo(() => FakeMapper.Map <ConfigurationSetModel>(A <ConfigurationSetApiDataModel> .Ignored)).Returns(expectedValidConfigurationSetModel);
            A.CallTo(() => FakeConfigurationSetDocumentService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).Returns(expectedValidConfigurationSetModel);
            A.CallTo(() => FakeConfigurationSetDocumentService.UpsertAsync(A <ConfigurationSetModel> .Ignored)).Returns(HttpStatusCode.OK);

            // Act
            var result = await service.ProcessConfigurationSetAsync(url).ConfigureAwait(false);

            // Assert
            A.CallTo(() => FakeCmsApiService.GetItemAsync <ConfigurationSetApiDataModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => FakeMapper.Map <ConfigurationSetModel>(A <ConfigurationSetApiDataModel> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => FakeConfigurationSetDocumentService.UpsertAsync(A <ConfigurationSetModel> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => FakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened();

            Assert.Equal(expectedResponse, result);
        }
        public async Task WebhooksServiceDeleteConfigurationSetContentAsyncForCreateReturnsNoContent()
        {
            // Arrange
            const bool           expectedResponse = false;
            const HttpStatusCode expectedResult   = HttpStatusCode.NoContent;
            var service = BuildWebhooksService();

            A.CallTo(() => FakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).Returns(expectedResponse);

            // Act
            var result = await service.DeleteConfigurationSetAsync(ContentIdForConfigurationSetDelete).ConfigureAwait(false);

            // Assert
            A.CallTo(() => FakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).MustHaveHappenedOnceExactly();

            Assert.Equal(expectedResult, result);
        }
Ejemplo n.º 4
0
        public async Task WebhooksServiceProcessMessageAsyncNoneOptionReturnsSuccess()
        {
            // Arrange
            const HttpStatusCode expectedResponse = HttpStatusCode.BadRequest;
            var url     = "https://somewhere.com";
            var service = BuildWebhooksService();

            // Act
            var result = await service.ProcessMessageAsync(WebhookCacheOperation.None, Guid.NewGuid(), ContentIdForEmailCreate, url).ConfigureAwait(false);

            // Assert
            A.CallTo(() => FakeCmsApiService.GetItemAsync <EmailApiDataModel>(A <Uri> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeConfigurationSetDocumentService.UpsertAsync(A <ConfigurationSetModel> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeConfigurationSetDocumentService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened();

            Assert.Equal(expectedResponse, result);
        }