public void TestActionServiceDtosDatabaseValidationOk(int num, bool hasErrors) { //SETUP var options = SqliteInMemory.CreateOptions <TestDbContext>(); using (var context = new TestDbContext(options)) { context.Database.EnsureCreated(); var bizInstance = new BizActionInOnlyWriteDb(context); var runner = new ActionService <IBizActionInOnlyWriteDb>(context, bizInstance, _wrappedConfig); var input = new ServiceLayerBizInDto { Num = num }; //ATTEMPT runner.RunBizAction(input); //VERIFY bizInstance.HasErrors.ShouldEqual(hasErrors); if (hasErrors) { context.LogEntries.Any().ShouldBeFalse(); input.SetupSecondaryDataCalled.ShouldBeTrue(); } else { context.LogEntries.Single().LogText.ShouldEqual(num.ToString()); } } }
public void TestActionServiceInOnlyMappingDatabaseOk(int num, bool hasErrors) { //SETUP var options = SqliteInMemory.CreateOptions <TestDbContext>(); using (var context = new TestDbContext(options)) { context.Database.EnsureCreated(); var mapper = SetupHelpers.CreateMapper <ServiceLayerBizInDto, ServiceLayerBizOutDto>(); var bizInstance = new BizActionInOnlyWriteDb(context); var runner = new ActionServiceInOnly <IBizActionInOnlyWriteDb, BizDataIn>(true, _noCachingConfig); var inDto = new ServiceLayerBizInDto { Num = num }; //ATTEMPT runner.RunBizActionDbAndInstance(context, bizInstance, mapper, inDto); //VERIFY bizInstance.HasErrors.ShouldEqual(hasErrors); if (hasErrors) { context.LogEntries.Any().ShouldBeFalse(); } else { context.LogEntries.Single().LogText.ShouldEqual(num.ToString()); } } }
public void TestNormalValidateActionsBasedOnConfig(bool doNotValidate, bool hasErrors) { //SETUP var config = new GenericBizRunnerConfig { TurnOffCaching = true, DoNotValidateSaveChanges = doNotValidate }; var options = SqliteInMemory.CreateOptions <TestDbContext>(); using (var context = new TestDbContext(options)) { context.Database.EnsureCreated(); var bizInstance = new BizActionInOnlyWriteDb(context); var runner = new ActionService <IBizActionInOnlyWriteDb>(context, bizInstance, _mapper, config); var input = new BizDataIn { Num = 1 }; //ATTEMPT runner.RunBizAction(input); //VERIFY bizInstance.HasErrors.ShouldEqual(hasErrors); if (hasErrors) { context.LogEntries.Any().ShouldBeFalse(); } else { context.LogEntries.Single().LogText.ShouldEqual("1"); } } }