Пример #1
0
        public void Execute_ManyParallelExecutionOnlyOneEvaluation_CorrectEvaluation()
        {
            var resolverMock = Mock.Of <IScalarResolver>();

            Mock.Get(resolverMock).Setup(r => r.Execute()).Returns(true);

            var globalVariables = new Dictionary <string, ITestVariable>()
            {
                { "myVar", new GlobalVariable(resolverMock) }
            };
            var args     = new GlobalVariableScalarResolverArgs("myVar", globalVariables);
            var resolver = new GlobalVariableScalarResolver <bool>(args);

            Parallel.Invoke(
                () => resolver.Execute(),
                () => resolver.Execute()
                );
            Mock.Get(resolverMock).Verify(x => x.Execute(), Times.Once);
        }
Пример #2
0
        public void Execute_ExistingVariableWrongTypeDateTime_CorrectEvaluation()
        {
            var globalVariables = new Dictionary <string, ITestVariable>()
            {
                { "myVar", new TestVariable(new CSharpScalarResolver <object>(new CSharpScalarResolverArgs("\"2017-05-12\""))) },
                { "otherVar", new TestVariable(new CSharpScalarResolver <object>(new CSharpScalarResolverArgs("10+10"))) }
            };
            var args     = new GlobalVariableScalarResolverArgs("myVar", globalVariables);
            var resolver = new GlobalVariableScalarResolver <DateTime>(args);

            Assert.That(resolver.Execute(), Is.EqualTo(new DateTime(2017, 5, 12)));
        }
Пример #3
0
        public void Execute_ExistingVariableWrongType_CorrectEvaluation()
        {
            var globalVariables = new Dictionary <string, ITestVariable>()
            {
                { "myVar", new TestVariable(new CSharpScalarResolver <object>(new CSharpScalarResolverArgs("(10*10).ToString()"))) },
                { "otherVar", new TestVariable(new CSharpScalarResolver <object>(new CSharpScalarResolverArgs("10+10"))) }
            };
            var args     = new GlobalVariableScalarResolverArgs("myVar", globalVariables);
            var resolver = new GlobalVariableScalarResolver <int>(args);

            Assert.That(resolver.Execute(), Is.EqualTo(100));
        }