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); } }
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 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); } }
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 HRBorderControllerOnGetByIDWithExistingItemExpectItemAndCodeStatus200() { List <String> list = new List <String>() { ("XX"), ("YY") }; CoreBordersServiceStub service = new CoreBordersServiceStub(list); HRBordersController ctrl = new HRBordersController(null, service); Task <(int, HRBorder)> resultService = ctrl.GetFromID("XX"); await resultService; Assert.True(resultService.Result.Item1 == StatusCodes.Status200OK); Assert.True(resultService.Result.Item2 != null && resultService.Result.Item2.FIPS == "XX"); }
public void HRCommonForkerOnCanOrderWithInvalidOrderByExpectFalse() { HRSortingParamModel model = new HRSortingParamModel() { OrderBy = "FIELD1" }; CoreBordersServiceStub service = new CoreBordersServiceStub(null) { ThrowException = false, IsSortable = true }; HRCommonForkerUtils util = new HRCommonForkerUtils(); Assert.False(util.CanOrder(model, service)); }
public async void HRBorderControllerOnGetByIDWithExceptionThrownByServiceExpectStatus500InternalServerError() { List <String> list = new List <String>() { ("XX") }; CoreBordersServiceStub service = new CoreBordersServiceStub(list) { ThrowException = true }; HRBordersController ctrl = new HRBordersController(null, service); Task <(int, HRBorder)> resultService = ctrl.GetFromID("XX"); await resultService; Assert.True(resultService.Result.Item1 == StatusCodes.Status500InternalServerError); Assert.True(resultService.Result.Item2 == null); }
public void HRCommonForkerOnCanOrderWithNullOrEmptyOrderByExpectTrue() { HRSortingParamModel model = new HRSortingParamModel() { OrderBy = null }; CoreBordersServiceStub service = new CoreBordersServiceStub(null) { ThrowException = false, IsSortable = true }; HRCommonForkerUtils util = new HRCommonForkerUtils(); Assert.True(util.CanOrder(model, service)); model.OrderBy = String.Empty; Assert.True(util.CanOrder(model, service)); }
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); HRBordersController ctrl = new HRBordersController(null, service); PagingParameterInModel validModel = new PagingParameterInModel() { PageNumber = 1, PageSize = 100 }; Task <(int, PagingParameterOutModel <HRBorder>)> resultService = ctrl.GetFromPaging(validModel, null); await resultService; Assert.True(resultService.Result.Item1 == StatusCodes.Status200OK); Assert.True(resultService.Result.Item2 != null); }
public async void HRBorderControllerOnGetAllWithExceptionThrownByServiceExpectStatus500InternalServerError() { List <String> list = new List <String>() { ("XX"), ("YY") }; CoreBordersServiceStub service = new CoreBordersServiceStub(list) { ThrowException = true }; HRBordersController ctrl = new HRBordersController(null, service); PagingParameterInModel validModel = new PagingParameterInModel() { PageNumber = 0, PageSize = 50 }; Task <(int, PagingParameterOutModel <HRBorder>)> resultService = ctrl.GetFromPaging(validModel, null); await resultService; Assert.True(resultService.Result.Item1 == StatusCodes.Status500InternalServerError); Assert.True(resultService.Result.Item2 == null); }
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); } }