Example #1
0
        public void Matching()
        {
            ServiceMessageHeader hi1         = "channel/messagetype/";
            ServiceMessageHeader hi2         = ("channel", "messagetype", null);
            ServiceMessageHeader hi3         = ("channel", "messagetype", "");
            ServiceMessageHeader hi4         = ("channel", "messagetype", " ");
            ServiceMessageHeader himprobable = ("channel", "", "Howdy");

            Assert.IsTrue(hi1.ChannelId == "channel");
            Assert.IsTrue(hi1.MessageType == "messagetype");
            Assert.IsTrue(hi1.ActionType == null);
            Assert.IsTrue(hi1.IsPartialKey);

#pragma warning disable CS1718 // Comparison made to same variable
            Assert.IsTrue(hi1 == hi1);
            Assert.IsFalse(hi1 != hi1);
#pragma warning restore CS1718 // Comparison made to same variable

            Assert.IsTrue((hi1 == hi2) && (hi2 == hi3) && (hi3 == hi4));
        }
Example #2
0
        public void ServiceMessageHeaderSerializationTest()
        {
            var headerBytes = _testHeader.GetBytes();

            headerBytes.Length.Should().Be(ServiceMessageHeader.Length);

            Action act = () => ServiceMessageHeader.Parse(headerBytes, 1);

            act.Should().Throw <IndexOutOfRangeException>();

            var smh2 = ServiceMessageHeader.Parse(headerBytes, 0);

            smh2.Version.Should().Be(ServiceMessageHeader.CurrentVersion);
            smh2.DataLength.Should().Be(DataLength);
            smh2.Flags.Should().Be(Flags);
            smh2.OperationCode.Should().Be(OpCode);
            smh2.SubordinateID.Should().Be(SubordinateID);
            smh2.RegIndex.Should().Be(RegIndex);

            smh2.Should().BeEquivalentTo(_testHeader);
        }
        public void Bug180()
        {
            try
            {
                ServiceMessageHeader destination = ("internalIn/frankie/benny");

                ICommandInitiator        init;
                DebugMemoryDataCollector collector;

                var pipeline = new MicroservicePipeline("TestPipeline")
                               .AdjustPolicyTaskManagerForDebug()
                               .AddDebugMemoryDataCollector(out collector)
                               .AddICommandInitiator(out init)
                               .AddChannelIncoming("internalIn", internalOnly: true)
                               .AttachCommand((c) =>
                {
                    c.ResponseSet(200);
                    return(Task.FromResult(0));
                }, ("frankie", "benny"))
                               .AttachCommand((ctx) =>
                {
                    ctx.ResponseSet(200);
                    return(Task.FromResult(0));
                }, ("internalIn", "frankie4fingers", "benny"))
                               .Revert()
                               .AddChannelOutgoing("internalOut", internalOnly: true)
                               .Revert();

                pipeline.Start();

                var rs = init.Process <string, string>(destination, "hello").Result;

                pipeline.Stop();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Example #4
0
 public LookupCallbackMessage(ServiceMessageHeader header) : this(header, new LookupCallbackMessagePayload())
 {
 }
Example #5
0
        public void Pipeline3()
        {
            try
            {
                var pipeline    = new MicroservicePipeline("TestPipeline");
                var destination = ServiceMessageHeader.FromKey("internalIn/frankie/benny");
                var fragment    = ServiceMessageHeaderFragment.FromKey("frankie/benny");

                ICommandInitiator        init;
                DebugMemoryDataCollector collector;

                pipeline
                .AddDebugMemoryDataCollector(out collector)
                .AdjustPolicyTaskManagerForDebug()
                .AddChannelIncoming("internalIn", internalOnly: true)
                .AttachCommand((ctx) =>
                {
                    string entity;

                    if (ctx.DtoTryGet(out entity))
                    {
                        Assert.AreEqual(entity, "Hello");
                        ctx.ResponseSet(200, entity + "Good good", "It's all good");
                    }
                    else
                    {
                        ctx.ResponseSet(400, description: "It's all messed up.");
                    }

                    ctx.Collector.LogMessage("It's all good.");

                    return(Task.FromResult(0));
                }
                               , fragment)
                .Revert()
                .AddChannelIncoming("internalRs", internalOnly: true)
                .AttachICommandInitiator(out init)
                .Revert();

                pipeline.Start();

                var rs1 = init.Process <string, string>(destination, "Hello", new RequestSettings()
                {
                    CorrelationId = "freddy"
                }).Result;
                var rs2 = init.Process <string, string>(destination, null, new RequestSettings()
                {
                    CorrelationId = "johnny"
                }).Result;

                Assert.IsTrue(rs1.ResponseCode.Value == 200);
                Assert.IsTrue(rs1.Response == "HelloGood good");
                Assert.IsTrue(rs2.ResponseCode.Value == 400);

                pipeline.Stop();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Example #6
0
 public BrowseMessage(ServiceMessageHeader header) : this(header, new BrowseMessagePayload())
 {
 }
Example #7
0
 public RequestMessage(ServiceMessageHeader header, RequestMessagePayload payload) : base(header, payload)
 {
 }
 public RegisterCallbackMessage(ServiceMessageHeader header) : this(header, new RegisterCallbackMessagePayload())
 {
 }
 public ResolveMessage(ServiceMessageHeader header) : this(header, new ResolveMessagePayload())
 {
 }