示例#1
0
        public void ContextLinkageInfoIsSerializedCorrectly(ContextLinkageDiscoveryMode mode)
        {
            var serializer            = SerializerFactory.Create(MessageFactory);
            var serviceReference      = MessageFactory.CreateConsumedServiceReference("interop.testing.EchoService", Maybe <string> .Nothing);
            var methodReference       = MessageFactory.CreateConsumedMethodReference(serviceReference, "Unary");
            var contextLinkageOptions = MessageFactory.CreateContextLinkageOptions(mode, Maybe <string> .Nothing);

            using (var request = MessageFactory.CreateInvocationStartRequest(methodReference, contextLinkageOptions))
                using (var serialized = serializer.Serialize(request))
                    using (var deserialized = serializer.DeserializeClientToBrokerRequest(serialized))
                    {
                        deserialized.Handle(new ClientToBrokerRequestHandler <Nothing, Nothing>(
                                                (msg, _) =>
                        {
                            msg.ContextLinkageOptions.Mode.ShouldBe(mode);
                            return(msg.Target.Handle(new InvocationTargetHandler <Nothing, Nothing>(
                                                         (target, __) =>
                            {
                                target.MethodId.ShouldBe("Unary");
                                target.ConsumedService.ServiceId.ShouldBe("interop.testing.EchoService");
                                target.ConsumedService.ServiceAlias.ShouldBe(Maybe <string> .Nothing);
                                return Nothing.Instance;
                            },
                                                         (target, __) => throw new InvalidOperationException($"Unexpected target: {target}"))));
                        },
                                                (msg, _) => throw new InvalidOperationException($"Unexpected message: {msg}"),
                                                (msg, _) => throw new InvalidOperationException($"Unexpected message: {msg}")));
                    }
        }
        public IContextLinkageOptions CreateContextLinkageOptions(ContextLinkageDiscoveryMode contextLinkageDiscoveryMode, Maybe <string> specificContextId = default)
        {
            var obj = ContextLinkageOptions.Rent();

            obj.Mode            = contextLinkageDiscoveryMode;
            obj.SpecificContext = specificContextId;
            return(obj);
        }
示例#3
0
 private ContextLinkageOptions(ContextLinkageDiscoveryMode mode)
 {
     Mode = mode;
     SpecifiedContextId = Maybe <string> .Nothing;
 }