Exemplo n.º 1
0
        public IEnumerable <Profile> GetProfiles(ProfilingTypes profiling)
        {
            if (!Tracker.IsActive)
            {
                return(Enumerable.Empty <Profile>());
            }

            return(profileProvider.GetSiteProfiles().Where(p => profileProvider.HasMatchingPattern(p, profiling)).Select(x => new Profile {
                Name = x.NameField, PatternMatches = profileProvider.GetPatternsWithGravityShare(x, profiling)
            }));
        }
Exemplo n.º 2
0
        public void LoadProfiles_SetProfiles_ShouldReturnExistentProfilesEnumerable([Content] Item item, PatternMatch patternMatch, ITracker tracker, IProfileProvider provider)
        {
            //arrange
            tracker.IsActive.Returns(true);

            var profileItem = item.Add("profile", new TemplateID(ProfileItem.TemplateID));

            using (new EditContext(profileItem))
            {
                profileItem.Fields[ProfileItem.FieldIDs.Type].Value      = "Average";
                profileItem.Fields[ProfileItem.FieldIDs.NameField].Value = profileItem.Name;
            }

            provider.GetSiteProfiles().Returns(new[] { new ProfileItem(profileItem) });
            provider.HasMatchingPattern(null).ReturnsForAnyArgs(true);
            provider.GetPatternsWithGravityShare(null).ReturnsForAnyArgs(new [] { patternMatch });


            var fakeSiteContext = new FakeSiteContext("fake")
            {
                Database = item.Database
            };

            using (new SiteContextSwitcher(fakeSiteContext))
            {
                using (new TrackerSwitcher(tracker))
                {
                    var model = new VisitInformation(provider);
                    //act
                    var profiles = model.LoadProfiles().ToArray();

                    //assert
                    profiles.Count().Should().Be(1);
                    profiles.First().Name.Should().Be(profileItem.Name);
                    profiles.First().PatternMatches.Single().Should().Be(patternMatch);
                }
            }
        }
Exemplo n.º 3
0
    public void LoadProfiles_SetProfiles_ShouldReturnExistentProfilesEnumerable([Content] Item item, PatternMatch patternMatch, ITracker tracker, IProfileProvider provider)
    {
      //arrange
      tracker.IsActive.Returns(true);

      var profileItem = item.Add("profile", new TemplateID(ProfileItem.TemplateID));
      using (new EditContext(profileItem))
      {
        profileItem.Fields[ProfileItem.FieldIDs.Type].Value = "Average";
        profileItem.Fields[ProfileItem.FieldIDs.NameField].Value = profileItem.Name;
      }

      provider.GetSiteProfiles().Returns(new[]{new ProfileItem(profileItem)});
      provider.HasMatchingPattern(null).ReturnsForAnyArgs(true);
      provider.GetPatternsWithGravityShare(null).ReturnsForAnyArgs(new [] { patternMatch });


      var fakeSiteContext = new FakeSiteContext("fake")
      {
        Database = item.Database
      };

      using (new SiteContextSwitcher(fakeSiteContext))
      {
        using (new TrackerSwitcher(tracker))
        {
          var model = new VisitInformation(provider);
          //act
          var profiles = model.LoadProfiles().ToArray();

          //assert
          profiles.Count().Should().Be(1);
          profiles.First().Name.Should().Be(profileItem.Name);
          profiles.First().PatternMatches.Single().Should().Be(patternMatch);
        }
      }
    }