public async Task Test_Get_Loan_For_Admin_UserName_Null() { //Act var loans = await _adminLoanController.Get(); //Assert loans.Should().BeOfType <BadRequestObjectResult>(); }
public void GetSuccess() { var loanServices = new Mock <ILoanServices>(); var logger = new Mock <ILogger <LoanController> >(); var loanResponse = A.ListOf <LoanResponseViewModel>(); var loanController = new LoanController(loanServices.Object, logger.Object); loanServices.Setup(x => x.GetByClientKey(It.IsAny <Guid>())) .Returns(loanResponse); var response = loanController.Get(); Assert.NotNull(response); Assert.IsType <OkObjectResult>(response.Result); var httpObjResult = response.Result as OkObjectResult; Assert.NotNull(httpObjResult); Assert.True(httpObjResult.StatusCode == 200); var value = httpObjResult.Value; Assert.NotNull(value); Assert.False(string.IsNullOrEmpty(value.ToString())); }
public async Task GetTest() { int id = 2014; var response = await controller.Get(id); Assert.AreEqual("s", ((LoanManage.Database.Entity.LoanDetails)((Microsoft.AspNetCore.Mvc.ObjectResult)response.Result).Value).Startdate); }
public void GetById() { var testId = 1; var loan = _controller.Get(testId); _repo.Verify(x => x.GetById(It.IsAny <int>()), Times.Once); Assert.Equal(testId, loan.Id); }
public void Get() { LoanController controller = new LoanController(new FakeLoanRepository()) { Request = new HttpRequestMessage() }; controller.Request.SetConfiguration(new HttpConfiguration()); HttpResponseMessage result = controller.Get(); Assert.IsNotNull(result); }
public async Task Test_Get_Loan_For_Customer() { //Act var loans = await _customerLoanController.Get(); var loansValue = (loans as OkObjectResult).Value as IEnumerable <Loan>; //Assert loansValue.Should().NotBeNull(); loansValue.Count().Should().Be(1); loansValue.ToArray()[0].CustomerID.Should().Be(2); }
public void GetInternFail() { var loanServices = new Mock <ILoanServices>(); var logger = new Mock <ILogger <LoanController> >(); var loanController = new LoanController(loanServices.Object, logger.Object); loanServices.Setup(x => x.GetByClientKey(It.IsAny <Guid>())).Throws(new IOException()); var response = loanController.Get(); Assert.NotNull(response); Assert.IsType <StatusCodeResult>(response.Result); var httpObjResult = response.Result as StatusCodeResult; Assert.NotNull(httpObjResult); Assert.True(httpObjResult.StatusCode == 500); }
public void ShouldReturnObjectOnGet() { var mockLoanDependency = new Mock <ILoanService>(); var mockDbService = new Mock <IDBService>(); var id = Guid.NewGuid().ToString(); mockDbService.Setup(x => x.Read(It.IsAny <string>())) .ReturnsAsync(new LoanRequest { id = id } ); var loanController = new LoanController(mockLoanDependency.Object, mockDbService.Object); var createdResponse = loanController.Get(id).Result; Assert.IsType <OkObjectResult>(createdResponse); var resultActionValue = (createdResponse as OkObjectResult).Value as LoanRequest; Assert.NotNull(resultActionValue.id); }