Exemple #1
0
        public void AddEntityCreatesEntityInDb()
        {
            using (var db = new ItsomContext(CtxOpt))
            {
                db.Database.EnsureCreated();

                IDataService <CashAccount> repo = new BaseDataService <CashAccount>(db);

                repo.Add(Cashact);

                var collection = db.ChangeTracker.Entries();
                Assert.Contains(collection, x => x.Entity.GetType() == typeof(CashAccount));

                db.SaveChanges();
            }
        }
Exemple #2
0
        public void GetByReturnEntityBasedOnPredicate()
        {
            using (var db = new ItsomContext(CtxOpt))
            {
                db.Database.EnsureCreated();
                IDataService <CashAccount> repo = new BaseDataService <CashAccount>(db);
                repo.Add(Cashact);
                db.SaveChanges();

                var condition = new QueryCondition <CashAccount>();
                condition.QueryPredicates.Add(c => c.IsActivated);

                var result = repo.GetBy(condition);

                Assert.NotNull(result);
                Assert.IsType <CashAccount>(result);
            }
        }
Exemple #3
0
        public void UpdateEntityChangesEntityStateToModified()
        {
            using (var db = new ItsomContext(CtxOpt))
            {
                db.Database.EnsureCreated();
                IDataService <CashAccount> repo = new BaseDataService <CashAccount>(db);

                repo.Add(Cashact);
                db.SaveChanges();

                var acct = db.CashAccounts.First();

                acct.AccountBalance = 10m;

                repo.Update(acct);
                var collection = db.ChangeTracker.Entries();
                Assert.Contains(collection, x => x.Entity.GetType() == typeof(CashAccount));
                var one = collection.Where(c => c.State == EntityState.Modified).SingleOrDefault();
                Assert.NotNull(one);
                //Assert.Equal(acct.AccountBalance, 10m);
            }
        }