public void ValidateModelReturnsSuccessForValidDataModels() { // Arrange const bool expectedResult = true; var appRegistrationModel = ModelBuilders.ValidAppRegistrationModel(ModelBuilders.PathName); // Act var result = modelValidationService.ValidateModel(appRegistrationModel); // assert Assert.Equal(expectedResult, result); }
public void MapModelsPairIsSuccessful() { // Arrange var appRegistrationModel = ModelBuilders.ValidAppRegistrationModel(ModelBuilders.PathName); var legacyPathModel = ModelBuilders.ValidLegacyPathModel(ModelBuilders.PathName); // Act modelMappingService.MapModels(appRegistrationModel, legacyPathModel); // assert A.CallTo(() => fakeMapper.Map(legacyPathModel, appRegistrationModel)).MustHaveHappenedOnceExactly(); }
public void ValidateModelReturnsFailureForInvalidDataModels() { // Arrange const bool expectedResult = false; var appRegistrationModel = ModelBuilders.ValidAppRegistrationModel(ModelBuilders.PathName); appRegistrationModel.Path = null; // Act var result = modelValidationService.ValidateModel(appRegistrationModel); // assert Assert.Equal(expectedResult, result); }
public void MapModelsPairReturnsExceptionForNullLegacyPathModel() { // Arrange var appRegistrationModel = ModelBuilders.ValidAppRegistrationModel(ModelBuilders.PathName); LegacyPathModel?legacyPathModel = null; // Act var exceptionResult = Assert.Throws <ArgumentNullException>(() => modelMappingService.MapModels(appRegistrationModel, legacyPathModel)); // assert A.CallTo(() => fakeMapper.Map(legacyPathModel, appRegistrationModel)).MustNotHaveHappened(); Assert.Equal("Value cannot be null. (Parameter 'legacyPathModel')", exceptionResult.Message); }
public async Task UpdateAppRegistrationAsyncAppRegistrationxxxxxxxxxxxxxxx() { // Arrange const HttpStatusCode upsertResult = HttpStatusCode.OK; const bool validationResult = true; var validAppRegistrationModel = ModelBuilders.ValidAppRegistrationModel(ModelBuilders.PathName); A.CallTo(() => fakeModelValidationService.ValidateModel(A <AppRegistrationModel> .Ignored)).Returns(validationResult); A.CallTo(() => fakeDocumentService.UpsertAsync(A <AppRegistrationModel> .Ignored)).Returns(upsertResult); // Act await legacyDataLoadService.UpdateAppRegistrationAsync(validAppRegistrationModel).ConfigureAwait(false); // Assert A.CallTo(() => fakeModelValidationService.ValidateModel(A <AppRegistrationModel> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => fakeDocumentService.UpsertAsync(A <AppRegistrationModel> .Ignored)).MustHaveHappenedOnceExactly(); }
public void MapRegionModelToAppRegistrationNoExistingRegionsReturnsSuccessForValidDataModelsWithLegacyRegions() { // Arrange var appRegistrationModel = ModelBuilders.ValidAppRegistrationModel(ModelBuilders.PathName); var legacyRegionModel = ModelBuilders.ValidLegacyRegionModel(ModelBuilders.PathName, Enums.PageRegion.Head); var validRegionModel = ModelBuilders.ValidRegionModel(Enums.PageRegion.Head); A.CallTo(() => fakeMapper.Map <RegionModel>(legacyRegionModel)); // Act modelMappingService.MapRegionModelToAppRegistration(appRegistrationModel, legacyRegionModel); // assert A.CallTo(() => fakeMapper.Map <RegionModel>(legacyRegionModel)).MustHaveHappenedOnceExactly(); Assert.NotNull(appRegistrationModel.Regions); }
public void MapModelsReturnsSuccessForValidDataModelsWithoutLegacyRegions() { // Arrange var appRegistrationModel = ModelBuilders.ValidAppRegistrationModel(ModelBuilders.PathName); var legacyPathModel = ModelBuilders.ValidLegacyPathModel(ModelBuilders.PathName); IList <LegacyRegionModel>?legacyRegionModels = null; 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)).MustNotHaveHappened(); Assert.Null(appRegistrationModel.Regions); }