示例#1
0
        public void RequestCurrentBalanceWithInvalidToken_ShouldReturnBadRequest()
        {
            //Arrange
            var token = fixture.Create <string>();

            mockUserAccountProvider.Setup(x => x.isLoggedIn(token)).Returns(false);
            //Act
            var ledgerController = new LedgerController(mockUserAccountProvider.Object, mockLedgerProvider.Object);
            var result           = ledgerController.CurrentBalance(token) as BadRequestObjectResult;

            //Asert
            Assert.IsType <BadRequestObjectResult>(result);
            Assert.Equal("User not presently logged in", result.Value);
            mockUserAccountProvider.VerifyAll();
        }
示例#2
0
        public void RequestCurrentBalanceWithInvalidToken_ShouldReturnCurrentBalance()
        {
            //Arrange
            var token   = fixture.Create <string>();
            var balance = fixture.Create <decimal>();

            mockUserAccountProvider.Setup(x => x.isLoggedIn(token)).Returns(true);
            mockLedgerProvider.Setup(x => x.getCurrentBalance(token)).Returns(balance);
            //Act
            var ledgerController = new LedgerController(mockUserAccountProvider.Object, mockLedgerProvider.Object);
            var result           = ledgerController.CurrentBalance(token) as OkObjectResult;

            //Asert
            Assert.IsType <OkObjectResult>(result);
            Assert.Equal(balance, result.Value);
            mockUserAccountProvider.VerifyAll();
            mockLedgerProvider.VerifyAll();
        }