public static void CreateExpenses(ExpenseDatabaseContext context)
        {
            var tag = new Tag()
                          {
                              Name = "food"
                          };
            context.Tags.Add(tag);

            var expense = new Expense.Expense();
            expense.Amount = 20;
            expense.DateOfMakingExpense = DateTime.UtcNow;
            expense.Description = "in the market";
            expense.Tag = tag;
            expense.User = context.Users.FirstOrDefault();
            context.Expenses.Add(expense);

            tag = new Tag()
                      {
                          Name = "party"
                      };
            context.Tags.Add(tag);

            expense = new Expense.Expense();
            expense.Amount = (Decimal)136.7;
            expense.DateOfMakingExpense = DateTime.UtcNow;
            expense.Description = "birthday";
            expense.Tag = tag;
            expense.User = context.Users.FirstOrDefault();
            context.Expenses.Add(expense);
        }
Пример #2
0
        public void SuccessfulTest_AddingSharedTag()
        {
            //adding shared tag

            ExpenseNamespace.Tag tagParty = new ExpenseNamespace.Tag()
            {
                Name = "party"
            };

            TagsList.Add(tagParty);

            Assert.AreEqual(3, TagsList.Count);
        }
Пример #3
0
        public void FailTest_AddingTag_SystemAlreadyHasSame()
        {
            //adding exists tag

            ExpenseNamespace.Tag tagParty = new ExpenseNamespace.Tag()
            {
                Name = "party",
                User = MyAccount
            };

            TagsList.Add(tagParty);

            Assert.AreEqual(3, TagsList.Count);
        }
        public SetupData()
        {
            // create new account record
            MyAccount = new User()
                            {
                                Login = "******",                      // login
                                Password = "******",                    // passwor
                                UserGuid = Guid.NewGuid().ToString(),   // generate new GUID
                                Expenses = new Collection<ExpenseNamespace.Expense>()   // empty collection of expenes
                            };

            TagsList = new List<ExpenseNamespace.Tag>();

            // create 1-st tag
            ExpenseNamespace.Tag tagFun = new ExpenseNamespace.Tag()
                                           {
                                               Name = "fun",
                                               User = MyAccount
                                           };
            TagsList.Add(tagFun);

            // create new expense
            ExpenseNamespace.Expense expense1 = new ExpenseNamespace.Expense()
                                         {
                                             Amount = 100,                            // expense sum
                                             DateOfMakingExpense = DateTime.UtcNow,   // date of take expense
                                             Description = "present for mom",         // reason
                                             Tag = tagFun,                            // select tag
                                             User = MyAccount                         // owner
                                         };

            ExpenseNamespace.Tag tagFood = new ExpenseNamespace.Tag()
                                        {
                                            Name = "food",
                                            User = MyAccount
                                        };

            TagsList.Add(tagFood);

            MyAccount.Expenses.Add(expense1);

            ExpenseNamespace.Expense expense2 = new ExpenseNamespace.Expense()
                                        {
                                            Amount = 50,
                                            DateOfMakingExpense = DateTime.UtcNow,
                                            Description = "",
                                            Tag = tagFood,
                                            User = MyAccount
                                        };

            MyAccount.Expenses.Add(expense2);

            ExpenseNamespace.Expense expense3 = new ExpenseNamespace.Expense()
            {
                Amount = 55,
                DateOfMakingExpense = DateTime.UtcNow,
                Description = "",
                Tag = tagFood,
                User = MyAccount
            };

            MyAccount.Expenses.Add(expense3);
        }