Beispiel #1
0
        public void GetSerializedMessageSerializesUsingHubProtocolIfNoCacheAvailable()
        {
            var invocation = new InvocationMessage("Foo", new object[0]);
            var message    = new SerializedHubMessage(invocation);
            var protocol   = new DummyHubProtocol("p1");

            var serialized = message.GetSerializedMessage(protocol);

            Assert.Equal(DummyHubProtocol.DummySerialization, serialized.ToArray());
            Assert.Collection(protocol.GetWrittenMessages(),
                              actualMessage => Assert.Same(invocation, actualMessage));
        }
Beispiel #2
0
        public void GetSerializedMessageReturnsCachedSerializationIfAvailable()
        {
            var invocation = new InvocationMessage("Foo", new object[0]);
            var message    = new SerializedHubMessage(invocation);
            var protocol   = new DummyHubProtocol("p1");

            // This should cache it
            _ = message.GetSerializedMessage(protocol);

            // Get it again
            var serialized = message.GetSerializedMessage(protocol);


            Assert.Equal(DummyHubProtocol.DummySerialization, serialized.ToArray());

            // We should still only have written one message
            Assert.Collection(protocol.GetWrittenMessages(),
                              actualMessage => Assert.Same(invocation, actualMessage));
        }