Beispiel #1
0
        public async void HRBorderForkerOnGetFromPagingWithModelPageSizeGreaterThanMaxSizeExpectCodeStatus413PayloadTooLarge()
        {
            PagingParameterInModel model = new PagingParameterInModel()
            {
                PageNumber = 0,
                PageSize   = 51
            };
            CoreBordersServiceStub service = new CoreBordersServiceStub(null)
            {
                ThrowException = true
            };

            service.ExceptionToThrow = new IndexOutOfRangeException();
            HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(utilStub);

            using (Task <(int, PagingParameterOutModel <HRBorder>)> forkerTask = forker.GetFromPagingAsync(
                       model,
                       null,
                       service,
                       50
                       ))
            {
                await forkerTask;
                Assert.True(forkerTask.Result.Item1 == StatusCodes.Status413PayloadTooLarge);
            }
        }
Beispiel #2
0
        public async void HRBorderForkerOnGetFromPagingWithServiceThrowingIndexOutOfRangeExceptionExpectStatus416RequestedRangeNotSatisfiable()
        {
            PagingParameterInModel model   = new PagingParameterInModel();
            CoreBordersServiceStub service = new CoreBordersServiceStub(null)
            {
                ThrowException = true
            };

            service.ExceptionToThrow = new IndexOutOfRangeException();
            HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(utilStub);

            using (Task <(int, PagingParameterOutModel <HRBorder>)> forkerTask = forker.GetFromPagingAsync(
                       model,
                       null,
                       service,
                       50
                       ))
            {
                await forkerTask;
                Assert.True(forkerTask.Result.Item1 == StatusCodes.Status416RequestedRangeNotSatisfiable);
            }
        }
Beispiel #3
0
        public async void HRBorderForkerOnGetFromPagingWithCanOrderReturnoingFalseExpectStatus400BadRequest()
        {
            PagingParameterInModel model = new PagingParameterInModel()
            {
                PageNumber = 0,
                PageSize   = 50
            };
            HRSortingParamModel sort = new HRSortingParamModel()
            {
                OrderBy = "FIELD1;ASC"
            };
            CoreBordersServiceStub service = new CoreBordersServiceStub(null)
            {
                ThrowException   = true,
                ExceptionToThrow = new IndexOutOfRangeException()
            };
            HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = false
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(utilStub);

            using (Task <(int, PagingParameterOutModel <HRBorder>)> forkerTask = forker.GetFromPagingAsync(
                       model,
                       sort,
                       service,
                       50
                       ))
            {
                await forkerTask;
                Assert.True(forkerTask.Result.Item1 == StatusCodes.Status400BadRequest);
            }
        }
        public async void HRBorderControllerOnGetAllWithValidPagingInExpectItemsAndCodeStatus200()
        {
            List <String> list = new List <String>();

            for (int i = 0; i < 300; i++)
            {
                list.Add(i.ToString());
            }
            //CoreBordersServiceStub service = new CoreBordersServiceStub(list);
            PagingParameterInModel validModel = new PagingParameterInModel()
            {
                PageNumber = 1, PageSize = 50
            };
            HRCommonForkerUtilsStub forkerUtil = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(forkerUtil);

            using (Task <(int, PagingParameterOutModel <HRBorder>)> resultService = forker.GetFromPagingAsync(
                       validModel,
                       null,
                       new CoreBordersServiceStub(list),
                       50
                       ))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status200OK);
                Assert.True(resultService.Result.Item2 != null);
            }
        }
Beispiel #5
0
        public async void HRBorderForkerOnGetFromPagingWithServiceNormalResultExpectCode200()
        {
            PagingParameterInModel model = new PagingParameterInModel()
            {
                PageNumber = 0,
                PageSize   = 10
            };
            CoreBordersServiceStub service = new CoreBordersServiceStub(new System.Collections.Generic.List <string>()
            {
                "XX"
            })
            {
                ThrowException = false
            };
            HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(utilStub);

            using (Task <(int, PagingParameterOutModel <HRBorder>)> forkerTask = forker.GetFromPagingAsync(
                       model,
                       null,
                       service,
                       50
                       ))
            {
                await forkerTask;
                Assert.True(forkerTask.Result.Item1 == StatusCodes.Status200OK);
            }
        }
        public async void HRBorderControllerOnGetAllWithExceptionThrownByServiceExpectStatus500InternalServerError()
        {
            List <String> list = new List <String>()
            {
                ("XX"), ("YY")
            };
            HRCommonForkerUtilsStub forkerUtil = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(forkerUtil);

            using (Task <(int, PagingParameterOutModel <HRBorder>)> resultService = forker.GetFromPagingAsync(
                       new PagingParameterInModel()
            {
                PageNumber = 0, PageSize = 50
            },
                       null,
                       new CoreBordersServiceStub(list)
            {
                ThrowException = true
            },
                       50
                       ))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status500InternalServerError);
                Assert.True(resultService.Result.Item2 == null);
            }
        }
        public async void HRBorderControllerOnGetByIDWithNullServiceExpectStatus500InternalServerError()
        {
            HRCommonForkerUtilsStub forkerUtil = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(forkerUtil);

            using (Task <(int, HRBorder)> resultService = forker.GetFromIDAsync("XX", null))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status500InternalServerError);
                Assert.True(resultService.Result.Item2 == null);
            }
        }
        public async void HRBorderControllerOnGetByIDNullExpectStatus400BadRequest()
        {
            List <String>           list       = new List <String>();
            HRCommonForkerUtilsStub forkerUtil = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(forkerUtil);

            using (Task <(int, HRBorder)> resultService = forker.GetFromIDAsync(null, new CoreBordersServiceStub(list)))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status400BadRequest);
                Assert.True(resultService.Result.Item2 == null);
            }
        }
        public async void HRBorderControllerOnGetByIDWithExistingItemExpectItemAndCodeStatus200()
        {
            List <String> list = new List <String>()
            {
                ("XX"), ("YY")
            };
            HRCommonForkerUtilsStub forkerUtil = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(forkerUtil);

            using (Task <(int, HRBorder)> resultService = forker.GetFromIDAsync("XX", new CoreBordersServiceStub(list)))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status200OK);
                Assert.True(resultService.Result.Item2 != null && resultService.Result.Item2.FIPS == "XX");
            }
        }
Beispiel #10
0
        public async void HRBorderForkerOnGetFromPagingWithNullServiceExpectStatus500InternalServerError()
        {
            PagingParameterInModel  model    = new PagingParameterInModel();
            CoreBordersServiceStub  service  = null;
            HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(utilStub);

            using (Task <(int, PagingParameterOutModel <HRBorder>)> forkerTask = forker.GetFromPagingAsync(
                       model,
                       null,
                       service,
                       50
                       ))
            {
                await forkerTask;
                Assert.True(forkerTask.Result.Item1 == StatusCodes.Status500InternalServerError);
            }
        }
        public async void HRBorderControllerOnGetByIDWithExceptionThrownByServiceExpectStatus500InternalServerError()
        {
            List <String> list = new List <String>()
            {
                ("XX")
            };
            HRCommonForkerUtilsStub forkerUtil = new HRCommonForkerUtilsStub()
            {
                CanOrderReturn = true
            };
            HRBordersControllersForker forker = new HRBordersControllersForker(forkerUtil);

            using (Task <(int, HRBorder)> resultService = forker.GetFromIDAsync("XX", new CoreBordersServiceStub(list)
            {
                ThrowException = true
            }))
            {
                await resultService;
                Assert.True(resultService.Result.Item1 == StatusCodes.Status500InternalServerError);
                Assert.True(resultService.Result.Item2 == null);
            }
        }