コード例 #1
0
ファイル: RuleEngineTest.cs プロジェクト: graylikeme/CodeRoom
 public void Rank_RuleEngineGotNoRules_ThorwsException()
 {
     var rules = new IRule[] {}; // TODO: Initialize to an appropriate value
     var target = new RuleEngine(rules); // TODO: Initialize to an appropriate value
     Snippet snippet = null; // TODO: Initialize to an appropriate value
     target.Rank(snippet);
 }
コード例 #2
0
ファイル: RuleEngineTest.cs プロジェクト: arielbh/CodeRoom
 public void Rank_RuleEngineGotNoRules_ThorwsException()
 {
     IRule[] rules = new IRule[] {}; // TODO: Initialize to an appropriate value
     RuleEngine target = new RuleEngine(rules); // TODO: Initialize to an appropriate value
     Snippet snippet = null; // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.Rank(snippet);
 }
コード例 #3
0
ファイル: RuleEngineTest.cs プロジェクト: graylikeme/CodeRoom
        public void Rank_RuleEngineGotOneRule_ShouldReturnMultiplicationOfSpecifiedRankAndWeight()
        {
            int rank = 42;
            double weight = 3;

            var ruleRank = new Mock<IRule>();
            ruleRank.Setup(m => m.Rank(It.IsAny<Snippet>())).Returns(rank);
            ruleRank.SetupGet(m => m.Weight).Returns(weight);

            var rules = new IRule[] { ruleRank.Object };
            var target = new RuleEngine(rules);
            Snippet snippet = null;

            int actual = target.Rank(snippet);

            Assert.AreEqual(rank * weight, actual);
        }
コード例 #4
0
ファイル: RuleEngineTest.cs プロジェクト: graylikeme/CodeRoom
        public void Rank_RuleEngineGotTwoRules_ShouldReturnAggregatedMultiplicationOfSpecifiedRankAndWeight()
        {
            int rank1 = 42;
            double weight1 = 3;

            int rank2 = 10;
            double weight2 = 30;

            double expectedValue = rank1*weight1 + rank2*weight2;

            Mock<IRule> ruleRank1 = GetRuleRank(rank1, weight1);
            Mock<IRule> ruleRank2 = GetRuleRank(rank2, weight2);

            var rules = new[] { ruleRank1.Object, ruleRank2.Object };
            var target = new RuleEngine(rules);

            Snippet snippet = null;
            int actual = target.Rank(snippet);

            Assert.AreEqual(expectedValue, actual);
        }
コード例 #5
0
ファイル: RuleEngineTest.cs プロジェクト: arielbh/CodeRoom
        public void Rank_RuleEngineGotTwoRules_ShouldReturnAggregatedMultiplicationOfSpecifiedRankAndWeight()
        {
            int rank1 = 42;
            double weight1 = 3;

            int rank2 = 10;
            double weight2 = 30;

            var ruleRank = new Mock<IRule>();
            ruleRank.Setup(m => m.Rank(It.IsAny<Snippet>())).Returns(rank1);
            ruleRank.SetupGet(m => m.Weight).Returns(weight1);

            IRule[] rules = new IRule[] { ruleRank.Object };
            RuleEngine target = new RuleEngine(rules);
            Snippet snippet = null;
            int actual;
            actual = target.Rank(snippet);

            Assert.AreEqual(rank * weight, actual);
        }