示例#1
0
        public async Task Examples_RunSuccessfully()
        {
            // Arrange
            GlobalConfiguration.Instance = GlobalConfiguration.MergeConfigurations(GlobalConfiguration.Instance, new Configuration
            {
                DateTimeFormat = "yyyy-MM-dd"
            });
            var budgetMonthId = "2019-08-01";
            var budgetId      = new Guid("14235236-8085-4cf6-9fa6-92c34ed44b0c");
            var categoryId    = new Guid("3b89df53-1869-4d2f-a636-d09eadc3f0ca");

            // Act
            // Assert
            try {
                using (var stub = new YnabApiStub()) {
                    var api = new API(_token, stub.BasePath);
                    var ble = new BudgetListExample(api);
                    ble.Execute();
                    await ble.ExecuteAsync();

                    var bme = new BudgetMonthExample(api);
                    bme.Execute(budgetId, budgetMonthId);
                    await bme.ExecuteAsync(budgetId, budgetMonthId);

                    var btc = new BulkTransactionCreate(api);
                    // btc.Execute();
                    // await btc.ExecuteAsync();

                    var cbe = new CategoryBalanceExample(api);
                    cbe.Execute(budgetId, categoryId);
                    await cbe.ExecuteAsync(budgetId, categoryId);

                    var cmt = new CreateMultipleTransactions(api);
                    // cmt.Execute();
                    // await cmt.ExecuteAsync();

                    var ct = new CreateTransaction(api);
                    ct.Execute();
                    await ct.ExecuteAsync();

                    var dre = new DeltaRequestExample(api);
                    dre.Execute();
                    await dre.ExecuteAsync();

                    var ucb = new UpdateCategoryBudgeted(api);
                    // ucb.Execute();
                    // await ucb.ExecuteAsync();

                    var ut = new UpdateTransaction(api);
                    // ut.Execute();
                    // await ut.ExecuteAsync();
                }
            } catch (Exception ex) {
                Assert.True(false, ex.Message);
            }
            Assert.True(true, "Finished running examples");
        }
示例#2
0
        public async Task Budgets_AreNotEmpty()
        {
            // Arrange
            using (var stub = new YnabApiStub())
            {
                var api = new API(_token, stub.BasePath);
                // Act
                var result = await api.Budgets.GetBudgetsAsync();

                // Assert
                Assert.True(result.Data.Budgets.Count == 2, "budget count should be 2");
            }
        }
示例#3
0
        public async Task Months_NotBeEmpty()
        {
            // Arrange
            using (var stub = new YnabApiStub())
            {
                var api = new API(_token, stub.BasePath);

                // Act
                var months = (await api.Months.GetBudgetMonthsAsync(TEST_BUDGET_ID)).Data.Months;

                // Assert
                Assert.NotNull(months);
                Assert.NotEmpty(months);
            }
        }
示例#4
0
        public async Task Categories_NotBeEmpty()
        {
            // Arrange
            using (var stub = new YnabApiStub())
            {
                var api = new API(_token, stub.BasePath);

                // Act
                var categories = (await api.Categories.GetCategoriesAsync(TEST_BUDGET_ID)).Data.CategoryGroups;

                // Assert
                Assert.NotNull(categories);
                Assert.NotEmpty(categories);
            }
        }
示例#5
0
        public async Task Budgets_TestBudgetExists()
        {
            // Arrange
            using (var stub = new YnabApiStub())
            {
                var api        = new API(_token, stub.BasePath);
                var budgetName = "TestBudget";
                var budgets    = (await api.Budgets.GetBudgetsAsync()).Data.Budgets;
                var testBudget = budgets.Where(budget => { return(budget.Name == budgetName); }).FirstOrDefault();
                Assert.NotNull(testBudget);
                var budgetId = testBudget.Id;

                // Act
                var result = await api.Budgets.GetBudgetByIdAsync(budgetId.ToString());

                // Assert
                Assert.True(result.Data.Budget.Name == budgetName, $"Incorrect budget name: {result.Data.Budget.Name}");
            }
        }
示例#6
0
        public async Task Budgets_ShouldHaveAllProperties()
        {
            // Arrange
            using (var stub = new YnabApiStub())
            {
                var api      = new API(_token, stub.BasePath);
                var budgetId = TEST_BUDGET_ID;

                // Act
                var testBudget = (await api.Budgets.GetBudgetByIdAsync(budgetId)).Data.Budget;

                // Assert
                Assert.NotNull(testBudget.Name);
                Assert.NotNull(testBudget.LastModifiedOn);
                Assert.NotNull(testBudget.DateFormat.Format);
                Assert.NotNull(testBudget.CurrencyFormat.IsoCode);
                Assert.NotNull(testBudget.CurrencyFormat.ExampleFormat);
                Assert.NotNull(testBudget.CurrencyFormat.DecimalDigits);
                Assert.NotNull(testBudget.CurrencyFormat.DecimalSeparator);
                Assert.NotNull(testBudget.CurrencyFormat.SymbolFirst);
                Assert.NotNull(testBudget.CurrencyFormat.GroupSeparator);
                Assert.NotNull(testBudget.CurrencyFormat.CurrencySymbol);
                Assert.NotNull(testBudget.CurrencyFormat.DisplaySymbol);
                Assert.NotNull(testBudget.FirstMonth);
                Assert.NotNull(testBudget.LastMonth);
                Assert.NotEmpty(testBudget.Accounts);
                Assert.NotEmpty(testBudget.Payees);
                Assert.Empty(testBudget.PayeeLocations);
                Assert.NotEmpty(testBudget.CategoryGroups);
                Assert.NotEmpty(testBudget.Categories);
                Assert.NotEmpty(testBudget.Months);
                Assert.NotEmpty(testBudget.Transactions);
                Assert.Empty(testBudget.Subtransactions);
                Assert.Empty(testBudget.ScheduledTransactions);
                Assert.Empty(testBudget.ScheduledSubtransactions);
            }
        }