Example #1
0
        public void TestCreateBusiness()
        {
            var a = EntityHelper.GetAccount("first", "lastName");
            var b = EntityHelper.GetBusiness("business1", Category.ActiveLife);

            using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>())
            {
                using (ISession Session = Scope.OpenSession())
                {
                    Session.Transaction.Begin();
                    IRepository r = new GenericRepository(Session);
                    EntityDataService <Business, BusinessValidator> bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator());

                    IDataService    ds = new DataService(null, bds, null, null, null, null, null, null, null, new UnitOfWork(Session));
                    BusinessActions ba = new BusinessActions(a, ds, new PraLoup.Infrastructure.Logging.Log4NetLogger(), null);
                    ba.CreateBusiness(b, a, Role.BusinessAdmin);
                    Session.Transaction.Commit();
                }

                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService <Business, BusinessValidator> bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator());

                    var b1 = bds.Find(b.Id);
                    Assert.IsNotNull(b1);
                    Assert.AreEqual(b, b1);
                }
            }
        }
Example #2
0
        public void TestCreateBusiness()
        {
            var a = EntityHelper.GetAccount("first", "lastName");
            var b = EntityHelper.GetBusiness("business1", Category.ActiveLife);

            using (var Scope = new SQLiteDatabaseScope<PraLoupAutoMappingConfiguration>())
            {
                using (ISession Session = Scope.OpenSession())
                {
                    Session.Transaction.Begin();
                    IRepository r = new GenericRepository(Session);
                    EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator());

                    IDataService ds = new DataService(null, bds, null, null, null, null, null, null, null, new UnitOfWork(Session));
                    BusinessActions ba = new BusinessActions(a, ds, new PraLoup.Infrastructure.Logging.Log4NetLogger(), null);
                    ba.CreateBusiness(b, a, Role.BusinessAdmin);
                    Session.Transaction.Commit();
                }

                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator());

                    var b1 = bds.Find(b.Id);
                    Assert.IsNotNull(b1);
                    Assert.AreEqual(b, b1);
                }
            }
        }
Example #3
0
        public void IsFriendGenerateOkSQL_Success()
        {
            using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>())
            {
                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService <Account, AccountValidator> ads = new EntityDataService <Account, AccountValidator>(r, new AccountValidator());

                    Session.BeginTransaction();
                    Assert.IsTrue(ads.SaveOrUpdate(myself));
                    Assert.IsTrue(ads.SaveOrUpdate(friend));
                    Assert.IsTrue(ads.SaveOrUpdate(friend2));
                    Assert.IsTrue(ads.SaveOrUpdate(friend3));
                    Assert.IsTrue(ads.SaveOrUpdate(friend4));
                    Session.Transaction.Commit();
                }

                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService <Account, AccountValidator>       ads = new EntityDataService <Account, AccountValidator>(r, new AccountValidator());
                    EntityDataService <Connection, ConnectionValidator> cds = new EntityDataService <Connection, ConnectionValidator>(r, new ConnectionValidator());

                    var m  = ads.Find(myself.Id);
                    var f  = ads.Find(friend.Id);
                    var f3 = ads.Find(friend3.Id);
                    var f4 = ads.Find(friend4.Id);

                    // there should be 1 friend for f
                    Log.Debug("executing isfriend");
                    var spec = new AccountGetFriendQuery(f);
                    Assert.IsTrue(ads.ExecuteQuery(spec).RowCount() == 1);
                    spec = new AccountGetFriendQuery(m);
                    Assert.IsTrue(ads.ExecuteQuery(spec).RowCount() == 2);

                    // m should be friends of friend of f3
                    Log.Debug("executing isfriendoffriend");
                    var fof = new ConnectionIsFriendOfFriendQuery(m, f3);
                    Assert.IsTrue(cds.ExecuteQuery(fof).RowCount() > 0);

                    // negative case
                    fof = new ConnectionIsFriendOfFriendQuery(m, f4);
                    Assert.IsTrue(cds.ExecuteQuery(fof).RowCount() == 0);
                }
            }
        }
Example #4
0
        public void TestCreatePromotion()
        {
            var a = EntityHelper.GetAccount("first", "lastName");
            var b = EntityHelper.GetBusiness("business1", Category.ActiveLife);
            var e = EntityHelper.GetEvent("ev name", "venue name");
            var d = EntityHelper.GetDeal("dealname", 10);
            var p = new Promotion(b, e, d, 100, 5);

            using (var Scope = new SQLiteDatabaseScope<PraLoupAutoMappingConfiguration>())
            {
                using (ISession Session = Scope.OpenSession())
                {

                    IRepository r = new GenericRepository(Session);
                    EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator());
                    EntityDataService<Promotion, PromotionValidator> pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator());

                    IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Scope.GetSessionFactory().OpenSession()));
                    BusinessActions ba = new BusinessActions(a, ds, Log, null);
                    PromotionActions pa = new PromotionActions(a, ds, Log, null);

                    Session.Transaction.Begin();
                    b = ba.CreateBusiness(b, a, Role.BusinessAdmin);
                    Assert.IsNotNull(b, "business should be saved succesfully");
                    Session.Transaction.Commit();
                }

                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator());
                    EntityDataService<Promotion, PromotionValidator> pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator());

                    IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Scope.GetSessionFactory().OpenSession()));
                    BusinessActions ba = new BusinessActions(a, ds, Log, null);
                    PromotionActions pa = new PromotionActions(a, ds, Log, null);

                    Session.Transaction.Begin();
                    p = pa.SavePromotion(p);
                    Assert.IsNotNull(p, "promotion should be saved succesfully");

                    Session.Transaction.Commit();
                }

                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService<Promotion, PromotionValidator> pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator());

                    var p1 = pds.Find(p.Id);
                    Assert.IsNotNull(p1);
                    Assert.AreEqual(p, p1);
                }
            }
        }
Example #5
0
        public void TestCreatePromotion()
        {
            var a = EntityHelper.GetAccount("first", "lastName");
            var b = EntityHelper.GetBusiness("business1", Category.ActiveLife);
            var e = EntityHelper.GetEvent("ev name", "venue name");
            var d = EntityHelper.GetDeal("dealname", 10);
            var p = new Promotion(b, e, d, 100, 5);

            using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>())
            {
                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService <Business, BusinessValidator>   bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator());
                    EntityDataService <Promotion, PromotionValidator> pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator());

                    IDataService     ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Scope.GetSessionFactory().OpenSession()));
                    BusinessActions  ba = new BusinessActions(a, ds, Log, null);
                    PromotionActions pa = new PromotionActions(a, ds, Log, null);

                    Session.Transaction.Begin();
                    b = ba.CreateBusiness(b, a, Role.BusinessAdmin);
                    Assert.IsNotNull(b, "business should be saved succesfully");
                    Session.Transaction.Commit();
                }

                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService <Business, BusinessValidator>   bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator());
                    EntityDataService <Promotion, PromotionValidator> pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator());

                    IDataService     ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Scope.GetSessionFactory().OpenSession()));
                    BusinessActions  ba = new BusinessActions(a, ds, Log, null);
                    PromotionActions pa = new PromotionActions(a, ds, Log, null);

                    Session.Transaction.Begin();
                    p = pa.SavePromotion(p);
                    Assert.IsNotNull(p, "promotion should be saved succesfully");

                    Session.Transaction.Commit();
                }

                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService <Promotion, PromotionValidator> pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator());

                    var p1 = pds.Find(p.Id);
                    Assert.IsNotNull(p1);
                    Assert.AreEqual(p, p1);
                }
            }
        }
        public void IsFriendGenerateOkSQL_Success()
        {
            using (var Scope = new SQLiteDatabaseScope<PraLoupAutoMappingConfiguration>())
            {
                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService<Account, AccountValidator> ads = new EntityDataService<Account, AccountValidator>(r, new AccountValidator());
                    var cds = new EntityDataService<Connection, ConnectionValidator>(r, new ConnectionValidator());
                    DataService ds = new DataService(ads, null, null, null, null, cds, null, null, null, new UnitOfWork(Session));
                    ds.UnitOfWork.Begin();
                    IEnumerable<string> s;
                    ds.Account.SaveOrUpdateAll(new Account[] { myself, friend, friend2, friend3, friend4 }, out s);
                    ds.UnitOfWork.End();
                }
                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService<Account, AccountValidator> ads = new EntityDataService<Account, AccountValidator>(r, new AccountValidator());
                    var cds = new EntityDataService<Connection, ConnectionValidator>(r, new ConnectionValidator());
                    DataService ds = new DataService(ads, null, null, null, null, cds, null, null, null, new UnitOfWork(Session));
                    ds.UnitOfWork.Begin();
                    var c = ads.GetAll().ToList();
                    var m = ads.Find(myself.Id);
                    var f = ads.Find(friend.Id);
                    var f3 = ads.Find(friend3.Id);

                    Log.Debug("executing isfriend");
                    Assert.IsTrue(m.IsFriend(f, ds));

                    Log.Debug("executing isfriendoffriend");
                    Assert.IsTrue(m.IsFriendOfFriend(f3, ds));
                    ds.UnitOfWork.End();
                }
            }
        }
Example #7
0
        public void IsFriendGenerateOkSQL_Success()
        {
            using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>())
            {
                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService <Account, AccountValidator> ads = new EntityDataService <Account, AccountValidator>(r, new AccountValidator());
                    var         cds = new EntityDataService <Connection, ConnectionValidator>(r, new ConnectionValidator());
                    DataService ds  = new DataService(ads, null, null, null, null, cds, null, null, null, new UnitOfWork(Session));
                    ds.UnitOfWork.Begin();
                    IEnumerable <string> s;
                    ds.Account.SaveOrUpdateAll(new Account[] { myself, friend, friend2, friend3, friend4 }, out s);
                    ds.UnitOfWork.End();
                }
                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService <Account, AccountValidator> ads = new EntityDataService <Account, AccountValidator>(r, new AccountValidator());
                    var         cds = new EntityDataService <Connection, ConnectionValidator>(r, new ConnectionValidator());
                    DataService ds  = new DataService(ads, null, null, null, null, cds, null, null, null, new UnitOfWork(Session));
                    ds.UnitOfWork.Begin();
                    var c  = ads.GetAll().ToList();
                    var m  = ads.Find(myself.Id);
                    var f  = ads.Find(friend.Id);
                    var f3 = ads.Find(friend3.Id);

                    Log.Debug("executing isfriend");
                    Assert.IsTrue(m.IsFriend(f, ds));

                    Log.Debug("executing isfriendoffriend");
                    Assert.IsTrue(m.IsFriendOfFriend(f3, ds));
                    ds.UnitOfWork.End();
                }
            }
        }
Example #8
0
        public void IsFriendGenerateOkSQL_Success()
        {
            using (var Scope = new SQLiteDatabaseScope<PraLoupAutoMappingConfiguration>())
            {
                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService<Account, AccountValidator> ads = new EntityDataService<Account, AccountValidator>(r, new AccountValidator());

                    Session.BeginTransaction();
                    Assert.IsTrue(ads.SaveOrUpdate(myself));
                    Assert.IsTrue(ads.SaveOrUpdate(friend));
                    Assert.IsTrue(ads.SaveOrUpdate(friend2));
                    Assert.IsTrue(ads.SaveOrUpdate(friend3));
                    Assert.IsTrue(ads.SaveOrUpdate(friend4));
                    Session.Transaction.Commit();
                }

                using (ISession Session = Scope.OpenSession())
                {
                    IRepository r = new GenericRepository(Session);
                    EntityDataService<Account, AccountValidator> ads = new EntityDataService<Account, AccountValidator>(r, new AccountValidator());
                    EntityDataService<Connection, ConnectionValidator> cds = new EntityDataService<Connection, ConnectionValidator>(r, new ConnectionValidator());

                    var m = ads.Find(myself.Id);
                    var f = ads.Find(friend.Id);
                    var f3 = ads.Find(friend3.Id);
                    var f4 = ads.Find(friend4.Id);

                    // there should be 1 friend for f
                    Log.Debug("executing isfriend");
                    var spec = new AccountGetFriendQuery(f);
                    Assert.IsTrue(ads.ExecuteQuery(spec).RowCount() == 1);
                    spec = new AccountGetFriendQuery(m);
                    Assert.IsTrue(ads.ExecuteQuery(spec).RowCount() == 2);

                    // m should be friends of friend of f3
                    Log.Debug("executing isfriendoffriend");
                    var fof = new ConnectionIsFriendOfFriendQuery(m, f3);
                    Assert.IsTrue(cds.ExecuteQuery(fof).RowCount() > 0);

                    // negative case
                    fof = new ConnectionIsFriendOfFriendQuery(m, f4);
                    Assert.IsTrue(cds.ExecuteQuery(fof).RowCount() == 0);
                }
            }
        }