Example #1
0
        public static void Test_Can_Serializer_Then_Deserialize_Most_Complex_Test_Possible()
        {
            //arrange
            SerializerService serializer = new SerializerService();

            TestEnum[] arrayOne = new TestEnum[] { TestEnum.Zero, TestEnum.One };
            TestEnum[] arrayTwo = new TestEnum[3] {
                TestEnum.Two, TestEnum.One, TestEnum.Zero
            };
            BasicWireDataContract WireDataContractNested = new BasicWireDataContract(8);

            //act
            serializer.RegisterType <VeryComplexType>();
            serializer.Compile();

            byte[] bytes = serializer.Serialize(new VeryComplexType(6, WireDataContractNested, arrayOne, arrayTwo));
            Assert.NotNull(bytes);
            Assert.False(bytes.Length == 0);
            VeryComplexType message = serializer.Deserialize <VeryComplexType>(bytes);

            //assert
            Assert.NotNull(message);

            //check fields
            for (int i = 0; i < arrayOne.Length; i++)
            {
                Assert.AreEqual(arrayOne[i], message.testEnums[i], $"Failed for index {i}.");
            }

            for (int i = 0; i < arrayTwo.Length; i++)
            {
                Assert.AreEqual(arrayTwo[i], message.testEnumsAnother[i], $"Failed for index {i}.");
            }
        }
Example #2
0
            public VeryComplexType(int aVal, BasicWireDataContract nestedMessage, TestEnum[] enumsOne, TestEnum[] enumsTwo)
            {
                a = aVal;
                b = nestedMessage;

                testEnumsAnother = enumsTwo;
                testEnums        = enumsOne;
                Time             = DateTime.UtcNow;
            }
Example #3
0
        public static void Test_Can_Serializer_Then_Deserialize_Basic_Wire_Message()
        {
            //arrange
            SerializerService serializer = new SerializerService();

            //act
            serializer.RegisterType <BasicWireDataContract>();
            serializer.Compile();

            BasicWireDataContract message = serializer.Deserialize <BasicWireDataContract>(serializer.Serialize(new BasicWireDataContract(5)));

            //assert
            Assert.NotNull(message);
        }