Пример #1
0
        public async Task GetBudget_ShouldReturnBudget()
        {
            _getBudgetQueryStub.Result = new BudgetViewModel();

            var result = (OkObjectResult)await _budgetController.GetBudget(2016, 5);

            Assert.Same(_getBudgetQueryStub.Result, result.Value);
        }
        public void GetBudgetWithIdNoResult()
        {
            var budgetRepository = new Mock <IRepository <Budget> >();
            var userManager      = new Mock <IIdentityMembershipProvider>();

            var controller = new BudgetController(budgetRepository.Object, userManager.Object);
            var someId     = 1;
            var budget     = controller.GetBudget(someId);

            Assert.IsInstanceOfType(budget, typeof(NotFoundResult));
        }
        public void Test_GetBudgetTest()
        {
            //Arrange
            Test_BudgetDbContext _tdb = new Test_BudgetDbContext();

            _tdb.Database.EnsureCreated();
            OrmAdapter <Test_BudgetDbContext> _oa = new OrmAdapter <Test_BudgetDbContext>(_tdb);
            BudgetController budgetController     = new BudgetController(_tdb);

            //Act
            var budget = budgetController.GetBudget(1);

            _tdb.Database.EnsureDeleted();

            //Assert
            Assert.True(budget != null); //
        }
        public void CanGetBudgetWithId()
        {
            var budgetRepository = new LocalRepository <Budget>();
            var userManager      = new Mock <IIdentityMembershipProvider>();

            var budgetInRepository = new Budget()
            {
                ClientId = 1,
                Id       = 1,
                Value    = 1000,
                Month    = new DateTime(2013, 2, 2)
            };

            budgetRepository.Add(budgetInRepository);
            var controller = new BudgetController(budgetRepository, userManager.Object);

            var budget = controller.GetBudget(budgetInRepository.Id) as OkNegotiatedContentResult <Budget>;

            Assert.AreEqual(1, budget.Content.Id);
            Assert.AreEqual(1000, budget.Content.Value);
        }