Beispiel #1
0
        public void CopyPossibleResult()
        {
            int givenValue = 25;
            var theResult  = new PossibleResult(givenValue);
            var myOutcome1 = new ChangeInTrust(1, new Role("one"), new Role("two"), "myOutcome1");
            var myOutcome2 = new ChangeInTrust(1, new Role("two"), new Role("one"), "myOutcome2");

            theResult.TheOutcomes.Add(myOutcome1);
            theResult.TheOutcomes.Add(myOutcome2);

            var altRole1        = new Role("three");
            var altRole2        = new Role("four");
            var replacementList = new List <Role>(2)
            {
                altRole1, altRole2
            };

            var theCopy = theResult.Copy(replacementList);

            Assert.AreEqual(theResult.ProbabilityScore, theCopy.ProbabilityScore);
            Assert.AreEqual(theResult.TheOutcomes.Count, theCopy.TheOutcomes.Count);

            var copyOutcome1 = theCopy.TheOutcomes.First() as ChangeInTrust;

            Assert.AreEqual(myOutcome1.OutcomeName, copyOutcome1.OutcomeName);
            Assert.AreEqual(myOutcome1.Magnitude, copyOutcome1.Magnitude);
            Assert.AreNotEqual(myOutcome1.BeingChanged, copyOutcome1.BeingChanged);
            Assert.AreNotEqual(myOutcome1.Towards, copyOutcome1.Towards);
        }
Beispiel #2
0
        public void ConstructPossibleResult_Successful()
        {
            int givenValue = 25;
            var theResult  = new PossibleResult(givenValue);

            Assert.AreEqual(givenValue, theResult.ProbabilityScore);
            Assert.IsNotNull(theResult.TheOutcomes);
        }
Beispiel #3
0
        private string TryToFindAnswer(int termCount, int previousTermCount)
        {
            SortedList <long, long> pentagonal = Shared.GetSortedPentagonalList(termCount + 2);

            PossibleResult bestSoFar = new PossibleResult(0, pentagonal.Keys[termCount]);
            PossibleResult noFind    = new PossibleResult(0, pentagonal.Keys[termCount]);

            int combinedSlot = previousTermCount;

            while (combinedSlot < termCount)
            {
                for (int lowSlot = combinedSlot / 2; lowSlot >= 0; lowSlot--)
                {
                    int highSlot = combinedSlot - lowSlot;

                    long pA = pentagonal.Keys[lowSlot];
                    long pB = pentagonal.Keys[highSlot];

                    if (pB - pA > bestSoFar.score)
                    {
                        break;
                    }
                    if (pentagonal.ContainsKey(pB - pA))
                    {
                        if (pentagonal.ContainsKey(pB + pA))
                        {
                            if (pB - pA < bestSoFar.score)
                            {
                                bestSoFar = new PossibleResult(pA, pB);
                            }
                        }
                    }
                }

                if (pentagonal.Keys[combinedSlot + 1] - pentagonal.Keys[combinedSlot] > bestSoFar.score)
                {
                    if (bestSoFar.score == noFind.score)
                    {
                        return("");
                    }
                    return(bestSoFar.score.ToString());
                }

                combinedSlot++;
            }
            if (bestSoFar.score == noFind.score)
            {
                return("");
            }
            return(bestSoFar.score.ToString());
        }
Beispiel #4
0
 private static object Result(decimal value)
 {
     return(Evt("ResultGenerated", PossibleResult <decimal> .Of(value)));
 }
Beispiel #5
0
 private static object Done()
 {
     return(Evt("ResultGenerated", PossibleResult <decimal> .Done()));
 }