public void BusinessBasicCRUD_Success() { using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { var account = EntityHelper.GetAccount("business", "owner"); var bu = new BusinessUser(account, Role.BusinessAdmin); var op = new List <HoursOfOperation>() { new HoursOfOperation(0, DateTime.Now.TimeOfDay, DateTime.Now.TimeOfDay) }; new PersistenceSpecification <Business>(Session, new BusinessUsersEqualityComparer()) .CheckProperty(c => c.Name, "businessname") .CheckProperty(c => c.Category, Category.Nightlife) .CheckProperty(c => c.BusinessUsers, new List <BusinessUser>() { bu }) .CheckProperty(c => c.Url, "http://www.hello.com") .CheckProperty(c => c.ImageUrl, "http://www.example.com/image/i.png") .CheckProperty(c => c.HoursOfOperations, op) .VerifyTheMappings(); } } }
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); } } }
public void CreateActivityAndQuery() { using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { //var ev = GetEvent("mytestevent", "mytestvenue"); //var a = GetAccount("fristname", "lastname"); //var act = new Activity(a, ev, Privacy.Public); //var r = new DataServ } } }
public void InvitationBasicCRUD_Success() { using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { var updatedTime = DateTime.Now.Date; // var organizer = GetAccount("firstname", "lastname"); // var ev = GetEvent("my test event", "my test venue name"); // new PersistenceSpecification<Invitation>(Session) //.CheckProperty(i => i.Activity, 1234) // //.CheckReference(i => i.Comments, ) //.CheckReference(c => c.Organizer, organizer) //.CheckProperty(c => c.Privacy, Privacy.Public) //.CheckProperty(c => c.UpdatedTime, updatedTime) //.VerifyTheMappings(); } } }
public void PromotionBasicCRUD_Success() { using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { var updatedTime = DateTime.Now.Date; var ev = EntityHelper.GetEvent("my test event", "my test venue name"); var d = EntityHelper.GetDeal("buy one get one beer", 100); IList <Deal> deals = new List <Deal>() { d }; new PersistenceSpecification <Promotion>(Session, new PromotionEqualityComparer()) .CheckProperty(c => c.Event, ev) .CheckProperty(c => c.Deals, deals) .VerifyTheMappings(); } } }
public void EventBasicCRUD_Success() { using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { var start = DateTime.Now.Date; var end = DateTime.Now.Date.AddHours(1); new PersistenceSpecification <Event>(Session, new TagsEqualityComparer()) .CheckProperty(c => c.Description, "Event Description") .CheckProperty(c => c.Name, "Event Name") .CheckProperty(c => c.ImageUrl, "http://www.example.com/image/i.png") .CheckProperty(c => c.StartDateTime, start) .CheckProperty(c => c.EndDateTime, end) .CheckProperty(c => c.Tags, new Tag[] { new Tag("Tag1"), new Tag("Tag2") }) .VerifyTheMappings(); } } }
public void AccountBasicCRUD_Success() { using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { var now = DateTime.Now; new PersistenceSpecification <Account>(Session, new CustomEqualityComparer()) .CheckProperty(c => c.FirstName, "John") .CheckProperty(c => c.LastName, "Doe") .CheckProperty(c => c.FacebookLogon, new FacebookLogon() { FacebookId = 1000, AccessToken = "abc", Expires = now }) .CheckProperty(c => c.Email, "*****@*****.**") .CheckProperty(c => c.Connections, new List <Connection>() { new Connection(1, 2), new Connection(1, 3) }) .VerifyTheMappings(); } } }