public async void HRCountriesController_On_GetAll_With_Valid_PagingIn_Expect_Items_And_Code_Status200() { List <String> list = new List <String>() { "FR", "US" }; PagingParameterInModel invalidModel = new PagingParameterInModel() { PageNumber = 1, PageSize = 50 }; IHRCommonForkerUtils util = new HRCommonForkerUtilsStub() { CanOrderReturn = true }; HRCountriesControllersForker forker = new HRCountriesControllersForker(util); using (Task <(int, PagingParameterOutModel <HRCountry>)> resultService = forker.GetFromPagingAsync( invalidModel, null, new CoreCountriesServiceStub(list), 50 )) { await resultService; Assert.True(resultService.Result.Item1 == StatusCodes.Status200OK); } }
public async void HRCountriesController_On_GetAll_With_Invalid_PagingIn_Expect_Status416_RequestedRangeNotSatisfiable() { List <String> list = new List <String>() { "FR", "US" }; PagingParameterInModel invalidModel = new PagingParameterInModel() { PageNumber = 2, PageSize = 50 }; IHRCommonForkerUtils util = new HRCommonForkerUtilsStub() { CanOrderReturn = true }; HRCountriesControllersForker forker = new HRCountriesControllersForker(util); using (Task <(int, PagingParameterOutModel <HRCountry>)> resultService = forker.GetFromPagingAsync( invalidModel, null, new CoreCountriesServiceStub(list) { ThrowException = true, ExceptionToThrow = new IndexOutOfRangeException() }, 50)) { await resultService; Assert.True(resultService.Result.Item1 == StatusCodes.Status416RequestedRangeNotSatisfiable); Assert.True(resultService.Result.Item2 == null); } }
public async void HRCountriesController_On_GetAll_With_Exception_Thrown_By_Service_Expect_Status500_InternalServerError() { List <String> list = new List <String>() { "FR", "US" }; PagingParameterInModel invalidModel = new PagingParameterInModel() { PageNumber = 2, PageSize = 50 }; IHRCommonForkerUtils util = new HRCommonForkerUtilsStub() { CanOrderReturn = true }; HRCountriesControllersForker forker = new HRCountriesControllersForker(util); using (Task <(int, PagingParameterOutModel <HRCountry>)> resultService = forker.GetFromPagingAsync( invalidModel, null, new CoreCountriesServiceStub(list) { ThrowException = true }, 50 )) { await resultService; Assert.True(resultService.Result.Item1 == StatusCodes.Status500InternalServerError); Assert.True(resultService.Result.Item2 == null); } }
public async void HRCountriesOnGetFromPagingWithServiceThrowingIndexOutOfRangeExceptionExpectStatus500InternalServerError() { PagingParameterInModel model = new PagingParameterInModel(); CoreCountriesServiceStub service = new CoreCountriesServiceStub(null) { ThrowException = true, ExceptionToThrow = new IndexOutOfRangeException() }; HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub() { CanOrderReturn = true }; HRCountriesControllersForker forker = new HRCountriesControllersForker(utilStub); using (Task <(int, PagingParameterOutModel <HRCountry>)> forkerTask = forker.GetFromPagingAsync( model, null, service, 50 )) { await forkerTask; Assert.True(forkerTask.Result.Item1 == StatusCodes.Status416RequestedRangeNotSatisfiable); } }
public async void HRCountriesOnGetFromPagingWithCanOrderReturnoingFalseExpectStatus400BadRequest() { PagingParameterInModel model = new PagingParameterInModel() { PageNumber = 0, PageSize = 50 }; HRSortingParamModel sort = new HRSortingParamModel() { OrderBy = "FIELD1;ASC" }; CoreCountriesServiceStub service = new CoreCountriesServiceStub(null) { ThrowException = true, ExceptionToThrow = new IndexOutOfRangeException() }; HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub() { CanOrderReturn = false }; HRCountriesControllersForker forker = new HRCountriesControllersForker(utilStub); using (Task <(int, PagingParameterOutModel <HRCountry>)> forkerTask = forker.GetFromPagingAsync( model, sort, service, 50 )) { await forkerTask; Assert.True(forkerTask.Result.Item1 == StatusCodes.Status400BadRequest); } }
public async void HRCountriesOnGetFromPagingWithModelPageSizeGreaterThanMaxSizeExpectCodeStatus413PayloadTooLarge() { PagingParameterInModel model = new PagingParameterInModel() { PageNumber = 0, PageSize = 51 }; CoreCountriesServiceStub service = new CoreCountriesServiceStub(null) { ThrowException = true }; service.ExceptionToThrow = new IndexOutOfRangeException(); HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub() { CanOrderReturn = true }; HRCountriesControllersForker forker = new HRCountriesControllersForker(utilStub); using (Task <(int, PagingParameterOutModel <HRCountry>)> forkerTask = forker.GetFromPagingAsync( model, null, service, 50 )) { await forkerTask; Assert.True(forkerTask.Result.Item1 == StatusCodes.Status413PayloadTooLarge); } }
public async void HRCountriesOnGetFromPagingWithServiceNormalResultExpectCode200() { PagingParameterInModel model = new PagingParameterInModel() { PageNumber = 0, PageSize = 10 }; CoreCountriesServiceStub service = new CoreCountriesServiceStub(new System.Collections.Generic.List <string>() { "XX" }) { ThrowException = false }; HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub() { CanOrderReturn = true }; HRCountriesControllersForker forker = new HRCountriesControllersForker(utilStub); using (Task <(int, PagingParameterOutModel <HRCountry>)> forkerTask = forker.GetFromPagingAsync( model, null, service, 50 )) { await forkerTask; Assert.True(forkerTask.Result.Item1 == StatusCodes.Status200OK); } }
public async void HRCountriesForkerOnGetFromPagingWithNullServiceExpectStatus500InternalServerError() { PagingParameterInModel model = new PagingParameterInModel(); CoreCountriesServiceStub service = null; HRCommonForkerUtilsStub utilStub = new HRCommonForkerUtilsStub() { CanOrderReturn = true }; HRCountriesControllersForker forker = new HRCountriesControllersForker(utilStub); using (Task <(int, PagingParameterOutModel <HRCountry>)> forkerTask = forker.GetFromPagingAsync( model, null, service, 50 )) { await forkerTask; Assert.True(forkerTask.Result.Item1 == StatusCodes.Status500InternalServerError); } }