Esempio n. 1
0
        public async Task TestActionServiceAsyncInOutAsyncDtosOk(int num, bool hasErrors)
        {
            //SETUP
            var mapper      = SetupHelpers.CreateMapper <ServiceLayerBizInDtoAsync, ServiceLayerBizOutDtoAsync>();
            var bizInstance = new BizActionInOutAsync();
            var runner      = new ActionServiceAsync <IBizActionInOutAsync>(_emptyDbContext, bizInstance, mapper, _noCachingConfig);
            var input       = new ServiceLayerBizInDtoAsync {
                Num = num
            };

            //ATTEMPT
            var data = await runner.RunBizActionAsync <ServiceLayerBizOutDtoAsync>(input);

            //VERIFY
            bizInstance.HasErrors.ShouldEqual(hasErrors);
            if (hasErrors)
            {
                data.ShouldBeNull();
                bizInstance.Message.ShouldEqual("Failed with 1 error");
            }
            else
            {
                data.Output.ShouldEqual(num.ToString());
            }
        }
        public void TestResetDtoGenericActionsAsyncDtoBad()
        {
            //SETUP
            var service = new ActionService <IBizActionInOut>(_emptyDbContext, new BizActionInOut(), _mapper, _noCachingConfig);
            var data    = new ServiceLayerBizInDtoAsync();

            //ATTEMPT
            var ex = Assert.Throws <InvalidOperationException>(() => service.ResetDto(data));

            //VERIFY
            ex.Message.ShouldEqual("You cannot use an Async version of the DTO in a non-async action.");
        }
        public void TestUseAsyncBizInWithSyncBad()
        {
            //SETUP
            var bizInstance = new BizActionValueInOut();
            var runner      = new ActionService <IBizActionValueInOut>(_emptyDbContext, bizInstance, _wrappedConfig);
            var input       = new ServiceLayerBizInDtoAsync();

            //ATTEMPT
            var ex = Assert.Throws <InvalidOperationException>(() => runner.RunBizAction <string>(input));

            //VERIFY
            ex.Message.ShouldEqual("You cannot use an Async version of the DTO in a non-async action.");
        }
        public async Task TestBizInCopyAsyncServiceInstanceOk()
        {
            //SETUP
            var utData = NonDiBizSetup.SetupDtoMapping <ServiceLayerBizInDtoAsync>();
            var copier = new CopyToBizDataAsync <BizDataIn, ServiceLayerBizInDtoAsync>();
            var input  = new ServiceLayerBizInDtoAsync {
                Num = 234
            };

            //ATTEMPT
            var data = await copier.CopyToBizAsync(null, utData.WrappedConfig.ToBizIMapper, input);

            //VERIFY
            data.Num.ShouldEqual(234);
        }
        public async Task TestSetupSecondaryDataAsyncDtoOk()
        {
            //SETUP
            var copier = DtoAccessGenerator.BuildCopier(typeof(ServiceLayerBizInDtoAsync), typeof(BizDataIn), true, true, true);
            var input  = new ServiceLayerBizInDtoAsync {
                Num = 234
            };
            var status = new TestBizActionStatus();

            //ATTEMPT
            await copier.SetupSecondaryDataIfRequiredAsync(null, status, input);

            //VERIFY
            input.SetupSecondaryDataCalled.ShouldBeTrue();
        }
        public async Task TestBizInCopyAsyncAsyncDtoOk()
        {
            //SETUP
            var utData = NonDiBizSetup.SetupDtoMapping <ServiceLayerBizInDtoAsync>();
            var copier = DtoAccessGenerator.BuildCopier(typeof(ServiceLayerBizInDtoAsync), typeof(BizDataIn), true, true, true);
            var input  = new ServiceLayerBizInDtoAsync {
                Num = 234
            };

            //ATTEMPT
            var data = await copier.DoCopyToBizAsync <BizDataIn>(null, utData.WrappedConfig.ToBizIMapper, input);

            //VERIFY
            data.Num.ShouldEqual(234);
        }
Esempio n. 7
0
        public async Task TestBizInCopyAsyncServiceInstanceOk()
        {
            //SETUP
            var mapper = SetupHelpers.CreateMapper <ServiceLayerBizInDtoAsync>();
            var copier = new CopyToBizDataAsync <BizDataIn, ServiceLayerBizInDtoAsync>();
            var input  = new ServiceLayerBizInDtoAsync {
                Num = 234
            };

            //ATTEMPT
            var data = await copier.CopyToBizAsync(null, mapper, input);

            //VERIFY
            data.Num.ShouldEqual(234);
        }
Esempio n. 8
0
        public async Task TestBizInCopyAsyncAsyncDtoOk()
        {
            //SETUP
            var mapper = SetupHelpers.CreateMapper <ServiceLayerBizInDtoAsync>();
            var copier = DtoAccessGenerator.BuildCopier(typeof(ServiceLayerBizInDtoAsync), typeof(BizDataIn), true, true, _noCachingConfig);
            var input  = new ServiceLayerBizInDtoAsync {
                Num = 234
            };

            //ATTEMPT
            var data = await copier.DoCopyToBizAsync <BizDataIn>(null, mapper, input);

            //VERIFY
            data.Num.ShouldEqual(234);
        }
        public async Task TestResetDtoAsyncOk()
        {
            //SETUP
            var service = new ActionServiceAsync <IBizActionInOutAsync>(_emptyDbContext, new BizActionInOutAsync(), _mapper, _noCachingConfig);
            var data    = new ServiceLayerBizInDtoAsync {
                Num = 123
            };

            //ATTEMPT
            await service.ResetDtoAsync(data);

            //VERIFY
            data.ShouldNotBeNull();
            data.Num.ShouldEqual(123);
            data.SetupSecondaryDataCalled.ShouldBeTrue();
        }
        public async Task TestActionServiceInOutDtosAsyncOk(int num, bool hasErrors)
        {
            //SETUP
            var bizInstance = new BizActionInOnlyAsync();
            var runner      = new ActionServiceAsync <IBizActionInOnlyAsync>(_emptyDbContext, bizInstance, _wrappedConfig);
            var input       = new ServiceLayerBizInDtoAsync {
                Num = num
            };

            //ATTEMPT
            await runner.RunBizActionAsync(input);

            //VERIFY
            bizInstance.HasErrors.ShouldEqual(hasErrors);
            if (hasErrors)
            {
                bizInstance.Message.ShouldEqual("Failed with 1 error");
            }
            else
            {
                bizInstance.Message.ShouldEqual("All Ok");
            }
        }