Exemplo n.º 1
0
        public void Should_allow_knock_down_10_pins_as_max()
        {
            // Arrange
            var scorer = new Scorer();

            // Act && assert
            scorer.Invoking(s => s.Roll(11)).ShouldThrow<ArgumentException>()
                  .And.Message.Should().Be("Max number of available pins is 10");
        }
Exemplo n.º 2
0
 /// <summary>
 /// Construct a <code>DisjunctionScorer</code>. </summary>
 /// <param name="weight"> The weight to be used. </param>
 /// <param name="subScorers"> Array of at least two subscorers. </param>
 /// <param name="coord"> Table of coordination factors </param>
 internal DisjunctionSumScorer(Weight weight, Scorer[] subScorers, float[] coord)
     : base(weight, subScorers)
 {
     if (NumScorers <= 1)
     {
         throw new System.ArgumentException("There must be at least 2 subScorers");
     }
     this.Coord = coord;
 }
Exemplo n.º 3
0
		/// <summary> Creates a new instance of DisjunctionMaxScorer
		/// 
		/// </summary>
		/// <param name="tieBreakerMultiplier">Multiplier applied to non-maximum-scoring subqueries for a
		/// document as they are summed into the result.
		/// </param>
		/// <param name="similarity">-- not used since our definition involves neither coord nor terms
		/// directly
		/// </param>
		/// <param name="subScorers">The sub scorers this Scorer should iterate on
		/// </param>
		/// <param name="numScorers">The actual number of scorers to iterate on. Note that the array's
		/// length may be larger than the actual number of scorers.
		/// </param>
		public DisjunctionMaxScorer(float tieBreakerMultiplier, Similarity similarity, Scorer[] subScorers, int numScorers):base(similarity)
		{
			
			this.tieBreakerMultiplier = tieBreakerMultiplier;
			// The passed subScorers array includes only scorers which have documents
			// (DisjunctionMaxQuery takes care of that), and their nextDoc() was already
			// called.
			this.subScorers = subScorers;
			this.numScorers = numScorers;
			
			Heapify();
		}
Exemplo n.º 4
0
        public void Robbie_State_Change_Hash_Code_Remains_Constant()
        {
            IDictionary<Situation, RobotAction> strategy = GetSimpleStrategy(RobotAction.PickUpCan);
            Scorer scorer = new Scorer();
            Robot robbie = new Robot(strategy, scorer);
            var startingHashCode = robbie.GetHashCode();

            robbie._scorer.Add(Robot.ActionResult.HitWall);

            var endingHashCode = robbie.GetHashCode();

            Assert.AreEqual(startingHashCode, endingHashCode);
        }
Exemplo n.º 5
0
        public void Should_allow_addtional_20Th_roll_if_there_are_strike_in_the_last_frame_and_one_strike_before()
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            scorer.Roll(10);
            for (int i = 0; i < 17; i++)
            {
                scorer.Roll(0);
            }
            scorer.Roll(10);
            scorer.Roll(0);

            // Assert
            scorer.Invoking(s => s.Roll(1)).ShouldThrow<MaxNumberOfRollsExceededException>();
        }
Exemplo n.º 6
0
        public void Should_allow_aditional_roll_if_spare_in_the_last_frame()
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            for (int i = 0; i < 18; i++)
            {
                scorer.Roll(0);
            }
            scorer.Roll(1);
            scorer.Roll(9);
            scorer.Roll(9);
            var score = scorer.CalculateScore();

            // Assert
            score.Should().Be(19);
        }
Exemplo n.º 7
0
        private double[] _stepSize; // size of the step for each value in _data

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="net">Network to perform hill climbing algorithm on.</param>
        /// <param name="score">Scoring object.</param>
        /// <param name="accel">Acceleration of step sizes.</param>
        /// <param name="stepSize">Initial step sizes.</param>
        public HillClimb(Network net, Scorer score, double accel, double stepSize)
        {
            _net = net;
            _scorer = score;
            _stepSize = new double[net.LongTermMemory.Length];

            for (int i = 0; i < _stepSize.Length; i++) {
                _stepSize[i] = stepSize;
            }

            _candidate[0] = -accel;
            _candidate[1] = -(1/accel);
            _candidate[2] = 0;
            _candidate[3] = 1/accel;
            _candidate[4] = accel;

            _lastError = double.MaxValue;
        }
Exemplo n.º 8
0
		/// <summary>Returns the score of the current document matching the query.
		/// Initially invalid, until <see cref="NextDoc()" /> is called the first time.
		/// </summary>
		/// <returns> The score of the required scorer, eventually increased by the score
		/// of the optional scorer when it also matches the current document.
		/// </returns>
		public override float Score()
		{
			int curDoc = reqScorer.DocID();
			float reqScore = reqScorer.Score();
			if (optScorer == null)
			{
				return reqScore;
			}
			
			int optScorerDoc = optScorer.DocID();
			if (optScorerDoc < curDoc && (optScorerDoc = optScorer.Advance(curDoc)) == NO_MORE_DOCS)
			{
				optScorer = null;
				return reqScore;
			}
			
			return optScorerDoc == curDoc?reqScore + optScorer.Score():reqScore;
		}
Exemplo n.º 9
0
		public override int NextDoc()
		{
			if (reqScorer == null)
			{
				return doc;
			}
			doc = reqScorer.NextDoc();
			if (doc == NO_MORE_DOCS)
			{
				reqScorer = null; // exhausted, nothing left
				return doc;
			}
			if (exclDisi == null)
			{
				return doc;
			}
			return doc = ToNonExcluded();
		}
Exemplo n.º 10
0
		/// <summary>Advance to non excluded doc.
		/// <br/>On entry:
		/// <list type="bullet">
		/// <item>reqScorer != null, </item>
		/// <item>exclScorer != null, </item>
		/// <item>reqScorer was advanced once via next() or skipTo() 
        /// and reqScorer.doc() may still be excluded.</item>
		/// </list>
		/// Advances reqScorer a non excluded required doc, if any.
		/// </summary>
		/// <returns> true iff there is a non excluded required doc.
		/// </returns>
		private int ToNonExcluded()
		{
			int exclDoc = exclDisi.DocID();
			int reqDoc = reqScorer.DocID(); // may be excluded
			do 
			{
				if (reqDoc < exclDoc)
				{
					return reqDoc; // reqScorer advanced to before exclScorer, ie. not excluded
				}
				else if (reqDoc > exclDoc)
				{
					exclDoc = exclDisi.Advance(reqDoc);
					if (exclDoc == NO_MORE_DOCS)
					{
						exclDisi = null; // exhausted, no more exclusions
						return reqDoc;
					}
					if (exclDoc > reqDoc)
					{
						return reqDoc; // not excluded
					}
				}
			}
			while ((reqDoc = reqScorer.NextDoc()) != NO_MORE_DOCS);
			reqScorer = null; // exhausted, nothing left
			return NO_MORE_DOCS;
		}
Exemplo n.º 11
0
		/// <summary>Construct a <c>ReqExclScorer</c>.</summary>
		/// <param name="reqScorer">The scorer that must match, except where
		/// </param>
		/// <param name="exclDisi">indicates exclusion.
		/// </param>
		public ReqExclScorer(Scorer reqScorer, DocIdSetIterator exclDisi):base(null)
		{ // No similarity used.
			this.reqScorer = reqScorer;
			this.exclDisi = exclDisi;
		}
 public DoubleDocValuesAnonymousInnerClassHelper(ScoreValueSource outerInstance, Scorer scorer)
     : base(outerInstance)
 {
     this.outerInstance = outerInstance;
     this.scorer = scorer;
 }
Exemplo n.º 13
0
        public void Should_Score_Category_ThreeOfAKind()
        {
            var scorer = new Scorer();

            Assert.AreEqual(3, scorer.Score("ThreeOfAKind", new[] { 1, 1, 1, 8, 8 }));
        }
Exemplo n.º 14
0
        public void Should_sum_two_subsequent_rolls(
			int firstRoll,
			int secondRoll,
			int total)
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            scorer.Roll(firstRoll);
            scorer.Roll(secondRoll);
            var score = scorer.CalculateScore();

            // Assert
            Assert.AreEqual(total, score);
        }
Exemplo n.º 15
0
        public void Should_not_allow_to_knock_down_negative_number_of_pins()
        {
            // Arrange
            var scorer = new Scorer();

            // Act && Assert
            scorer.Invoking(s => s.Roll(-1)).ShouldThrow<ArgumentException>()
                  .And.Message.Should().Be("Number of pins cannot be negative");
        }
Exemplo n.º 16
0
        public void Should_Score_Category_FourOfAKind()
        {
            var scorer = new Scorer();

            Assert.AreEqual(4, scorer.Score("FourOfAKind", new[] { 1, 1, 1, 1, 8 }));
        }
Exemplo n.º 17
0
 public Highlighter(Formatter formatter, Scorer fragmentScorer)
     : this(formatter, new DefaultEncoder(), fragmentScorer)
 {
 }
Exemplo n.º 18
0
 public Highlighter(Scorer fragmentScorer)
     : this(new SimpleHTMLFormatter(), fragmentScorer)
 {
 }
Exemplo n.º 19
0
 public void CallBefore()
 {
     _scorer = new Scorer(_player);
 }
Exemplo n.º 20
0
 /// <summary>Construct a <c>ReqExclScorer</c>.</summary>
 /// <param name="reqScorer">The scorer that must match, except where
 /// </param>
 /// <param name="exclDisi">indicates exclusion.
 /// </param>
 public ReqExclScorer(Scorer reqScorer, DocIdSetIterator exclDisi) : base(null)
 {         // No similarity used.
     this.reqScorer = reqScorer;
     this.exclDisi  = exclDisi;
 }
Exemplo n.º 21
0
        public virtual void Search(Weight weight, Filter filter, ICollector collector, int start, IBoboMapFunctionWrapper mapReduceWrapper)
        {
            FacetValidator validator = CreateFacetValidator();
            int            target    = 0;

            IndexReader        reader             = this.IndexReader;
            IndexReaderContext indexReaderContext = reader.Context;

            if (filter == null)
            {
                for (int i = 0; i < m_subReaders.Length; i++)
                {
                    AtomicReaderContext atomicContext = indexReaderContext.Children == null
                        ? (AtomicReaderContext)indexReaderContext
                        : (AtomicReaderContext)(indexReaderContext.Children.Get(i));
                    int docStart = start;

                    // NOTE: This code calls an internal constructor. Apparently, this was in the same namespace as Lucene,
                    // but was added to this project, which presumably allows you to call internal constructors in Java.
                    // In .NET, we can just use Activator.CreateInstance. Not great, but this code will be removed
                    // when applying commit https://github.com/senseidb/bobo/commit/924c8579d90dbb5d56103976d39b47daa2242ef3
                    // which includes several major changes after the 4.0.2 release.

                    // atomicContext = AtomicReaderContextUtil.UpdateDocBase(atomicContext, docStart);
                    object[] args = new object[] { (CompositeReaderContext)null, atomicContext.AtomicReader, 0, 0, 0, docStart };
                    Type[]   constructorSignature = { typeof(CompositeReaderContext), typeof(AtomicReader), typeof(int), typeof(int), typeof(int), typeof(int) };
                    var      constr = typeof(AtomicReaderContext).GetTypeInfo().DeclaredConstructors
                                      .Single(constructor =>
                                              constructor.GetParameters()
                                              .Select(parameter => parameter.ParameterType)
                                              .SequenceEqual(constructorSignature));
                    atomicContext = (AtomicReaderContext)constr.Invoke(args);

                    if (reader is BoboMultiReader)
                    {
                        docStart = start + ((BoboMultiReader)reader).SubReaderBase(i);
                    }
                    collector.SetNextReader(atomicContext);
                    validator.SetNextReader(m_subReaders[i], docStart);

                    // NOTE: The Weight.Scorer method lost the scoreDocsInOrder and topScorer parameters between
                    // Lucene 4.3.0 and 4.8.0. They are not used by BoboBrowse anyway, so the code here diverges
                    // from the original Java source to remove these two parameters.

                    // Scorer scorer = weight.Scorer(atomicContext, true, true, _subReaders[i].LiveDocs);
                    Scorer scorer = weight.GetScorer(atomicContext, m_subReaders[i].LiveDocs);
                    if (scorer != null)
                    {
                        collector.SetScorer(scorer);
                        target = scorer.NextDoc();
                        while (target != DocIdSetIterator.NO_MORE_DOCS)
                        {
                            if (validator.Validate(target))
                            {
                                collector.Collect(target);
                                target = scorer.NextDoc();
                            }
                            else
                            {
                                target = validator.m_nextTarget;
                                target = scorer.Advance(target);
                            }
                        }
                    }
                    if (mapReduceWrapper != null)
                    {
                        mapReduceWrapper.MapFullIndexReader(m_subReaders[i], validator.GetCountCollectors());
                    }
                }
                return;
            }

            for (int i = 0; i < m_subReaders.Length; i++)
            {
                AtomicReaderContext atomicContext = indexReaderContext.Children == null
                        ? (AtomicReaderContext)indexReaderContext
                        : (AtomicReaderContext)(indexReaderContext.Children.Get(i));

                DocIdSet filterDocIdSet = filter.GetDocIdSet(atomicContext, m_subReaders[i].LiveDocs);
                if (filterDocIdSet == null)
                {
                    return;                          //shall we use return or continue here ??
                }
                int docStart = start;
                if (reader is BoboMultiReader)
                {
                    docStart = start + ((BoboMultiReader)reader).SubReaderBase(i);
                }
                collector.SetNextReader(atomicContext);
                validator.SetNextReader(m_subReaders[i], docStart);

                // NOTE: The Weight.Scorer method lost the scoreDocsInOrder and topScorer parameters between
                // Lucene 4.3.0 and 4.8.0. They are not used by BoboBrowse anyway, so the code here diverges
                // from the original Java source to remove these two parameters.

                // Scorer scorer = weight.Scorer(atomicContext, true, false, _subReaders[i].LiveDocs);
                Scorer scorer = weight.GetScorer(atomicContext, m_subReaders[i].LiveDocs);
                if (scorer != null)
                {
                    collector.SetScorer(scorer);
                    DocIdSetIterator filterDocIdIterator = filterDocIdSet.GetIterator(); // CHECKME: use ConjunctionScorer here?

                    if (filterDocIdIterator == null)
                    {
                        continue;
                    }

                    int doc = -1;
                    target = filterDocIdIterator.NextDoc();
                    if (mapReduceWrapper == null)
                    {
                        while (target < DocIdSetIterator.NO_MORE_DOCS)
                        {
                            if (doc < target)
                            {
                                doc = scorer.Advance(target);
                            }

                            if (doc == target) // permitted by filter
                            {
                                if (validator.Validate(doc))
                                {
                                    collector.Collect(doc);

                                    target = filterDocIdIterator.NextDoc();
                                }
                                else
                                {
                                    // skip to the next possible docid
                                    target = filterDocIdIterator.Advance(validator.m_nextTarget);
                                }
                            }
                            else // doc > target
                            {
                                if (doc == DocIdSetIterator.NO_MORE_DOCS)
                                {
                                    break;
                                }
                                target = filterDocIdIterator.Advance(doc);
                            }
                        }
                    }
                    else
                    {
                        //MapReduce wrapper is not null
                        while (target < DocIdSetIterator.NO_MORE_DOCS)
                        {
                            if (doc < target)
                            {
                                doc = scorer.Advance(target);
                            }

                            if (doc == target) // permitted by filter
                            {
                                if (validator.Validate(doc))
                                {
                                    mapReduceWrapper.MapSingleDocument(doc, m_subReaders[i]);
                                    collector.Collect(doc);

                                    target = filterDocIdIterator.NextDoc();
                                }
                                else
                                {
                                    // skip to the next possible docid
                                    target = filterDocIdIterator.Advance(validator.m_nextTarget);
                                }
                            }
                            else // doc > target
                            {
                                if (doc == DocIdSetIterator.NO_MORE_DOCS)
                                {
                                    break;
                                }
                                target = filterDocIdIterator.Advance(doc);
                            }
                        }
                        mapReduceWrapper.FinalizeSegment(m_subReaders[i], validator.GetCountCollectors());
                    }
                }
            }
        }
Exemplo n.º 22
0
        public void Should_Score_Category_NoneOfAKind()
        {
            var scorer = new Scorer();

            Assert.AreEqual(40, scorer.Score("NoneOfAKind", new[] { 1, 2, 3, 4, 5 }));
        }
Exemplo n.º 23
0
        public void Should_Score_Category_AllOfAKind()
        {
            var scorer = new Scorer();

            Assert.AreEqual(50, scorer.Score("AllOfAKind", new[] { 1, 1, 1, 1, 1 }));
        }
Exemplo n.º 24
0
		public Highlighter(Formatter formatter, Scorer fragmentScorer) : this(formatter, new DefaultEncoder(), fragmentScorer)
		{
		}
Exemplo n.º 25
0
		public Highlighter(Formatter formatter, Encoder encoder, Scorer fragmentScorer)
		{
			this.formatter = formatter;
			this.encoder = encoder;
			this.fragmentScorer = fragmentScorer;
		}
Exemplo n.º 26
0
 public Highlighter(Formatter formatter, Encoder encoder, Scorer fragmentScorer)
 {
     this.formatter      = formatter;
     this.encoder        = encoder;
     this.fragmentScorer = fragmentScorer;
 }
Exemplo n.º 27
0
 private void InitializeScorer()
 {
     var scorer = new Scorer(this, "fonts/Segoe");
     AddComponent(scorer, "Sprites");
 }
Exemplo n.º 28
0
 /// <param name="">scorer
 /// </param>
 public virtual void SetFragmentScorer(Scorer scorer)
 {
     fragmentScorer = scorer;
 }
Exemplo n.º 29
0
        public void Should_return_300_for_the_perfect_game()
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            for (int i = 0; i < 12; i++)
            {
                scorer.Roll(10);
            }
            var score = scorer.CalculateScore();

            // Assert
            score.Should().Be(300);
        }
Exemplo n.º 30
0
 internal HeapedScorerDoc(ScorerDocQueue enclosingInstance, Scorer s) : this(enclosingInstance, s, s.DocID())
 {
 }
Exemplo n.º 31
0
        public void Should_Score_Category_Fours()
        {
            var scorer = new Scorer();

            Assert.AreEqual(16, scorer.Score("Fours", new[] { 4, 4, 4, 4, 3 }));
        }
Exemplo n.º 32
0
 internal HeapedScorerDoc(ScorerDocQueue enclosingInstance, Scorer scorer, int doc)
 {
     InitBlock(enclosingInstance);
     this.scorer = scorer;
     this.doc    = doc;
 }
Exemplo n.º 33
0
        public void Should_Score_Category_Fives()
        {
            var scorer = new Scorer();

            Assert.AreEqual(10, scorer.Score("Fives", new[] { 4, 4, 4, 5, 5 }));
        }
Exemplo n.º 34
0
 /// <summary> Adds a Scorer to a ScorerDocQueue in log(size) time.
 /// If one tries to add more Scorers than maxSize
 /// a RuntimeException (ArrayIndexOutOfBound) is thrown.
 /// </summary>
 public void  Put(Scorer scorer)
 {
     size++;
     heap[size] = new HeapedScorerDoc(this, scorer);
     UpHeap();
 }
Exemplo n.º 35
0
		public override int Advance(int target)
		{
			if (reqScorer == null)
			{
				return doc = NO_MORE_DOCS;
			}
			if (exclDisi == null)
			{
				return doc = reqScorer.Advance(target);
			}
			if (reqScorer.Advance(target) == NO_MORE_DOCS)
			{
				reqScorer = null;
				return doc = NO_MORE_DOCS;
			}
			return doc = ToNonExcluded();
		}
Exemplo n.º 36
0
 internal SingleMatchScorer(BooleanScorer2 enclosingInstance, Scorer scorer) : base(scorer.Similarity)
 {
     InitBlock(enclosingInstance);
     this.scorer = scorer;
 }
 public virtual void SetScorer(Scorer scorer)
 {
     m_in.SetScorer(scorer);
 }
 public DoubleDocValuesAnonymousInnerClassHelper(ValueSourceAnonymousInnerClassHelper outerInstance, Scorer scorer)
     : base(null) //todo: value source
 {
     this.outerInstance = outerInstance;
     this.scorer        = scorer;
 }
Exemplo n.º 39
0
		public Highlighter(Scorer fragmentScorer) : this(new SimpleHTMLFormatter(), fragmentScorer)
		{
		}
Exemplo n.º 40
0
		/// <summary> Creates a <see cref="Scorer" /> with the given similarity and lists of required,
		/// prohibited and optional scorers. In no required scorers are added, at least
		/// one of the optional scorers will have to match during the search.
		/// 
		/// </summary>
		/// <param name="similarity">The similarity to be used.
		/// </param>
		/// <param name="minNrShouldMatch">The minimum number of optional added scorers that should match
		/// during the search. In case no required scorers are added, at least
		/// one of the optional scorers will have to match during the search.
		/// </param>
		/// <param name="required">the list of required scorers.
		/// </param>
		/// <param name="prohibited">the list of prohibited scorers.
		/// </param>
		/// <param name="optional">the list of optional scorers.
		/// </param>
		public BooleanScorer2(Similarity similarity, int minNrShouldMatch, 
                                System.Collections.Generic.List<Scorer> required,
                                System.Collections.Generic.List<Scorer> prohibited,
                                System.Collections.Generic.List<Scorer> optional)
            : base(similarity)
		{
			if (minNrShouldMatch < 0)
			{
				throw new System.ArgumentException("Minimum number of optional scorers should not be negative");
			}
			coordinator = new Coordinator(this);
			this.minNrShouldMatch = minNrShouldMatch;
			
			optionalScorers = optional;
			coordinator.maxCoord += optional.Count;
			
			requiredScorers = required;
			coordinator.maxCoord += required.Count;
			
			prohibitedScorers = prohibited;
			
			coordinator.Init();
			countingSumScorer = MakeCountingSumScorer();
		}
Exemplo n.º 41
0
		/// <param name="">scorer
		/// </param>
		public virtual void  SetFragmentScorer(Scorer scorer)
		{
			fragmentScorer = scorer;
		}
Exemplo n.º 42
0
		private Scorer DualConjunctionSumScorer(Scorer req1, Scorer req2)
		{
			// non counting.
			return new ConjunctionScorer(defaultSimilarity, new Scorer[]{req1, req2});
			// All scorers match, so defaultSimilarity always has 1 as
			// the coordination factor.
			// Therefore the sum of the scores of two scorers
			// is used as score.
		}
Exemplo n.º 43
0
 public CustomScorer(BoostedQuery outerInstance, AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight, Scorer scorer, ValueSource vs)
     : base(w)
 {
     this.outerInstance = outerInstance;
     this.weight        = w;
     this.qWeight       = qWeight;
     this.scorer        = scorer;
     this.readerContext = readerContext;
     this.vals          = vs.GetValues(weight.fcontext, readerContext);
 }
Exemplo n.º 44
0
        public void Should_Score_Category_Ones()
        {
            var scorer = new Scorer();

            Assert.AreEqual(3, scorer.Score("Ones", new[] { 1, 1, 1, 2, 2 }));
        }
Exemplo n.º 45
0
			internal SingleMatchScorer(BooleanScorer2 enclosingInstance, Scorer scorer):base(scorer.Similarity)
			{
				InitBlock(enclosingInstance);
				this.scorer = scorer;
			}
Exemplo n.º 46
0
 public override void SetScorer(Scorer scorer)
 {
 }
Exemplo n.º 47
0
		/// <summary>Returns the scorer to be used for match counting and score summing.
		/// Uses the given required scorer and the prohibitedScorers.
		/// </summary>
		/// <param name="requiredCountingSumScorer">A required scorer already built.
		/// </param>
		private Scorer AddProhibitedScorers(Scorer requiredCountingSumScorer)
		{
			return (prohibitedScorers.Count == 0) 
                   ? requiredCountingSumScorer
                   : new ReqExclScorer(requiredCountingSumScorer, 
                                       ((prohibitedScorers.Count == 1)
                                        ? prohibitedScorers[0]
                                        : new DisjunctionSumScorer(prohibitedScorers)));
		}
Exemplo n.º 48
0
 public override sealed void SetScorer(Scorer scorer)
 {
     this.scorer = scorer;
 }
Exemplo n.º 49
0
        public void Should_allow_only_20_rolls()
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            for (int i = 0; i < 20; i++)
            {
                scorer.Roll(1);
            }

            // Assert
            scorer.Invoking(s => s.Roll(1)).ShouldThrow<MaxNumberOfRollsExceededException>("sdf")
                  .And.Message.Should().Be("Maximum number of rolls exceeded", "Message should be meaningful");
        }
Exemplo n.º 50
0
 public virtual void SetScorer(Scorer scorer)
 {
 }
Exemplo n.º 51
0
        public void Should_return_0_if_no_rolls()
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            int score = scorer.CalculateScore();

            // Assert
            Assert.AreEqual(0, score);
        }
Exemplo n.º 52
0
        public void Should_Score_Category_Sevens()
        {
            var scorer = new Scorer();

            Assert.AreEqual(21, scorer.Score("Sevens", new[] { 7, 7, 7, 3, 3 }));
        }
Exemplo n.º 53
0
        public void Should_sum_one_subsequent_roll_if_spare(
			int first,
			int second,
			int third,
			int total)
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            scorer.Roll(first);
            scorer.Roll(second);
            scorer.Roll(third);
            var score = scorer.CalculateScore();

            // Assert
            score.Should().Be(total);
        }
Exemplo n.º 54
0
        public void Should_Score_Category_Sixes()
        {
            var scorer = new Scorer();

            Assert.AreEqual(6, scorer.Score("Sixes", new[] { 6, 4, 4, 4, 3 }));
        }
Exemplo n.º 55
0
        public void Should_sum_two_subsequent_rolls_if_strike(int[] rolls, int total)
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            foreach (int pins in rolls)
            {
                scorer.Roll(pins);
            }
            var score = scorer.CalculateScore();

            // Assert
            score.Should().Be(total);
        }
Exemplo n.º 56
0
        private string ActualPoints(NFLPlayer p)
        {
            var nScore = Scorer.RatePlayer(p, NflWeek);

            return(nScore.ToString());
        }
Exemplo n.º 57
0
 public virtual void SetScorer(Scorer scorer)
 {
     this.scorer = scorer;
 }
Exemplo n.º 58
0
        public void Should_Score_Category_Eights()
        {
            var scorer = new Scorer();

            Assert.AreEqual(24, scorer.Score("Eights", new[] { 7, 7, 8, 8, 8 }));
        }
Exemplo n.º 59
0
        public void Should_allow_only_19_rolls_if_strike_is_not_in_the_last_frame()
        {
            // Arrange
            var scorer = new Scorer();

            // Act
            scorer.Roll(10);
            for (int i = 0; i < 18; i++)
            {
                scorer.Roll(2);
            }

            // Assert
            scorer.Invoking(r => r.Roll(1)).ShouldThrow<MaxNumberOfRollsExceededException>();
        }
Exemplo n.º 60
0
 public override void SetScorer(Scorer scorer)
 {
     _scorer = scorer;
 }