public async Task GetAllCaseworkersSuccess() { //Arrange var helperHttpClientMoq = new Mock <ICaseworkerHttpClientHelper>(); var configurationMoq = new Mock <IConfiguration>(); var pageNumber = 1; var context = GetContext(); var caseworkerData = new List <CaseworkerDataResponseModel>() { new CaseworkerDataResponseModel(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>()) }; var responseData = new CaseworkerList() { TotalNoOfPages = 1, TotalSearchCount = 1, PageNo = 1, Result = caseworkerData }; helperHttpClientMoq.Setup(x => x.GetAllCaseworkerDataFromMomentumCoreAsync("/punits/0d1345f4-51e0-407e-9dc0-15a9d08326d7/caseworkers", pageNumber)) .Returns(Task.FromResult(new ResultOrHttpError <CaseworkerList, Error>(responseData))); var caseWorkerService = new CaseworkerService(helperHttpClientMoq.Object, configurationMoq.Object, context.Object); //Act var result = await caseWorkerService.GetAllCaseworkersAsync(pageNumber).ConfigureAwait(false); //Asert result.Should().NotBeNull(); result.IsError.Should().BeFalse(); result.Result.Should().BeEquivalentTo(responseData); }
public async Task GetAllCaseworkersFails() { //Arrange var helperHttpClientMoq = new Mock <ICaseworkerHttpClientHelper>(); var configurationMoq = new Mock <IConfiguration>(); var pageNumber = 0; var context = GetContext(); var error = new Error("123456", new string[] { "An Error Occured while retriving data of all caseworkers" }, "MCA"); helperHttpClientMoq.Setup(x => x.GetAllCaseworkerDataFromMomentumCoreAsync("/punits/0d1345f4-51e0-407e-9dc0-15a9d08326d7/caseworkers", pageNumber)) .Returns(Task.FromResult(new ResultOrHttpError <CaseworkerList, Error>(error, HttpStatusCode.BadRequest))); var caseWorkerService = new CaseworkerService(helperHttpClientMoq.Object, configurationMoq.Object, context.Object); //Act var result = await caseWorkerService.GetAllCaseworkersAsync(pageNumber).ConfigureAwait(false); //Asert result.Should().NotBeNull(); result.IsError.Should().BeTrue(); result.Error.Errors[0].Should().Be("An Error Occured while retriving data of all caseworkers"); }
public async Task GetAllCaseworkersFailsWhenPageNoIsLessThan0() { //Arrange var helperHttpClientMoq = new Mock <ICaseworkerHttpClientHelper>(); int pageNumber = -3; var context = GetContext(); var _config = GetConifg(); var error = new Error("123456", new string[] { "The offset specified in a OFFSET clause may not be negative." }, "MCA"); helperHttpClientMoq.Setup(x => x.GetAllCaseworkerDataFromMomentumCoreAsync("/punits/0d1345f4-51e0-407e-9dc0-15a9d08326d7/caseworkers", pageNumber)) .Returns(Task.FromResult(new ResultOrHttpError <CaseworkerList, Error>(error, HttpStatusCode.BadRequest))); var caseWorkerService = new CaseworkerService(_config, helperHttpClientMoq.Object, context.Object); //Act var result = await caseWorkerService.GetAllCaseworkersAsync(pageNumber).ConfigureAwait(false); //Asert result.Should().NotBeNull(); result.IsError.Should().BeTrue(); result.Error.Errors[0].Should().Be("The offset specified in a OFFSET clause may not be negative."); }