Ejemplo n.º 1
0
        public MathEquation GenerateEquation()
        {
            var oneSide   = _randomGenerator.Int(0, 10);
            var otherSide = _randomGenerator.Int(0, 10);
            var @operator = GetOperator(_randomGenerator.Double());

            var actualResult    = Math.Round(GetResult(oneSide, otherSide, @operator), 1);
            var useActualResult = _randomGenerator.Bool();

            double shownResult;

            if (useActualResult)
            {
                shownResult = actualResult;
            }
            else
            {
                shownResult = Math.Round(GenerateProbableResult(@operator, actualResult), 0);
            }

            var equationString = GetEquationString(oneSide, otherSide, shownResult, @operator);

            return(new MathEquation(equationString, new[] { actualResult }, shownResult, ANSWER_TOLERANCE));
        }
Ejemplo n.º 2
0
        public ExtensibileRandomValuePropertyNamerTests()
        {
            builderSettings = new BuilderSettings();

            randomGenerator = Substitute.For <IRandomGenerator>();
            target          = new ExtensibleRandomValuePropertyNamer(randomGenerator, builderSettings);

            bool    @bool    = true;
            byte    @byte    = 1;
            char    @char    = 'a';
            var     dateTime = new DateTime(2009, 01, 01);
            decimal @decimal = 1m;
            double  @double  = 1d;
            float   @float   = 1f;
            Guid    guid     = new Guid();
            int     @int     = 2;
            long    @long    = 3;
            string  phrase   = "some text";
            sbyte   @sbyte   = 4;
            short   @short   = 5;
            uint    @uint    = 6;
            ulong   @ulong   = 7;
            ushort  @ushort  = 8;
            MyEnum  @enum    = MyEnum.EnumValue3;


            {
                randomGenerator.Boolean().Returns(@bool);
                randomGenerator.Byte().Returns(@byte);
                randomGenerator.Char().Returns(@char);
                randomGenerator.DateTime().Returns(dateTime);
                randomGenerator.Decimal().Returns(@decimal);
                randomGenerator.Double().Returns(@double);
                randomGenerator.Float().Returns(@float);
                randomGenerator.Guid().Returns(guid);
                randomGenerator.Int().Returns(@int);
                randomGenerator.Long().Returns(@long);
                randomGenerator.Phrase(50).Returns(@phrase);
                randomGenerator.SByte().Returns(@sbyte);
                randomGenerator.Short().Returns(@short);
                randomGenerator.UInt().Returns(@uint);
                randomGenerator.ULong().Returns(@ulong);
                randomGenerator.UShort().Returns(@ushort);
                randomGenerator.Enumeration(typeof(MyEnum)).Returns(@enum);
            }
        }
Ejemplo n.º 3
0
 public static double Double()
 {
     return(generator.Double());
 }
Ejemplo n.º 4
0
 public void ShouldBeAbleToGenerateDouble()
 {
     randomGenerator.Double();
 }