Exemple #1
0
        public static void Run(ScenarioDescriptor scenarioDescriptor, Func <RunDescriptor, bool> remove)
        {
            var runDescriptors = Transports.AllAvailable;

            foreach (var rundescriptor in runDescriptors)
            {
                Type type;
                if (rundescriptor.Settings.TryGet("Transport", out type))
                {
                    var configurerTypeName = "ConfigureScenariosFor" + type.Name;
                    var configurerType     = Type.GetType(configurerTypeName, false);

                    if (configurerType == null)
                    {
                        throw new InvalidOperationException($"Acceptance Test project must include a non-namespaced class named '{configurerTypeName}' implementing {typeof(IConfigureSupportedScenariosForTestExecution).Name}. See {typeof(ConfigureScenariosForMsmqTransport).FullName} for an example.");
                    }

                    var configurer = Activator.CreateInstance(configurerType) as IConfigureSupportedScenariosForTestExecution;

                    if (configurer == null)
                    {
                        throw new InvalidOperationException($"{configurerTypeName} does not implement {typeof(IConfigureSupportedScenariosForTestExecution).Name}.");
                    }

                    if (configurer.UnsupportedScenarioDescriptorTypes.Contains(scenarioDescriptor.GetType()))
                    {
                        remove(rundescriptor);
                    }
                }
            }
        }
        public void It_should_accept_parameterless_methods_with_unknown_arguments()
        {
            var methodInfo = GetMethod(nameof(Parameterless_method));
            var descriptor = new ScenarioDescriptor(methodInfo, null);

            Assert.That(descriptor.MethodInfo, Is.SameAs(methodInfo));
            Assert.That(descriptor.Parameters, Is.Empty);
        }
        public void It_should_accept_parameterless_methods()
        {
            var methodInfo = GetMethod(nameof(Parameterless_method));
            var descriptor = new ScenarioDescriptor(methodInfo, new object[0]);

            Assert.That(descriptor.MethodInfo, Is.SameAs(methodInfo));
            Assert.That(descriptor.Parameters, Is.Empty);
        }
        public void It_should_accept_parameterized_methods_with_nullable_parameters(int?arg1)
        {
            var methodInfo = GetMethod(nameof(Parameterized_method_with_nullable_parameter));
            var descriptor = new ScenarioDescriptor(methodInfo, new object[] { arg1 });

            Assert.That(descriptor.MethodInfo, Is.SameAs(methodInfo));
            Assert.That(descriptor.Parameters, Is.Not.Empty);

            var parameters = descriptor.Parameters.ToArray();

            AssertParameter(parameters[0], "x", arg1);
        }
        public void It_should_accept_parameterized_methods(int a1, string a2)
        {
            var methodInfo = GetMethod(nameof(Parameterized_method));
            var descriptor = new ScenarioDescriptor(methodInfo, new object[] { a1, a2 });

            Assert.That(descriptor.MethodInfo, Is.SameAs(methodInfo));
            Assert.That(descriptor.Parameters, Is.Not.Empty);

            var parameters = descriptor.Parameters.ToArray();

            AssertParameter(parameters[0], "x", a1);
            AssertParameter(parameters[1], "y", a2);
        }