Esempio n. 1
0
        public void TestActionServiceInOutMappingOk(int num, bool hasErrors)
        {
            //SETUP
            var utData = NonDiBizSetup.SetupDtoMapping <ServiceLayerBizInDto>(_noCachingConfig);

            utData.AddDtoMapping <ServiceLayerBizOutDto>();
            var bizInstance = new BizActionInOut();
            var runner      = new ActionServiceInOut <IBizActionInOut, BizDataIn, BizDataOut>(false, utData.WrappedConfig);
            var inDto       = new ServiceLayerBizInDto {
                Num = num
            };

            //ATTEMPT
            var data = runner.RunBizActionDbAndInstance <ServiceLayerBizOutDto>(_dbContext, bizInstance, inDto);

            //VERIFY
            bizInstance.HasErrors.ShouldEqual(hasErrors);
            if (hasErrors)
            {
                data.ShouldBeNull();
            }
            else
            {
                data.Output.ShouldEqual(inDto.Num.ToString());
            }
        }
Esempio n. 2
0
        public void TestValidation(int num, bool hasErrors, bool doNotValidateSaveChanges)
        {
            //SETUP
            var config = new GenericBizRunnerConfig {
                TurnOffCaching = true, DoNotValidateSaveChanges = doNotValidateSaveChanges
            };
            var options = SqliteInMemory.CreateOptions <TestDbContext>();

            using (var context = new TestDbContext(options))
            {
                context.Database.EnsureCreated();
                var mapper      = SetupHelpers.CreateMapper <ServiceLayerBizInDto, ServiceLayerBizOutDto>();
                var bizInstance = new BizActionInOutWriteDb(context);
                var runner      = new ActionServiceInOut <IBizActionInOutWriteDb, BizDataIn, BizDataOut>(true, config);
                var inDto       = new ServiceLayerBizInDto {
                    Num = num
                };

                //ATTEMPT
                var data = runner.RunBizActionDbAndInstance <ServiceLayerBizOutDto>(context, bizInstance, mapper, inDto);

                //VERIFY
                bizInstance.HasErrors.ShouldEqual(hasErrors);
                if (hasErrors)
                {
                    context.LogEntries.Any().ShouldBeFalse();
                }
                else
                {
                    context.LogEntries.Single().LogText.ShouldEqual(num.ToString());
                }
            }
        }
Esempio n. 3
0
        public void TestActionServiceInOutValuesOk(int input, bool hasErrors)
        {
            //SETUP
            var mapper      = SetupHelpers.CreateMapper <ServiceLayerBizInDto>(); //doesn't need a mapper, but mapper msutn't be null
            var bizInstance = new BizActionValueInOut();
            var runner      = new ActionServiceInOut <IBizActionValueInOut, int, string>(false, _noCachingConfig);

            //ATTEMPT
            var data = runner.RunBizActionDbAndInstance <string>(_dbContext, bizInstance, mapper, input);

            //VERIFY
            bizInstance.HasErrors.ShouldEqual(hasErrors);
            if (hasErrors)
            {
                data.ShouldBeNull();
            }
            else
            {
                data.ShouldEqual(input.ToString());
            }
        }
Esempio n. 4
0
        public void TestActionServiceInOutValuesOk(int input, bool hasErrors)
        {
            //SETUP
            var utData      = NonDiBizSetup.SetupDtoMapping <ServiceLayerBizInDto>(_noCachingConfig);
            var bizInstance = new BizActionValueInOut();
            var runner      = new ActionServiceInOut <IBizActionValueInOut, int, string>(false, utData.WrappedConfig);

            //ATTEMPT
            var data = runner.RunBizActionDbAndInstance <string>(_dbContext, bizInstance, input);

            //VERIFY
            bizInstance.HasErrors.ShouldEqual(hasErrors);
            if (hasErrors)
            {
                data.ShouldBeNull();
            }
            else
            {
                data.ShouldEqual(input.ToString());
            }
        }