Example #1
0
		public void WhereColumnInStringArrayDoesntCauseFormattingExceptions()
		{
			string emailWithOpenBrace = "OpenBrace{@hotmail.com";
			Usr u1 = new Usr {Email = emailWithOpenBrace};
			u1.Update();
			string emailWithCloseBrace = "CloseBrace}@hotmail.com";
			Usr u2 = new Usr {Email = emailWithCloseBrace};
			u2.Update();

			UsrSet us = new UsrSet(new Query(new Q(Usr.Columns.Email, new[] {emailWithOpenBrace, emailWithCloseBrace})){OrderBy = new OrderBy(Usr.Columns.K)});
			Assert.AreEqual(u1.K, us[0].K);
			Assert.AreEqual(u2.K, us[1].K);
		}
		public void UsrFavoursParentMusicType_BannerTargetsChild_BannerIsServed()
		{
			Usr u = new Usr();
			u.Name = Guid.NewGuid().ToString();
			u.Update();

			MusicType parentMusicType = new MusicType() { ParentK = 1 };
			parentMusicType.Update();

			MusicType childMusicType = new MusicType()
			{
				ParentK = parentMusicType.K
			};
			childMusicType.Update();

			UsrMusicTypeFavourite umtf = new UsrMusicTypeFavourite()
			{
				MusicTypeK = parentMusicType.K,
				UsrK = u.K
			};
			umtf.Update();

			Banner b = new Banner()
			{
				IsMusicTargetted = true
			};
			b.Update();

			b.SaveMusicTargetting(new List<int>() { childMusicType.K });

			MusicTypesFavouredByIdentityRule rule = new MusicTypesFavouredByIdentityRule(new UsrIdentity(u));
			RequestRules rr = new RequestRules();
			rr.MusicTypes = rule;
			ReadOnlyCollection<BannerDataHolder> results = rr.GetBannersSatsfyingQueryConditionsInTimeslot(Timeslots.GetCurrentTimeslot());
			Assert.IsTrue(ContainsBanner(b.K, results));
		}
		public void UsrFavoursOneMusicType_BannerTargetsAnother_BannerIsNotServed()
		{
			Usr u = new Usr();
			u.Name = Guid.NewGuid().ToString();
			u.Update();

			MusicType musicTypeA = new MusicType() { ParentK = 1 };
			musicTypeA.Update();

			MusicType musicTypeB = new MusicType() { ParentK = 1 };
			musicTypeB.Update();

			UsrMusicTypeFavourite umtf = new UsrMusicTypeFavourite()
			{
				MusicTypeK = musicTypeA.K,
				UsrK = u.K
			};
			umtf.Update();

			Banner b = new Banner()
			{
				IsMusicTargetted = true
			};
			b.Update();

			BannerMusicType bmt = new BannerMusicType()
			{
				BannerK = b.K,
				MusicTypeK = musicTypeB.K
			};
			bmt.Update();

			MusicTypesFavouredByIdentityRule rule = new MusicTypesFavouredByIdentityRule(new UsrIdentity(u));
			RequestRules rr = new RequestRules() { MusicTypes = rule };
			ReadOnlyCollection<BannerDataHolder> results = rr.GetBannersSatsfyingQueryConditionsInTimeslot(Timeslots.GetCurrentTimeslot());
			Assert.IsFalse(ContainsBanner(b.K, results));
		}