Пример #1
0
        public async Task ContentItemUpdaterFindAndUpdateAsyncThrowsExceptionFailWhenNullContentitemmodel()
        {
            // Arrange
            var dummyCmsApiHtmlModel = A.Dummy <CmsApiHtmlModel>();
            ContentItemModel?nullContentItemModel = null;
            var url     = new Uri("https://www.somewhere.com", UriKind.Absolute);
            var service = new MarkupContentItemUpdater <CmsApiHtmlModel>(fakeCmsApiService);

            A.CallTo(() => fakeCmsApiService.GetContentItemAsync <CmsApiHtmlModel>(A <Uri> .Ignored)).Returns(dummyCmsApiHtmlModel);

            // Act & Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() => await service.FindAndUpdateAsync(nullContentItemModel, url).ConfigureAwait(false)).ConfigureAwait(false);
        }
Пример #2
0
        public async Task ContentItemUpdaterFindAndUpdateAsyncReturnsFailWhenNoApiResponse()
        {
            // Arrange
            const bool      expectedResult        = false;
            CmsApiHtmlModel?nullCmsApiHtmlModel   = null;
            var             dummyContentItemModel = A.Dummy <ContentItemModel>();
            var             url     = new Uri("https://www.somewhere.com", UriKind.Absolute);
            var             service = new MarkupContentItemUpdater <CmsApiHtmlModel>(fakeCmsApiService);

            A.CallTo(() => fakeCmsApiService.GetContentItemAsync <CmsApiHtmlModel>(A <Uri> .Ignored)).Returns(nullCmsApiHtmlModel);

            // Act
            var result = await service.FindAndUpdateAsync(dummyContentItemModel, url).ConfigureAwait(false);

            // Assert
            A.CallTo(() => fakeCmsApiService.GetContentItemAsync <CmsApiHtmlModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly();

            Assert.Equal(expectedResult, result !);
        }
Пример #3
0
        public async Task ContentItemUpdaterFindAndUpdateAsyncForFormReturnsSuccess()
        {
            // Arrange
            const bool expectedResult       = true;
            var        dummyCmsApiFormModel = A.Dummy <CmsApiFormModel>();
            var        contentItemModel     = new ContentItemModel {
                ContentType = Constants.ContentTypeForm
            };
            var url     = new Uri("https://www.somewhere.com", UriKind.Absolute);
            var service = new MarkupContentItemUpdater <CmsApiFormModel>(fakeCmsApiService);

            A.CallTo(() => fakeCmsApiService.GetContentItemAsync <CmsApiFormModel>(A <Uri> .Ignored)).Returns(dummyCmsApiFormModel);

            // Act
            var result = await service.FindAndUpdateAsync(contentItemModel, url).ConfigureAwait(false);

            // Assert
            A.CallTo(() => fakeCmsApiService.GetContentItemAsync <CmsApiFormModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly();

            Assert.Equal(expectedResult, result !);
        }