コード例 #1
0
        public static void CreateFrames()
        {
            goodRequestFrame = EpoxyConnection.MessageToFrame(
                GoodRequestId, GoodMethod, PayloadType.Request, meaninglessMessage, null, LoggerTests.BlackHole);
            goodRequestLayerDataFrame = EpoxyConnection.MessageToFrame(
                GoodRequestId, GoodMethod, PayloadType.Request, meaninglessMessage, GoodLayerData, LoggerTests.BlackHole);

            goodResponseFrame = EpoxyConnection.MessageToFrame(
                GoodResponseId, GoodMethod, PayloadType.Response, meaninglessMessage, null, LoggerTests.BlackHole);
            goodEventFrame = EpoxyConnection.MessageToFrame(
                GoodRequestId, GoodMethod, PayloadType.Event, meaninglessMessage, null, LoggerTests.BlackHole);
            var goodFrameletCount = goodRequestFrame.Count;

            shortRequestFrame = new Frame(goodFrameletCount - 1, LoggerTests.BlackHole);
            for (var i = 0; i < goodFrameletCount - 1; i++)
            {
                shortRequestFrame.Add(goodRequestFrame.Framelets[i]);
            }

            doubleHeadersRequestFrame = new Frame(goodFrameletCount + 1, LoggerTests.BlackHole);
            doubleHeadersRequestFrame.Add(goodRequestFrame.Framelets[0]);
            for (var i = 0; i < goodFrameletCount; i++)
            {
                doubleHeadersRequestFrame.Add(goodRequestFrame.Framelets[i]);
            }

            doublePayloadRequestFrame = new Frame(goodFrameletCount + 1, LoggerTests.BlackHole);
            for (var i = 0; i < goodFrameletCount; i++)
            {
                doublePayloadRequestFrame.Add(goodRequestFrame.Framelets[i]);
            }
            doublePayloadRequestFrame.Add(goodRequestFrame.Framelets[goodFrameletCount - 1]);

            backwardsRequestFrame = new Frame(goodFrameletCount, LoggerTests.BlackHole);
            foreach (var framelet in goodRequestFrame.Framelets.Reverse())
            {
                backwardsRequestFrame.Add(framelet);
            }

            protocolErrorFrame = EpoxyConnection.MakeProtocolErrorFrame(meaninglessErrorCode, null, LoggerTests.BlackHole);

            doubleProtocolErrorFrame = EpoxyConnection.MakeProtocolErrorFrame(meaninglessErrorCode, null, LoggerTests.BlackHole);
            doubleProtocolErrorFrame.Add(doubleProtocolErrorFrame.Framelets[0]);

            configFrame = EpoxyConnection.MakeConfigFrame(LoggerTests.BlackHole);

            configFrameExtra = EpoxyConnection.MakeConfigFrame(LoggerTests.BlackHole);
            configFrameExtra.Add(goodRequestFrame.Framelets[0]);

            var invalidConfigData = new ArraySegment <byte>(new byte[] { 0x01 });

            configFrameBadConfigData = new Frame(1, LoggerTests.BlackHole);
            configFrameBadConfigData.Add(new Framelet(FrameletType.EpoxyConfig, invalidConfigData));

            protocolErrorFrame = EpoxyConnection.MakeProtocolErrorFrame(meaninglessErrorCode, null, LoggerTests.BlackHole);
        }
コード例 #2
0
        public static void CreateFrames()
        {
            // Set up the non-empty layer data we'll use.
            Bond.IBonded goodLayerObject = new Bond.Bonded <Dummy>(dummyObject);
            var          outputBuffer    = new OutputBuffer();
            var          compactWriter   = new CompactBinaryWriter <OutputBuffer>(outputBuffer);

            compactWriter.WriteVersion();
            goodLayerObject.Serialize(compactWriter);
            goodLayerData = outputBuffer.Data;

            // Good frames, from which we can pull good framelets to build bad frames.
            goodRequestFrame = EpoxyConnection.MessageToFrame(
                GoodRequestId, GoodService, GoodMethod, EpoxyMessageType.REQUEST, meaninglessPayload, null, LoggerTests.BlackHole);
            goodRequestLayerDataFrame = EpoxyConnection.MessageToFrame(
                GoodRequestId, GoodService, GoodMethod, EpoxyMessageType.REQUEST, meaninglessPayload, goodLayerObject, LoggerTests.BlackHole);

            goodResponseFrame = EpoxyConnection.MessageToFrame(
                GoodResponseId, GoodService, GoodMethod, EpoxyMessageType.RESPONSE, meaninglessPayload, null, LoggerTests.BlackHole);
            goodErrorResponseFrame = EpoxyConnection.MessageToFrame(
                GoodResponseId, GoodService, GoodMethod, EpoxyMessageType.RESPONSE, meaninglessError, null, LoggerTests.BlackHole);

            goodEventFrame = EpoxyConnection.MessageToFrame(
                GoodRequestId, GoodService, GoodMethod, EpoxyMessageType.EVENT, meaninglessPayload, null, LoggerTests.BlackHole);

            configFrame        = EpoxyConnection.MakeConfigFrame(LoggerTests.BlackHole);
            protocolErrorFrame = EpoxyConnection.MakeProtocolErrorFrame(MeaninglessErrorCode, null, LoggerTests.BlackHole);

            var goodFrameletCount = goodRequestFrame.Count;

            // Bad frames made of good framelets.
            shortRequestFrame = new Frame(goodFrameletCount - 1, LoggerTests.BlackHole);
            for (var i = 0; i < goodFrameletCount - 1; i++)
            {
                shortRequestFrame.Add(goodRequestFrame.Framelets[i]);
            }

            doubleHeadersRequestFrame = new Frame(goodFrameletCount + 1, LoggerTests.BlackHole);
            doubleHeadersRequestFrame.Add(goodRequestFrame.Framelets[0]);
            for (var i = 0; i < goodFrameletCount; i++)
            {
                doubleHeadersRequestFrame.Add(goodRequestFrame.Framelets[i]);
            }

            headersConfigRequestFrame = new Frame(2, LoggerTests.BlackHole);
            headersConfigRequestFrame.Add(goodRequestFrame.Framelets[0]);
            headersConfigRequestFrame.Add(configFrame.Framelets[0]);

            doublePayloadRequestFrame = new Frame(goodFrameletCount + 1, LoggerTests.BlackHole);
            for (var i = 0; i < goodFrameletCount; i++)
            {
                doublePayloadRequestFrame.Add(goodRequestFrame.Framelets[i]);
            }
            doublePayloadRequestFrame.Add(goodRequestFrame.Framelets[goodFrameletCount - 1]);

            backwardsRequestFrame = new Frame(goodFrameletCount, LoggerTests.BlackHole);
            foreach (var framelet in goodRequestFrame.Framelets.Reverse())
            {
                backwardsRequestFrame.Add(framelet);
            }

            doubleProtocolErrorFrame = EpoxyConnection.MakeProtocolErrorFrame(MeaninglessErrorCode, null, LoggerTests.BlackHole);
            doubleProtocolErrorFrame.Add(doubleProtocolErrorFrame.Framelets[0]);

            configFrameExtra = EpoxyConnection.MakeConfigFrame(LoggerTests.BlackHole);
            configFrameExtra.Add(goodRequestFrame.Framelets[0]);

            // Bad frames made of bad framelets.
            var invalidConfigData = new ArraySegment <byte>(new byte[] { 0x01 });

            configFrameBadConfigData = new Frame(1, LoggerTests.BlackHole);
            configFrameBadConfigData.Add(new Framelet(FrameletType.EpoxyConfig, invalidConfigData));
        }