Ejemplo n.º 1
0
 public void HandleResponseRoutesWithNameSetToNullOrEmpty(Type subscriberType)
 {
     Assert.Throws <NetmqRouterException>(() =>
     {
         var subscriber = Activator.CreateInstance(subscriberType);
         ClassAnalyzer.AnalyzeClass(subscriber);
     });
 }
Ejemplo n.º 2
0
        public static IMessageRouter RegisterSubscriber <T>(this IMessageRouter router, T subscriber)
        {
            ClassAnalyzer
            .AnalyzeClass(subscriber)
            .ToList()
            .ForEach(x => router.RegisterSubscriber(x));

            return(router);
        }
Ejemplo n.º 3
0
        public void HandleRouteWithMoreThanOneArgument()
        {
            var subscriber = new ExampleSubscriberRouteWithMoreThanOneArgument();

            Assert.Throws <ConfigurationException>(() =>
            {
                ClassAnalyzer.AnalyzeClass(subscriber);
            });
        }
Ejemplo n.º 4
0
        public string CorrectlyHandleRoutesWithoutRouteResponseAttribute(string incomingROuteName)
        {
            var subscriber = new ExampleSubscriberWithVariousResponseConfiguration();

            return(ClassAnalyzer
                   .AnalyzeClass(subscriber)
                   .First(x => x.Incoming.Name == incomingROuteName)
                   .Outcoming
                   ?.Name);
        }
Ejemplo n.º 5
0
        public Type CorrectlyDiscoverOutcomingDataType(string methodName)
        {
            var subscriber = new ExampleSubscriberWithOutcomingRoutes();

            return(ClassAnalyzer
                   .AnalyzeClass(subscriber)
                   .First(x => x.Outcoming.Name == methodName)
                   .Outcoming
                   .DataType);
        }
Ejemplo n.º 6
0
        public void HandleBaseRoute()
        {
            // arrange
            var subscriber = new ClassWithBaseRoute();

            // act
            var result = ClassAnalyzer.AnalyzeClass(subscriber);

            // assert
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("BaseRoute/IncomingRoute", result[0].Incoming.Name);
            Assert.AreEqual("OutcomingRoute", result[0].Outcoming.Name);
        }
Ejemplo n.º 7
0
        public void CorrectlyCallRoute(string routeName, string value)
        {
            // arrange
            var subscriber = new ExampleSubscriberWithCallHandler();
            var routes     = ClassAnalyzer.AnalyzeClass(subscriber);

            // act
            routes
            .First(x => x.Incoming.Name == routeName)
            .Method(value);

            // assert
            Assert.AreEqual(value, subscriber.PassedValue);
        }
Ejemplo n.º 8
0
        public void DiscoverOnlyMethodsWithRouteAttribute()
        {
            var subscriber         = new ExampleSubscriberWithIncommingRoutes();
            var incomingRouteNames = ClassAnalyzer
                                     .AnalyzeClass(subscriber)
                                     .Select(x => x.Incoming.Name);

            var expected = new[]
            {
                "GetEvent",
                "GetRaw",
                "GetText",
                "GetObject"
            };

            Assert.AreEqual(expected, incomingRouteNames);
        }
Ejemplo n.º 9
0
        public void DiscoverOnlyMethodsWithRouteResponseAttribute()
        {
            var subscriber          = new ExampleSubscriberWithOutcomingRoutes();
            var outcomingRouteNames = ClassAnalyzer
                                      .AnalyzeClass(subscriber)
                                      .Select(x => x.Outcoming.Name)
                                      .ToList();

            var expected = new[]
            {
                "ResponseEvent",
                "ResponseRaw",
                "ResponseText",
                "ResponseObject"
            };

            Assert.AreEqual(expected, outcomingRouteNames);
        }
Ejemplo n.º 10
0
        public void HandleMethodWithRouteResponseAttributeButwithoutBasicRoute()
        {
            var subscriber = new ExampleSubscriberWithOutcomingRouteButWithoutIcoming();

            Assert.Throws <ConfigurationException>(() => { ClassAnalyzer.AnalyzeClass(subscriber); });
        }