Exemple #1
0
        public void Name_ShouldReturnDisplayNameOfItem(IBehaviorProfileContext ctx, [Content] Item ctxItem)
        {
            ctx.Id.Returns(ctxItem.ID);
            var model = new BehaviorProfile(ctx);

            model.Name.Should().Be(ctxItem.DisplayName);
        }
    public void GetEnumerator_Call_ReturnScoresWithKeyName(Db db, ID keyId1, ID keyId2, DbItem profileItem, IBehaviorProfileContext behaviorProfile)
    {
      //Arrange
      using (new SecurityDisabler())
      {
        profileItem.Add(new DbItem("Key1", keyId1, ProfileKeyItem.TemplateID)
        {
          {ProfileKeyItem.FieldIDs.NameField,"key1name" }
        });
        profileItem.Add(new DbItem("Key2", keyId2, ProfileKeyItem.TemplateID)
        {
          {ProfileKeyItem.FieldIDs.NameField,"key2name" }
        });

        db.Add(profileItem);

        var item = db.GetItem(profileItem.FullPath);
        var profile = new ProfileItem(item);

        var behaviorScores = new List<KeyValuePair<ID, float>>() { new KeyValuePair<ID, float>(keyId1, 10), new KeyValuePair<ID, float>(keyId2, 20) };
        behaviorProfile.Scores.Returns(behaviorScores);
        var behaviorProfileDecorator = new BehaviorProfileDecorator(profile, behaviorProfile);

        //Act
        var result = behaviorProfileDecorator.ToList();

        //Assert      
        result.Should().BeEquivalentTo(new[] { new KeyValuePair<string, float>("key1name", 10), new KeyValuePair<string, float>("key2name", 20) });
      }
    }
Exemple #3
0
        public void NumberOfTimesScored_ShouldReturnFromContext(IBehaviorProfileContext ctx, int count)
        {
            ctx.NumberOfTimesScored.Returns(count);
            var model = new BehaviorProfile(ctx);

            model.NumberOfTimesScored.Should().Be(count);
        }
    public void Name_ShouldReturnDisplayNameOfItem(IBehaviorProfileContext ctx, [Content] Item ctxItem)
    {
      ctx.Id.Returns(ctxItem.ID);
      var model = new BehaviorProfile(ctx);
      model.Name.Should().Be(ctxItem.DisplayName);

    }
Exemple #5
0
        public void Id_ShouldReturnFromContext(IBehaviorProfileContext ctx)
        {
            ctx.Id.Returns(ID.NewID);
            var model = new BehaviorProfile(ctx);

            model.Id.Should().Be(ctx.Id.Guid);
        }
    public void NumberOfTimesScored_ShouldReturnFromContext(IBehaviorProfileContext ctx, int count)
    {
      ctx.NumberOfTimesScored.Returns(count);
      var model = new BehaviorProfile(ctx);
      model.NumberOfTimesScored.Should().Be(count);

    }
    public void Id_ShouldReturnFromContext(IBehaviorProfileContext ctx)
    {
      ctx.Id.Returns(ID.NewID);
      var model = new BehaviorProfile(ctx);
      model.Id.Should().Be(ctx.Id.Guid);

    }
 public void GetCount_NumberOfTimesScored_ReturnNumberOfTimesScored(int numberOfTimesScored, IBehaviorProfileContext behaviorProfile)
 {
   //Arrange
   var behaviorProfileDecorator = new BehaviorProfileDecorator(null, behaviorProfile);
   behaviorProfile.NumberOfTimesScored.Returns(numberOfTimesScored);
   //Assert
   behaviorProfileDecorator.Count.Should().Be(numberOfTimesScored);
 }
 public void Total_Total_ReturnTotal(int total, IBehaviorProfileContext behaviorProfile)
 {
   //Arrange
   var behaviorProfileDecorator = new BehaviorProfileDecorator(null, behaviorProfile);
   behaviorProfile.Total.Returns(total);
   //Assert
   behaviorProfileDecorator.Total.Should().Be(total);
 }
Exemple #10
0
        public void Total_Total_ReturnTotal(int total, IBehaviorProfileContext behaviorProfile)
        {
            //Arrange
            var behaviorProfileDecorator = new BehaviorProfileDecorator(null, behaviorProfile);

            behaviorProfile.Total.Returns(total);
            //Assert
            behaviorProfileDecorator.Total.Should().Be(total);
        }
    public void Indexer_NullProfileKey_ReturnZero([Content]Item profileItem, IBehaviorProfileContext behaviorProfile)
    {
      //Arrange
      var profile = new ProfileItem(profileItem);

      var behaviorProfileDecorator = new BehaviorProfileDecorator(profile, behaviorProfile);
      //Assert
      behaviorProfileDecorator["profileKey"].Should().Be(0);
    }
Exemple #12
0
        public void Indexer_NullProfileKey_ReturnZero([Content] Item profileItem, IBehaviorProfileContext behaviorProfile)
        {
            //Arrange
            var profile = new ProfileItem(profileItem);

            var behaviorProfileDecorator = new BehaviorProfileDecorator(profile, behaviorProfile);

            //Assert
            behaviorProfileDecorator["profileKey"].Should().Be(0);
        }
 public void Scores_ShouldReturnFromContext(IBehaviorProfileContext ctx, float value, [Content] Item ctxItem)
 {
   var score = new KeyValuePair<ID, float>(ctxItem.ID, value);
   ctx.Scores.Returns(new [] { score });
   var model = new BehaviorProfile(ctx);
   model.Scores.Count().Should().Be(1);
   model.Scores.First().Id.Should().Be(score.Key.Guid);
   model.Scores.First().Value.Should().Be(score.Value);
   model.Scores.First().Name.Should().Be(ctxItem.DisplayName);
 }
Exemple #14
0
 private static ExtraBehaviorProfileContext CreateExtraBehaviorProfileContext(IBehaviorProfileContext profile)
 {
     return(new ExtraBehaviorProfileContext
     {
         Id = profile.Id,
         NumberOfTimesScored = profile.NumberOfTimesScored,
         Scores = profile.Scores,
         PatternId = profile.PatternId,
         ProfileName = Context.Database.GetItem(profile.Id).Name,
         PatternName = (!ID.IsNullOrEmpty(profile.PatternId)) ? Context.Database.GetItem(profile.PatternId).Name : ""
     });
 }
Exemple #15
0
        public void Scores_ShouldReturnFromContext(IBehaviorProfileContext ctx, float value, [Content] Item ctxItem)
        {
            var score = new KeyValuePair <ID, float>(ctxItem.ID, value);

            ctx.Scores.Returns(new [] { score });
            var model = new BehaviorProfile(ctx);

            model.Scores.Count().Should().Be(1);
            model.Scores.First().Id.Should().Be(score.Key.Guid);
            model.Scores.First().Value.Should().Be(score.Value);
            model.Scores.First().Name.Should().Be(ctxItem.DisplayName);
        }
 public BehaviorProfileDecorator(ProfileItem profile, IBehaviorProfileContext behaviorProfile)
 {
   this.profile = profile;
   this.behaviorProfile = behaviorProfile;
 }
Exemple #17
0
 public BehaviorProfile(IBehaviorProfileContext behaviorProfileContext)
 {
   this.behaviorProfileContext = behaviorProfileContext;
 }
Exemple #18
0
 public BehaviorProfile(IBehaviorProfileContext behaviorProfileContext)
 {
     this.behaviorProfileContext = behaviorProfileContext;
 }
Exemple #19
0
        public void GetEnumerator_Call_ReturnScoresWithKeyName(Db db, ID keyId1, ID keyId2, DbItem profileItem, IBehaviorProfileContext behaviorProfile)
        {
            //Arrange
            using (new SecurityDisabler())
            {
                profileItem.Add(new DbItem("Key1", keyId1, ProfileKeyItem.TemplateID)
                {
                    { ProfileKeyItem.FieldIDs.NameField, "key1name" }
                });
                profileItem.Add(new DbItem("Key2", keyId2, ProfileKeyItem.TemplateID)
                {
                    { ProfileKeyItem.FieldIDs.NameField, "key2name" }
                });

                db.Add(profileItem);

                var item    = db.GetItem(profileItem.FullPath);
                var profile = new ProfileItem(item);

                var behaviorScores = new List <KeyValuePair <ID, float> >()
                {
                    new KeyValuePair <ID, float>(keyId1, 10), new KeyValuePair <ID, float>(keyId2, 20)
                };
                behaviorProfile.Scores.Returns(behaviorScores);
                var behaviorProfileDecorator = new BehaviorProfileDecorator(profile, behaviorProfile);

                //Act
                var result = behaviorProfileDecorator.ToList();

                //Assert
                result.Should().BeEquivalentTo(new[] { new KeyValuePair <string, float>("key1name", 10), new KeyValuePair <string, float>("key2name", 20) });
            }
        }
Exemple #20
0
 public BehaviorProfileDecorator(ProfileItem profile, IBehaviorProfileContext behaviorProfile)
 {
     this.profile         = profile;
     this.behaviorProfile = behaviorProfile;
 }
Exemple #21
0
        public void GetCount_NumberOfTimesScored_ReturnNumberOfTimesScored(int numberOfTimesScored, IBehaviorProfileContext behaviorProfile)
        {
            //Arrange
            var behaviorProfileDecorator = new BehaviorProfileDecorator(null, behaviorProfile);

            behaviorProfile.NumberOfTimesScored.Returns(numberOfTimesScored);
            //Assert
            behaviorProfileDecorator.Count.Should().Be(numberOfTimesScored);
        }