public static HttpResponseMessage CreatePdfResponse(this HttpRequestMessage request, System.IO.Stream stream,
     string filename = default(string), bool inline = false)
 {
     var result = stream.ToBytes(
         (pdfData) => request.CreatePdfResponse(pdfData, filename, inline));
     return result;
 }
        public void UInt32_IEnumerable_ToBytes_ComputesCorrectly()
        {
            var testValues = new[] { 2382910298U, 0U, 32483910U, 231398239U };

            var expected = new byte[] {
                0x5A, 0x53, 0x08, 0x8E,
                0x00, 0x00, 0x00, 0x00,
                0x46, 0xaa, 0xef, 0x01,
                0x5f, 0xdb, 0xca, 0x0d
            };

            Assert.Equal(expected, testValues.ToBytes());
        }
Пример #3
0
        public void ShouldCloseOnCloseFromTextFrame()
        {
            var frame = new Hybi14DataFrame
                {
                    FrameType = FrameType.Close,
                    IsFinal = true,
                    IsMasked = true,
                    MaskKey = 5232,
                    Payload = 1000.ToBigEndianBytes<ushort>()
                };

            var hit = false;
            _onClose = () => hit = true;
            _handler.Receive(frame.ToBytes());

            Assert.IsTrue(hit);
        }
Пример #4
0
        private static System.Drawing.Icon CreateImage(System.Drawing.Icon icon)
        {
            long checkSum = icon.ToBytes().GetCheckSum();

            if (images.ContainsKey(checkSum))
                return images[checkSum];

            images.Add(checkSum, icon);
            return icon;
        }
Пример #5
0
        public void ShouldThrowOnInvalidFrameType()
        {
            var frame = new Hybi14DataFrame
                {
                    FrameType = (FrameType)11,
                    IsFinal = true,
                    IsMasked = true,
                    MaskKey = 5232,
                    Payload = 1000.ToBigEndianBytes<ushort>()
                };

            var ex = Assert.Throws<WebSocketException>(() => _handler.Receive(frame.ToBytes()));
            Assert.AreEqual(WebSocketStatusCodes.ProtocolError, ex.StatusCode);
        }