コード例 #1
0
ファイル: VisitInformation.cs プロジェクト: nsgocev/Habitat
        private static PatternMatch CreatePatternMatch(PatternCardItem matchingPattern, ProfileItem visibleProfile)
        {
            var src = matchingPattern.Image.ImageUrl(new MediaUrlOptions()
            {
                Width    = 50,
                MaxWidth = 50
            });
            var patternMatch = new PatternMatch(visibleProfile.NameField, matchingPattern.Name, src);

            return(patternMatch);
        }
コード例 #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);
        }
      }
    }
コード例 #3
0
 private static PatternMatch CreatePatternMatch(PatternCardItem matchingPattern, ProfileItem visibleProfile)
 {
   var src = matchingPattern.Image.ImageUrl(new MediaUrlOptions()
                                            {
                                              Width = 50,
                                              MaxWidth = 50
                                            });
   var patternMatch = new PatternMatch(visibleProfile.NameField, matchingPattern.Name, src);
   return patternMatch;
 }