Exemplo n.º 1
0
        public void Test_CellPass_BinaryReadWrite()
        {
            CellPass     cp1 = ATestCellPass();
            MemoryStream ms  = new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION);
            BinaryWriter bw  = new BinaryWriter(ms, Encoding.UTF8, true);

            cp1.Write(bw);

            ms.Position = 0;
            BinaryReader br  = new BinaryReader(ms, Encoding.UTF8, true);
            CellPass     cp2 = new CellPass();

            cp2.Read(br);

            Assert.True(cp1.Equals(cp2), "Equality check on same cell passes failed after write then read (returned true)");

            // Check negative condition by writing and reading a second different cell pass then comparing the results of reading the two cell passes
            // to ensure they are different

            cp2 = ATestCellPass2();
            MemoryStream ms2 = new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION);
            BinaryWriter bw2 = new BinaryWriter(ms2, Encoding.UTF8, true);

            cp2.Write(bw2);

            ms2.Position = 0;
            BinaryReader br2 = new BinaryReader(ms2, Encoding.UTF8, true);

            cp2.Read(br2);

            Assert.False(cp1.Equals(cp2), "Equality check on different cell passes failed after write then read (returned true)");
        }