예제 #1
0
        public async Task Test_Get_Loan_For_Admin_UserName_Null()
        {
            //Act
            var loans = await _adminLoanController.Get();

            //Assert
            loans.Should().BeOfType <BadRequestObjectResult>();
        }
예제 #2
0
        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()));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public void Get()
        {
            LoanController controller = new LoanController(new FakeLoanRepository())
            {
                Request = new HttpRequestMessage()
            };

            controller.Request.SetConfiguration(new HttpConfiguration());
            HttpResponseMessage result = controller.Get();

            Assert.IsNotNull(result);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }