Пример #1
0
        public void FromStringThrowsOnTooBigFrame()
        {
            TestEntryFull entry         = TestEntryFull.Create();
            string        requestString = JsonConvert.SerializeObject(entry);

            byte[] bytes = Encoding.UTF8.GetBytes(requestString);

            Assert.Throws <TooBigRequestException>(() => QueueEntry.FromRequestString(new QueueContext("x"), requestString, bytes.Length - 1));
        }
Пример #2
0
        public void CreateJsonFromRequestString()
        {
            TestEntryFull originalEntry = TestEntryFull.Create();

            string requestString = JsonConvert.SerializeObject(originalEntry);

            QueueEntry requestEntry = QueueEntry.FromRequestString(new QueueContext("x"), requestString, Int32.MaxValue);

            Assert.AreEqual(originalEntry.Tag, requestEntry.Tag);
            Assert.IsTrue(originalEntry.Equals(JsonConvert.DeserializeObject <TestEntryFull>(requestEntry.Data)));
        }
Пример #3
0
        public void CreateJsonFromBytes()
        {
            TestEntryFull originalEntry = TestEntryFull.Create();

            byte[] bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(originalEntry));

            QueueEntry    queueEntry     = QueueEntry.FromBytes(bytes);
            TestEntryFull entryFromBytes = JsonConvert.DeserializeObject <TestEntryFull>(queueEntry.Data);

            Assert.AreEqual(originalEntry.Tag, queueEntry.Tag);
            Assert.IsTrue(originalEntry.Equals(entryFromBytes));
        }