public async Task TestGetDtoDirectOk()
        {
            //SETUP
            var service = new ActionServiceAsync <IBizActionInOutAsync>(_emptyDbContext, new BizActionInOutAsync(), _mapper, _noCachingConfig);

            //ATTEMPT
            var data = await service.GetDtoAsync <BizDataIn>();

            //VERIFY
            data.ShouldNotBeNull();
            data.ShouldBeType <BizDataIn>();
        }
        public async Task TestGetDtoGenericActionsDtoOk()
        {
            //SETUP
            var service = new ActionServiceAsync <IBizActionInOutAsync>(_emptyDbContext, new BizActionInOutAsync(), _mapper, _noCachingConfig);

            //ATTEMPT
            var data = await service.GetDtoAsync <ServiceLayerBizInDto>();

            //VERIFY
            data.ShouldNotBeNull();
            data.ShouldBeType <ServiceLayerBizInDto>();
            data.SetupSecondaryDataCalled.ShouldEqual(true);
        }
        public async Task TestActionServiceErrorInSetupOk()
        {
            //SETUP
            var bizInstance = new BizActionInOnlyAsync();
            var runner      = new ActionServiceAsync <IBizActionInOnlyAsync>(_emptyDbContext, bizInstance, _wrappedConfig);
            var input       = await runner.GetDtoAsync <ServiceLayerBizInDto>(x => { x.RaiseErrorInSetupSecondaryData = true; });

            //ATTEMPT
            await runner.RunBizActionAsync(input);

            //VERIFY
            bizInstance.HasErrors.ShouldEqual(true);
            bizInstance.Errors.Single().ErrorResult.ErrorMessage.ShouldEqual("Error in SetupSecondaryData");
        }
Ejemplo n.º 4
0
        public async Task TestGetDtoGenericActionsDtoAsyncOkAithAction()
        {
            //SETUP
            var service = new ActionServiceAsync <IBizActionInOutAsync>(_emptyDbContext, new BizActionInOutAsync(), _wrappedConfig);

            //ATTEMPT
            var data = await service.GetDtoAsync <ServiceLayerBizInDtoAsync>(x => { x.Num = 2; });

            //VERIFY
            data.ShouldNotBeNull();
            data.ShouldBeType <ServiceLayerBizInDtoAsync>();
            data.SetupSecondaryDataCalled.ShouldEqual(true);
            data.Num.ShouldEqual(2);
        }
        public async Task TestGetDtoGenericActionsDtoOutOnlyBad()
        {
            //SETUP
            var service = new ActionServiceAsync <IBizActionOutOnly>(_emptyDbContext, new BizActionOutOnly(), _mapper, _noCachingConfig);

            //ATTEMPT
            var ex = await Assert.ThrowsAsync <InvalidOperationException>(async() => await service.GetDtoAsync <ServiceLayerBizInDto>());

            //VERIFY
            ex.Message.ShouldEqual("The action with interface of IBizActionOutOnly does not have an input, but you called it with a method that needs an input.");
        }
        public async Task TestGetDtoGenericActionsDtoBad()
        {
            //SETUP
            var service = new ActionServiceAsync <IBizActionInOutAsync>(_emptyDbContext, new BizActionInOutAsync(), _mapper, _noCachingConfig);

            //ATTEMPT
            var ex = await Assert.ThrowsAsync <InvalidOperationException>(async() => await service.GetDtoAsync <ServiceLayerBizOutDto>());

            //VERIFY
            ex.Message.ShouldEqual("Indirect copy to biz action. from type = ServiceLayerBizOutDto, to type BizDataIn. Expected a DTO of type GenericActionToBizDto<BizDataIn,ServiceLayerBizOutDto>");
        }