public async void HRBorderControllerOnGetByIDWithNullServiceExpectStatus500InternalServerError() { HRBordersController ctrl = new HRBordersController(null, null); Task <(int, HRBorder)> resultService = ctrl.GetFromID("XX"); 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>(); HRBordersController ctrl = new HRBordersController(null, new CoreBordersServiceStub(list)); Task <(int, HRBorder)> resultService = ctrl.GetFromID(null); 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") }; 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 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 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); }