public async Task ProcessPathAsyncUpsertIsSuccessful()
        {
            // Arrange
            const HttpStatusCode upsertResult     = HttpStatusCode.OK;
            const bool           validationResult = true;
            var validLegacyPathModel       = ModelBuilders.ValidLegacyPathModel(ModelBuilders.PathName);
            var validLegacyRegionModels    = ModelBuilders.ValidLegacyRegionModels();
            var validAppRegistrationModels = ModelBuilders.ValidAppRegistrationModels(ModelBuilders.PathName);

            A.CallTo(() => fakeLegacyRegionService.GetListAsync(A <string> .Ignored)).Returns(validLegacyRegionModels);
            A.CallTo(() => fakeDocumentService.GetAsync(A <Expression <Func <AppRegistrationModel, bool> > > .Ignored)).Returns(validAppRegistrationModels);
            A.CallTo(() => fakeModelMappingService.MapModels(A <AppRegistrationModel> .Ignored, A <LegacyPathModel> .Ignored, A <List <LegacyRegionModel> > .Ignored));
            A.CallTo(() => fakeModelValidationService.ValidateModel(A <AppRegistrationModel> .Ignored)).Returns(validationResult);
            A.CallTo(() => fakeDocumentService.UpsertAsync(A <AppRegistrationModel> .Ignored)).Returns(upsertResult);

            // Act
            await legacyDataLoadService.ProcessPathAsync(validLegacyPathModel).ConfigureAwait(false);

            // Assert
            A.CallTo(() => fakeLegacyRegionService.GetListAsync(A <string> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeDocumentService.GetAsync(A <Expression <Func <AppRegistrationModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeModelMappingService.MapModels(A <AppRegistrationModel> .Ignored, A <LegacyPathModel> .Ignored, A <List <LegacyRegionModel> > .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeModelValidationService.ValidateModel(A <AppRegistrationModel> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeDocumentService.UpsertAsync(A <AppRegistrationModel> .Ignored)).MustHaveHappenedOnceExactly();
        }
示例#2
0
        public void MapModelsReturnsExceptionForNullLegacyPathModel()
        {
            // Arrange
            var             appRegistrationModel = ModelBuilders.ValidAppRegistrationModel(ModelBuilders.PathName);
            LegacyPathModel?legacyPathModel      = null;
            var             legacyRegionModels   = ModelBuilders.ValidLegacyRegionModels();

            // Act
            var exceptionResult = Assert.Throws <ArgumentNullException>(() => modelMappingService.MapModels(appRegistrationModel, legacyPathModel, legacyRegionModels));

            // assert
            A.CallTo(() => fakeMapper.Map(legacyPathModel, appRegistrationModel)).MustNotHaveHappened();
            A.CallTo(() => fakeMapper.Map <List <RegionModel> >(legacyRegionModels)).MustNotHaveHappened();

            Assert.Equal("Value cannot be null. (Parameter 'legacyPathModel')", exceptionResult.Message);
        }
示例#3
0
        public void MapModelsReturnsSuccessForValidDataModelsWithLegacyRegions()
        {
            // Arrange
            var appRegistrationModel = ModelBuilders.ValidAppRegistrationModel(ModelBuilders.PathName);
            var legacyPathModel      = ModelBuilders.ValidLegacyPathModel(ModelBuilders.PathName);
            var legacyRegionModels   = ModelBuilders.ValidLegacyRegionModels();
            var validRegionModels    = ModelBuilders.ValidRegionModels();

            A.CallTo(() => fakeMapper.Map(legacyPathModel, appRegistrationModel));
            A.CallTo(() => fakeMapper.Map <List <RegionModel> >(legacyRegionModels)).Returns(validRegionModels);

            // Act
            modelMappingService.MapModels(appRegistrationModel, legacyPathModel, legacyRegionModels);

            // assert
            A.CallTo(() => fakeMapper.Map(legacyPathModel, appRegistrationModel)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeMapper.Map <List <RegionModel> >(legacyRegionModels)).MustHaveHappenedOnceExactly();

            Assert.NotNull(appRegistrationModel.Regions);
        }