public void ExpectNullReference()
        {
            // arrange
            var controller = new BankAccountsController(null);

            // act
            controller.Get();

            // assert
            Assert.Fail();
        }
        public void ExpectNoBankAccounts()
        {
            // arrange
            var controller = new BankAccountsController(new Mocks.MockNoBankAccountRepository());
            var products   = default(IEnumerable <BankAccount>);

            // act
            products = controller.Get();

            // assert
            Assert.AreEqual(0, products.Count());
        }
예제 #3
0
        public void GetAll_Tests()
        {
            // Arrange
            var expectedStatusCode = 200;

            _unitOfWorkMock
            .Setup(uow => uow.GetReadOnlyRepository <BankAccount>())
            .Returns(_bankAccountReadOnlyRepositoryMock.Object);

            var bankAccounts = new BankAccount[] {
                new BankAccount
                {
                    Id       = 1,
                    Balance  = 102.45M,
                    Number   = "PBO1221323",
                    IsLocked = false
                },
                new BankAccount
                {
                    Id       = 2,
                    Balance  = 10002.98M,
                    Number   = "PIC9984567",
                    IsLocked = false
                }
            };

            _bankAccountReadOnlyRepositoryMock
            .Setup(ror => ror.GetList <BankAccount>(null, null, null, null, 0, 20, true))
            .Returns(bankAccounts.ToPaginate(0, 20));

            // Act
            var result = _bankAccountsController.Get();
            var or     = (result as ActionResult <IList <BankAccount> >)?.Result as ObjectResult;

            // Assert
            Assert.NotNull(or);
            Assert.Equal(expectedStatusCode, or.StatusCode);
            Assert.NotEmpty(or.Value as IList <BankAccount>);
            Assert.Equal(bankAccounts.Length, (or.Value as IList <BankAccount>).Count);
        }