예제 #1
0
            public void UpdatesBudgetInTheContext()
            {
                // Act.
                using (CheckbookContext context = new CheckbookContext(this.dbContextOptions))
                {
                    BudgetsRepository repository = new BudgetsRepository(context);
                    repository.Save(this.budget, this.userId);
                }

                // Assert.
                using (CheckbookContext context = new CheckbookContext(this.dbContextOptions))
                {
                    int expectedBudgetCount = 5;
                    Assert.AreEqual(expectedBudgetCount, context.Budgets.Count(), "The number of budgets should not change.");

                    Budget actual = ContextDataService.GetBudgetsSet(context)
                                    .FirstOrDefault(x => x.Id == this.budget.Id);
                    Assert.IsNotNull(actual, "A budget should be found.");

                    Budget expected = this.budget;
                    Assert.AreEqual(expected.Id, actual.Id, "The ID for the entity should match.");
                    Assert.AreEqual(expected.Name, actual.Name, "The name for the entity should match.");
                    Assert.AreEqual(expected.UserId, actual.UserId, "The user ID for the entity should match.");
                }
            }
예제 #2
0
            public void UpdatesCategoryInTheContext()
            {
                // Act.
                using (CheckbookContext context = new CheckbookContext(this.dbContextOptions))
                {
                    CategoriesRepository repository = new CategoriesRepository(context);
                    repository.Save(this.category, this.userId);
                }

                // Assert.
                using (CheckbookContext context = new CheckbookContext(this.dbContextOptions))
                {
                    int expectedCategoryCount = 4;
                    Assert.AreEqual(expectedCategoryCount, context.Categories.Count(), "The number of categories should not change.");

                    Category actual = ContextDataService.GetCategoriesSet(context)
                                      .FirstOrDefault(x => x.Id == this.category.Id);
                    Assert.IsNotNull(actual, "A category should be found.");

                    Category expected = this.category;
                    Assert.AreEqual(expected.Id, actual.Id, "The ID for the entity should match.");
                    Assert.AreEqual(expected.Name, actual.Name, "The name for the entity should match.");
                    Assert.AreEqual(expected.UserId, actual.UserId, "The user ID for the entity should match.");
                }
            }
예제 #3
0
            public override void Initialize()
            {
                base.Initialize();

                // Initialize the database set.
                using (CheckbookContext context = new CheckbookContext(this.dbContextOptions))
                {
                    DatabaseSeed.AddEntities(context);
                    this.entities = ContextDataService.GetBudgets(context);
                }
            }
예제 #4
0
            public override void Initialize()
            {
                base.Initialize();

                // Initialize the inputs.
                this.userId = 1;

                // Initialize the database set.
                using (CheckbookContext context = new CheckbookContext(this.dbContextOptions))
                {
                    DatabaseSeed.AddEntities(context);
                    this.entities = ContextDataService.GetBudgets(context)
                                    .Where(a => a.UserId == this.userId)
                                    .ToList();
                }
            }
예제 #5
0
            public override void Initialize()
            {
                base.Initialize();

                // Initialize the inputs.
                this.userId   = 1;
                this.category = new Category
                {
                    Name   = "Third Category",
                    UserId = this.userId,
                };

                // Initialize the database set.
                using (CheckbookContext context = new CheckbookContext(this.dbContextOptions))
                {
                    DatabaseSeed.AddEntities(context);
                    this.entities = ContextDataService.GetCategories(context);
                }
            }
예제 #6
0
            public override void Initialize()
            {
                base.Initialize();

                // Initialize the input.
                this.userId = 1;
                this.budget = new Budget
                {
                    Id         = 2,
                    Name       = "Second Budget x",
                    UserId     = this.userId,
                    CategoryId = 1,
                };

                // Initialize the database set.
                using (CheckbookContext context = new CheckbookContext(this.dbContextOptions))
                {
                    DatabaseSeed.AddEntities(context);
                    this.entities = ContextDataService.GetBudgets(context);
                }
            }