Ejemplo n.º 1
0
        public static void Publish <TMessage>(this ITestConfigurator <IBusTestScenario> configurator, TMessage message)
            where TMessage : class
        {
            var actionConfigurator = new PublishTestActionConfigurator <IBusTestScenario, TMessage>(x => x.Bus, message);

            configurator.AddActionConfigurator(actionConfigurator);
        }
Ejemplo n.º 2
0
        public static void Send <TMessage>(this ITestConfigurator <IBusTestScenario> configurator, TMessage message)
            where TMessage : class
        {
            var actionConfigurator = new SendTestActionConfigurator <IBusTestScenario, TMessage>(x => x.SubjectSendEndpoint, message);

            configurator.AddActionConfigurator(actionConfigurator);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets all tests contained within the given type
        /// </summary>
        /// <param name="type">The class to search for test methods</param>
        /// <param name="filters">The accumulation filters</param>
        /// <param name="configurator">The test configurator</param>
        public IEnumerable <ITest> Accumulate(Type type, IEnumerable <IAccumulationFilter> filters, ITestConfigurator configurator)
        {
            var instance = Activator.CreateInstance(type);

            return(type
                   .GetTestMethods()
                   .Select(methodInfo => new ReflectedTestMethod(methodInfo, instance).Configure(configurator))
                   .Where(filters.Apply));
        }
        /// <summary>
        /// Extensions for configuring a test RabbitMQ instance that can be used
        /// in the test. See <see cref="RabbitMqBusTestScenarioBuilder"/> docs.
        ///
        /// Sample usage:
        /// <code>
        ///using Magnum.TestFramework;
        ///using MassTransit.Testing;
        ///[Scenario]
        ///public class Using_the_handler_test_factory
        ///{
        ///    IHandlerTest&lt;A&gt; _test;
        ///
        ///    [When]
        ///    public void Setup()
        ///    {
        ///        _test = TestFactory.ForHandler&lt;A&gt;()
        ///            .New(x =>
        ///                {
        ///                    x.UseRabbitMqBusScenario();
        ///                    x.Send(new A());
        ///                    x.Send(new B());
        ///                });
        ///        _test.Execute();
        ///    }
        ///    [Finally]
        ///    public void Teardown()
        ///    {
        ///        _test.Dispose();
        ///        _test = null;
        ///    }
        ///    [Then]
        ///    public void Should_have_received_a_message_of_type_a()
        ///    {
        ///        _test.Received.Select&lt;A&gt;().ShouldBeTrue();
        ///    }
        ///}
        ///</code>
        /// </summary>
        /// <param name="configurator">The configurator that is passed via the lambda that you are calling this method from.</param>
        public static void UseRabbitMqBusScenario(this ITestConfigurator <IBusTestScenario> configurator)
        {
//			configurator.UseScenarioBuilder(() => new RabbitMqBusTestScenarioBuilder());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets an enumeration of class suites and unattaced test methods contained within
        /// a namespace
        /// </summary>
        /// <param name="typeContainedInNamespace">A type contained within the desired namespace</param>
        /// <param name="filters">Accumulation filters</param>
        /// <param name="configurator">Test configurator</param>
        public IEnumerable <ITest> Accumulate(Type typeContainedInNamespace, IEnumerable <IAccumulationFilter> filters, ITestConfigurator configurator)
        {
            var ns = typeContainedInNamespace.Namespace;

            if (ns == null)
            {
                //e.g. anonymous type
                throw new ArgumentException("Type given is not contained within a namespace", "typeContainedInNamespace");
            }

            return(typeContainedInNamespace
                   .Assembly
                   .GetTestClasses()
                   .Where(type => type.Namespace == ns)
                   .Select(type => new ClassSuite(type, filters, configurator).Configure(configurator))
                   .Cast <ITest>()
                   .Concat(new UnattachedMethodAccumulator()
                           .Accumulate(typeContainedInNamespace.Assembly, filters, configurator)
                           .Where(test => ((ITestMethodInfo)test).Method.DeclaringType.Namespace == ns)
                           ));
        }
Ejemplo n.º 6
0
 public static ITestConfiguratorResult Success(this ITestConfigurator configurator, string key, string value,
                                               string message)
 {
     return(new TestConfiguratorResult(TestConfiguratorResultDisposition.Success, key, value, message));
 }
Ejemplo n.º 7
0
 public static ITestConfiguratorResult Warning(this ITestConfigurator configurator, string key, string message)
 {
     return(new TestConfiguratorResult(TestConfiguratorResultDisposition.Warning, key, message));
 }
Ejemplo n.º 8
0
 public static ITestConfiguratorResult Failure(this ITestConfigurator configurator, string key, string message)
 {
     return(new TestConfiguratorResult(TestConfiguratorResultDisposition.Failure, key, message));
 }
Ejemplo n.º 9
0
 public IEnumerable <ITest> Accumulate(_Assembly assembly, IEnumerable <IAccumulationFilter> filters, ITestConfigurator configurator)
 {
     return((
                from method in assembly.GetUnattachedTestMethods()
                let instance = Activator.CreateInstance(method.DeclaringType)
                               select new ReflectedTestMethod(method, instance).Configure(configurator)
                ).Where(filters.Apply).Cast <ITest>());
 }
 public static TestConfiguratorResult Success(this ITestConfigurator configurator, string message)
 {
     return(new TestConfiguratorResultImpl(TestConfiguratorResultDisposition.Success, message));
 }
Ejemplo n.º 11
0
 public AssemblySuite(_Assembly assembly, IEnumerable <IAccumulationFilter> filters, ITestConfigurator configurator)
 {
     Assembly = assembly;
     Name     = assembly.GetName().Name;
     AddTests(Accumulator.Accumulate(assembly, filters, configurator));
 }
Ejemplo n.º 12
0
 public ITest Configure(ITestConfigurator configurator)
 {
     return(this);
 }
Ejemplo n.º 13
0
 public ITest Configure(ITestConfigurator configurator)
 {
     (configurator ?? new NullConfigurator()).Configure(this);
     return(this);
 }
Ejemplo n.º 14
0
        public IEnumerable <ITest> Accumulate(_Assembly assembly, IEnumerable <IAccumulationFilter> filters, ITestConfigurator configurator)
        {
            var namespaceAccumulator = new NamespaceAccumulator();
            var allTypes             = assembly.GetTypes();

            var types = new List <Type>();

            foreach (var ns in allTypes.Select(type => type.Namespace).Distinct())
            {
                var temp = ns;
                types.Add(allTypes.Where(type => type.Namespace == temp).First());
            }

            return(types.SelectMany(type => namespaceAccumulator.Accumulate(type, filters, configurator)));
        }
Ejemplo n.º 15
0
 public ClassSuite(Type @class, IEnumerable <IAccumulationFilter> filters, ITestConfigurator configurator)
 {
     Class = @class;
     Name  = Class.Name;
     AddTests(Accumulator.Accumulate(Class, filters, configurator));
 }