예제 #1
0
        public void Adding_Income_To_Db()
        {
            Context        context        = new Context();
            var            incomeManager  = new IncomeManager();
            AccountManager accountManager = new AccountManager();

            incomeManager.Context.Categories.Local.Add(new Category("З/п", "income"));
            incomeManager.Context.Currencies.Local.Add(new Currency("RUB"));
            Account textAccount = new Account("testAccount");

            accountManager.Context.Accounts.Local.Add(textAccount);
            accountManager.Context.SaveChanges();

            incomeManager.AddOperation(1000, DateTime.Parse("2014-02-02"),
                                       accountManager.Context.Accounts.Local.ElementAt(accountManager.Context.Accounts.Local.IndexOf(textAccount)), null,
                                       incomeManager.Context.Currencies.Local.ElementAt(0), incomeManager.Context.Categories.Local.ElementAt(0), "text comment");

            Operation addedOperation = context.Operations
                                       .OrderByDescending(op => op.Id)
                                       .First();

            Assert.ReferenceEquals(incomeManager.Context.Operations.Local.ElementAt(0), new Operation("income", 1000, DateTime.Parse("2014-02-02"),
                                                                                                      accountManager.Context.Accounts.Local.ElementAt(0), null,
                                                                                                      incomeManager.Context.Currencies.Local.ElementAt(0), incomeManager.Context.Categories.Local.ElementAt(0),
                                                                                                      "text comment")
            {
                Id = incomeManager.Context.Operations.Local.ElementAt(0).Id
            });
        }
예제 #2
0
        public void Not_Adding_Simmiliar_Items()
        {
            Context        context        = new Context();
            var            incomeManager  = new IncomeManager();
            AccountManager accountManager = new AccountManager();

            incomeManager.Context.Categories.Local.Add(new Category("Sallary", "income"));
            incomeManager.Context.Currencies.Local.Add(new Currency("RUB"));
            Account textAccount = new Account("testAccount");

            accountManager.Context.Accounts.Local.Add(textAccount);
            accountManager.Context.SaveChanges();

            incomeManager.AddOperation(1000, DateTime.Parse("2014-02-02"),
                                       accountManager.Context.Accounts.Local.ElementAt(accountManager.Context.Accounts.Local.IndexOf(textAccount)),
                                       null, incomeManager.Context.Currencies.Local.ElementAt(0),
                                       incomeManager.Context.Categories.Local.ElementAt(0), "first part");
            incomeManager.AddOperation(1000, DateTime.Parse("2014-02-02"),
                                       accountManager.Context.Accounts.Local.ElementAt(accountManager.Context.Accounts.Local.IndexOf(textAccount)),
                                       null, incomeManager.Context.Currencies.Local.ElementAt(0),
                                       incomeManager.Context.Categories.Local.ElementAt(0), "first part");
        }