예제 #1
0
        public void TestGreetingContract()
        {
            var serializer = new MyNoSqlTcpSerializer();


            var testContract = new GreetingContract
            {
                Name = "Test"
            };

            var rawData = serializer.Serialize(testContract);

            var memStream = new MemoryStream(rawData.ToArray())
            {
                Position = 0
            };


            var dataReader = new TcpDataReader();

            dataReader.NewPackage(memStream.ToArray());


            var result
                = (GreetingContract)serializer
                  .DeserializeAsync(dataReader)
                  .AsTestResult();

            Assert.AreEqual(testContract.Name, result.Name);
        }
예제 #2
0
        public void TestPing()
        {
            var serializer = new MyNoSqlTcpSerializer();


            var pingContract = new PingContract();

            var rawData = serializer.Serialize(pingContract);

            var memStream = new MemoryStream(rawData.ToArray())
            {
                Position = 0
            };


            var dataReader = new TcpDataReader();

            dataReader.NewPackage(memStream.ToArray());


            var result
                = serializer
                  .DeserializeAsync(dataReader)
                  .AsTestResult();

            Assert.IsTrue(typeof(PingContract) == result.GetType());
        }
예제 #3
0
        public void TestInitPartitionContract()
        {
            var serializer = new MyNoSqlTcpSerializer();


            var testContract = new InitPartitionContract
            {
                TableName    = "Test",
                PartitionKey = "PK",
                Data         = new byte[] { 1, 2, 3 }
            };

            var rawData = serializer.Serialize(testContract);

            var memStream = new MemoryStream(rawData.ToArray())
            {
                Position = 0
            };


            var dataReader = new TcpDataReader();

            dataReader.NewPackage(memStream.ToArray());


            var result
                = (InitPartitionContract)serializer
                  .DeserializeAsync(dataReader)
                  .AsTestResult();

            Assert.AreEqual(testContract.TableName, result.TableName);
            Assert.AreEqual(testContract.PartitionKey, result.PartitionKey);
            Assert.AreEqual(testContract.Data.Length, result.Data.Length);
            for (var i = 0; i < testContract.Data.Length; i++)
            {
                Assert.AreEqual(testContract.Data[i], result.Data[i]);
            }
        }