Inheritance: IBindingRegistry
Exemplo n.º 1
0
        public void ShouldFindExampleConverter()
        {
            BindingRegistry registry = new BindingRegistry();
            registry.BuildBindingsFromAssembly(Assembly.GetExecutingAssembly());

            Assert.AreEqual(1, registry.StepTransformations.Where(s => s.Regex.Match("BindingRegistryTests").Success).Count());
        }
Exemplo n.º 2
0
        public TestRunner()
        {
            errorProvider = ObjectContainer.ErrorProvider;
            testTracer = ObjectContainer.TestTracer;
            unitTestRuntimeProvider = ObjectContainer.UnitTestRuntimeProvider;
            stepFormatter = ObjectContainer.StepFormatter;
 
            bindingRegistry = ObjectContainer.BindingRegistry;
            stepArgumentTypeConverter = ObjectContainer.StepArgumentTypeConverter;
        }
Exemplo n.º 3
0
        public void ShouldFindScopedExampleConverter()
        {
            BindingRegistry registry = new BindingRegistry();
            registry.BuildBindingsFromAssembly(Assembly.GetExecutingAssembly());

            Assert.AreEqual(2,
                registry.Where(s => s.Regex.Match("SpecificBindingRegistryTests").Success && s.IsScoped).Count());

            Assert.AreEqual(0,
                registry.Where(s => s.Regex.Match("SpecificBindingRegistryTests").Success && s.IsScoped == false).Count());
        }
Exemplo n.º 4
0
        public void GetStepDefinitions_should_return_all_step_definitions()
        {
            var sut = new BindingRegistry();

            var stepDefinitionBinding1 = new StepDefinitionBinding(StepDefinitionType.Given, @"foo.*", new Mock<IBindingMethod>().Object, null);
            var stepDefinitionBinding2 = new StepDefinitionBinding(StepDefinitionType.When, @"bar.*", new Mock<IBindingMethod>().Object, null);
            sut.RegisterStepDefinitionBinding(stepDefinitionBinding1);
            sut.RegisterStepDefinitionBinding(stepDefinitionBinding2);

            var result = sut.GetStepDefinitions();

            result.Should().BeEquivalentTo(stepDefinitionBinding1, stepDefinitionBinding2);
        }
Exemplo n.º 5
0
        public void GetHooks_should_return_all_hooks()
        {
            var sut = new BindingRegistry();

            var hook1 = new HookBinding(new Mock<IBindingMethod>().Object, HookType.BeforeScenario, null, 1);
            var hook2 = new HookBinding(new Mock<IBindingMethod>().Object, HookType.AfterFeature, null, 2);
            sut.RegisterHookBinding(hook1);
            sut.RegisterHookBinding(hook2);

            var result = sut.GetHooks();

            result.Should().BeEquivalentTo(hook1, hook2);
        }
Exemplo n.º 6
0
        public void StepArgumentTypeConverterShouldUseUserConverterForConversion()
        {
            ObjectContainer.ScenarioContext = new ScenarioContext(null);
            BindingRegistry bindingRegistry = new BindingRegistry();
            ObjectContainer.BindingRegistry = bindingRegistry;

            UserCreator stepTransformationInstance = new UserCreator();
            var transformMethod = stepTransformationInstance.GetType().GetMethod("Create");
            bindingRegistry.StepTransformations.Add(new StepTransformationBinding(@"user (\w+)", transformMethod));

            var stepArgumentTypeConverter = new StepArgumentTypeConverter();

            var result = stepArgumentTypeConverter.Convert("user xyz", typeof(User), new CultureInfo("en-US"));
            Assert.That(result.GetType(), Is.EqualTo(typeof(User)));
            Assert.That(((User)result).Name, Is.EqualTo("xyz"));
        }
Exemplo n.º 7
0
        public void ShouldUseStepArgumentTransformationToConvertTable()
        {
            ObjectContainer.ScenarioContext = new ScenarioContext(null, null);
            BindingRegistry bindingRegistry = new BindingRegistry();
            ObjectContainer.BindingRegistry = bindingRegistry;

            UserCreator stepTransformationInstance = new UserCreator();
            var transformMethod = stepTransformationInstance.GetType().GetMethod("CreateUsers");
            bindingRegistry.StepTransformations.Add(new StepTransformationBinding(@"", transformMethod));

            var stepArgumentTypeConverter = new StepArgumentTypeConverter();

            var table = new Table("Name");
            table.AddRow("Tom");
            table.AddRow("Dick");
            table.AddRow("Harry");

            var result = stepArgumentTypeConverter.Convert(table, typeof(IEnumerable<User>), new CultureInfo("en-US"));

            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.InstanceOf<IEnumerable<User>>());
            Assert.That(((IEnumerable<User>)result).Count(), Is.EqualTo(3));
        }