Esempio n. 1
0
        public async Task ExpensePredictionTest()
        {
            using (var fixture = new GeldAppFixture())
            {
                await fixture.Login("Hans");

                for (var n = 0; n < CategoryPredictionService.MinimumNumberOfExpensesForPrediction; n++)
                {
                    await fixture.AddExpenseAsync("Hans", -100, "Essen", "Pizza");
                }
                for (var n = 0; n < CategoryPredictionService.MinimumNumberOfExpensesForPrediction; n++)
                {
                    await fixture.AddExpenseAsync("Hans", -200, "Einkaufen", "Pizza");
                }

                // Learn.
                var categoryPredictionService = fixture.GetService <ICategoryPredictionService>();
                await categoryPredictionService.LearnCategoriesAsync();

                // Verify.
                (await fixture.GetAsync <CategoryPredictionResult>("/api/account/Hans/categories/predict?amount=-100&created=2019-01-01&expenseDate=2019-01-01"))
                .Category.Should().Be("Essen");
                (await fixture.GetAsync <CategoryPredictionResult>("/api/account/Hans/categories/predict?amount=-200&created=2019-01-01&expenseDate=2019-01-01"))
                .Category.Should().Be("Einkaufen");
            }
        }