public void GherkinFeatureMustHaveScenariosExpectException()
        {
            var dependency = TestDouble.Dummy <IGherkinFeature>();
            var options    = TestDouble.Dummy <ISpockOptions>();

            Assert.Throws <GherkinException>(() => Lexer.For(options).Parse(dependency));
        }
Example #2
0
        public static T BindDummy <T>(this IFixtureKernel kernel)
            where T : class
        {
            var result = TestDouble.For <T>().Dummy();

            kernel.Bind(result);
            return(result);
        }
Example #3
0
        public static ITestSpy <T, TIndirectOutput> ReplaceWithTestSpy <T, TIndirectOutput>(
            this IFixtureKernel kernel,
            Expression <Action <T> > expression)
            where T : class
            where TIndirectOutput : class
        {
            var result = TestDouble.Spy <T, TIndirectOutput>(expression);

            kernel.Bind(result.Dependency);
            return(result);
        }
Example #4
0
        public static ISaboteurVerify <T> ReplaceWithSaboteur <T, TException>(
            this IFixtureKernel kernel,
            Expression <Action <T> > expression)
            where T : class
            where TException : Exception, new()
        {
            var result = TestDouble.For <T>().Verifiable.Saboteur <TException>(expression);

            kernel.Bind(result.Dependency);
            return(result);
        }
Example #5
0
        /// <summary>
        /// Loads the specified bindings into the kernel.
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        public void Load(IFixtureKernel kernel)
        {
// ReSharper disable once RedundantBoolCompare
            kernel.Bind(TestDouble.Stub <ISpockOptions>(o => o.TestRunner == this.testRunner && o.SetIgnore == true));
            kernel.BindDummy <IFixtureInvariants>();
            kernel.BindDummy <IGherkinBlock>();

            kernel.Bind <IMethods, ScenarioMethods>();
            kernel.Bind <IBuilder <IFixtureMethods>, FixtureMethodBuilder>();

            kernel.Bind(ctx => ctx.Get <FixtureMethodBuilder>().Build());
        }
Example #6
0
 public bool Equals(TestObject other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(TestBoolean.Equals(other.TestBoolean) && TestDouble.Equals(other.TestDouble) && TestInt == other.TestInt && TestIntVector.SequenceEqual(other.TestIntVector) &&
            TestLong == other.TestLong && string.Equals(TestString, other.TestString) && TestInt128 == other.TestInt128 && TestInt256 == other.TestInt256);
 }
        public void MethodArgTest(
            object value,
            MethodArgType argumentType,
            Type expectedType,
            object expected,
            string keyword)
        {
            var dependency = TestDouble.For <ITestCaseCell>().Stub(x => x.Value, value);
            var sut        = MethodArgument.Create(dependency, argumentType);

            sut.Type.Should().Be(expectedType, "SUT type was not expected type.");
            sut.Value.Should().Be(expected, "SUT values was not expected value.");
            sut.CSharpType.Should().Be(keyword);
        }
Example #8
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = TestBoolean.GetHashCode();
         hashCode = (hashCode * 397) ^ TestDouble.GetHashCode();
         hashCode = (hashCode * 397) ^ TestInt;
         hashCode = (hashCode * 397) ^ (TestIntVector != null ? TestIntVector.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ TestLong.GetHashCode();
         hashCode = (hashCode * 397) ^ (TestString != null ? TestString.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ TestInt128.GetHashCode();
         hashCode = (hashCode * 397) ^ TestInt256.GetHashCode();
         return(hashCode);
     }
 }
Example #9
0
        static void Main(string[] args)
        {
            // Change current culture to Invariant culture to match nanoFramework culture setting
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var testByte = new TestByte();

            testByte.RunTest();

            var testSByte = new TestSByte();

            testSByte.RunTest();

            var testUInt16 = new TestUInt16();

            testUInt16.RunTest();

            var testInt16 = new TestInt16();

            testInt16.RunTest();

            var testUInt32 = new TestUInt32();

            testUInt32.RunTest();

            var testInt32 = new TestInt32();

            testInt32.RunTest();

            var testUInt64 = new TestUInt64();

            testUInt64.RunTest();

            var testInt64 = new TestInt64();

            testInt64.RunTest();

            var testFloat = new TestFloat();

            testFloat.RunTest();

            var testDouble = new TestDouble();

            testDouble.RunTest();

            Thread.Sleep(Timeout.Infinite);
        }
Example #10
0
        public void PriceExtremeMin()
        {
            //create an instance of tyhe class we want to create
            clsOrder AnOrder = new clsOrder();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass the method
            double TestDouble;

            TestDouble = Double.MinValue;
            string Price = TestDouble.ToString(); //should trigger an error

            //invoke the method
            Error = AnOrder.Valid(orderId, ItemName, Price, DateOrderMade, ItemShipped);
            //test to see that the results are correct
            Assert.AreNotEqual(Error, "");
        }
Example #11
0
        public static void Main()
        {
            var testByte = new TestByte();

            testByte.RunTest();

            var testSByte = new TestSByte();

            testSByte.RunTest();

            var testUInt16 = new TestUInt16();

            testUInt16.RunTest();

            var testInt16 = new TestInt16();

            testInt16.RunTest();

            var testUInt32 = new TestUInt32();

            testUInt32.RunTest();

            var testInt32 = new TestInt32();

            testInt32.RunTest();

            var testUInt64 = new TestUInt64();

            testUInt64.RunTest();

            var testInt64 = new TestInt64();

            testInt64.RunTest();

            var testFloat = new TestFloat();

            testFloat.RunTest();

            var testDouble = new TestDouble();

            testDouble.RunTest();

            Thread.Sleep(Timeout.Infinite);
        }
        public void GetFixedAsStringDouble()
        {
            var res1 = 0.001.GetFixedAsString(5);
            var res2 = 15.123456.GetFixedAsString(2);
            var res3 = 2.0.GetFixedAsString(2);
            var res4 = 2.0.GetFixedAsString(0);

            var ct   = new TestDouble();
            var res5 = ct.D.GetFixedAsString(2);

            var dnan = double.NaN;
            var res6 = dnan.GetFixedAsString(2);

            Assert.Equal("0.00100", res1);
            Assert.Equal("15.12", res2);
            Assert.Equal("2.00", res3);
            Assert.Equal("2", res4);
            Assert.Equal("0.00", res5);
            Assert.Equal("NaN", res6);
        }
 protected override void Given()
 {
     sut = d => TestDouble.For <IGherkinBlockStep>().Stub(x => x.Description, d);
 }