コード例 #1
0
        public virtual void TestReadWrite()
        {
            DeleteBase("testReadWrite.ndb");
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testReadWrite.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));

            fsi.SetWritePosition(fsi.GetLength(), false);
            for (var i = 0; i < 10000; i++)
            {
                fsi.WriteInt(i, false);
                var currentPosition = fsi.GetPosition();
                if (i == 8000)
                {
                    currentPosition = fsi.GetPosition();

                    // Using the for transaction method to avoid protected area
                    // verification, check the setWritePosition method
                    fsi.SetWritePositionNoVerification(4, false);
                    AssertEquals(1, fsi.ReadInt());

                    fsi.SetWritePositionNoVerification(currentPosition, false);
                }
                if (i == 9000)
                {
                    currentPosition = fsi.GetPosition();

                    fsi.SetWritePositionNoVerification(8, false);
                    fsi.WriteInt(12, false);

                    fsi.SetWritePositionNoVerification(currentPosition, false);
                }
            }
            fsi.SetReadPosition(0);
            for (var i = 0; i < 10000; i++)
            {
                var j = fsi.ReadInt();
                if (i == 2)
                {
                    AssertEquals(12, j);
                }
                else
                {
                    AssertEquals(i, j);
                }
            }
            fsi.Close();
            DeleteBase("testReadWrite.ndb");
        }
コード例 #2
0
 public virtual void TestBigInteger()
 {
     DeleteBase("testBigDecimal.ndb");
     var bd = Convert.ToDecimal("-128451");
     IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testBigDecimal.ndb"),
                                                        MultiBuffer.DefaultBufferSizeForData,
                                                        new MockSession("test"));
     fsi.SetWritePosition(0, false);
     fsi.WriteBigDecimal(bd, false);
     fsi.Close();
     fsi = new FileSystemInterface(new FileIdentification("testBigDecimal.ndb"),
                                   MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
     fsi.SetReadPosition(0);
     var bd2 = fsi.ReadBigDecimal();
     AssertEquals(bd, bd2);
     fsi.Close();
 }
コード例 #3
0
        public virtual void TestByte()
        {
            DeleteBase("testByte.ndb");

            const byte b = 127;
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testByte.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));
            fsi.SetWritePosition(0, false);
            fsi.WriteByte(b, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testByte.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var b2 = fsi.ReadByte();
            AssertEquals(b, b2);
            fsi.Close();
        }
コード例 #4
0
 public virtual void TestReadWrite()
 {
     DeleteBase("testReadWrite.ndb");
     IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testReadWrite.ndb"),
                                                        MultiBuffer.DefaultBufferSizeForData,
                                                        new MockSession("test"));
     fsi.SetWritePosition(fsi.GetLength(), false);
     for (var i = 0; i < 10000; i++)
     {
         fsi.WriteInt(i, false);
         var currentPosition = fsi.GetPosition();
         if (i == 8000)
         {
             currentPosition = fsi.GetPosition();
             
             // Using the for transaction method to avoid protected area
             // verification, check the setWritePosition method
             fsi.SetWritePositionNoVerification(4, false);
             AssertEquals(1, fsi.ReadInt());
             
             fsi.SetWritePositionNoVerification(currentPosition, false);
         }
         if (i == 9000)
         {
             currentPosition = fsi.GetPosition();
             
             fsi.SetWritePositionNoVerification(8, false);
             fsi.WriteInt(12, false);
             
             fsi.SetWritePositionNoVerification(currentPosition, false);
         }
     }
     fsi.SetReadPosition(0);
     for (var i = 0; i < 10000; i++)
     {
         var j = fsi.ReadInt();
         if (i == 2)
             AssertEquals(12, j);
         else
             AssertEquals(i, j);
     }
     fsi.Close();
     DeleteBase("testReadWrite.ndb");
 }
コード例 #5
0
        public virtual void TestFloat()
        {
            DeleteBase("testFloat.ndb");
            const float          f   = (float)12544548.12454;
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testFloat.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));

            fsi.SetWritePosition(0, false);
            fsi.WriteFloat(f, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testFloat.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var f2 = fsi.ReadFloat();

            AssertTrue(f == f2);
            fsi.Close();
        }
コード例 #6
0
        public virtual void TestBigInteger()
        {
            DeleteBase("testBigDecimal.ndb");
            var bd = Convert.ToDecimal("-128451");
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testBigDecimal.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));

            fsi.SetWritePosition(0, false);
            fsi.WriteBigDecimal(bd, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testBigDecimal.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var bd2 = fsi.ReadBigDecimal();

            AssertEquals(bd, bd2);
            fsi.Close();
        }
コード例 #7
0
        public virtual void TestShort()
        {
            DeleteBase("testShort.ndb");
            const short          s   = 4598;
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testShort.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));

            fsi.SetWritePosition(0, false);
            fsi.WriteShort(s, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testShort.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var s2 = fsi.ReadShort();

            AssertEquals(s, s2);
            fsi.Close();
        }
コード例 #8
0
        public virtual void TestString()
        {
            var                  baseName = GetBaseName();
            const string         s        = "ola chico, como você está ??? eu estou bem até amanhã de manhã, áááá'";
            IFileSystemInterface fsi      = new FileSystemInterface(new FileIdentification(baseName),
                                                                    MultiBuffer.DefaultBufferSizeForData,
                                                                    new MockSession("test"));

            fsi.SetWritePosition(0, false);
            fsi.WriteString(s, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification(baseName), MultiBuffer.DefaultBufferSizeForData,
                                          new MockSession("test"));
            fsi.SetReadPosition(0);
            var s2 = fsi.ReadString();

            fsi.Close();
            AssertEquals(s, s2);
        }
コード例 #9
0
        public virtual void TestLong()
        {
            DeleteBase("testLong.ndb");
            const long           i   = 259999865;
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testLong.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));

            fsi.SetWritePosition(0, false);
            fsi.WriteLong(i, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testLong.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var i2 = fsi.ReadLong();

            AssertEquals(i, i2);
            fsi.Close();
        }
コード例 #10
0
        public virtual void TestByte()
        {
            DeleteBase("testByte.ndb");

            const byte           b   = 127;
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testByte.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));

            fsi.SetWritePosition(0, false);
            fsi.WriteByte(b, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testByte.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var b2 = fsi.ReadByte();

            AssertEquals(b, b2);
            fsi.Close();
        }
コード例 #11
0
        public virtual void TestChar()
        {
            DeleteBase("testChar.ndb");

            const char           c   = '\u00E1';
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testChar.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));

            fsi.SetWritePosition(0, false);
            fsi.WriteChar(c, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testChar.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var c2 = fsi.ReadChar();

            AssertEquals(c, c2);
            fsi.Close();
        }
コード例 #12
0
        public virtual void TestBoolean()
        {
            DeleteBase("testBoolean.ndb");

            const bool b1 = true;
            const bool b2 = false;
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testBoolean.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));
            fsi.SetWritePosition(0, false);
            fsi.WriteBoolean(b1, false);
            fsi.WriteBoolean(b2, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testBoolean.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var b11 = fsi.ReadBoolean();
            var b22 = fsi.ReadBoolean();
            AssertEquals(b1, b11);
            AssertEquals(b2, b22);
            fsi.Close();
        }
コード例 #13
0
        public virtual void TestBoolean()
        {
            DeleteBase("testBoolean.ndb");

            const bool           b1  = true;
            const bool           b2  = false;
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testBoolean.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));

            fsi.SetWritePosition(0, false);
            fsi.WriteBoolean(b1, false);
            fsi.WriteBoolean(b2, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testBoolean.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var b11 = fsi.ReadBoolean();
            var b22 = fsi.ReadBoolean();

            AssertEquals(b1, b11);
            AssertEquals(b2, b22);
            fsi.Close();
        }
コード例 #14
0
 public virtual void TestFloat()
 {
     DeleteBase("testFloat.ndb");
     const float f = (float) 12544548.12454;
     IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testFloat.ndb"),
                                                        MultiBuffer.DefaultBufferSizeForData,
                                                        new MockSession("test"));
     fsi.SetWritePosition(0, false);
     fsi.WriteFloat(f, false);
     fsi.Close();
     fsi = new FileSystemInterface(new FileIdentification("testFloat.ndb"),
                                   MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
     fsi.SetReadPosition(0);
     var f2 = fsi.ReadFloat();
     AssertTrue(f == f2);
     fsi.Close();
 }
コード例 #15
0
        public virtual void TestChar()
        {
            DeleteBase("testChar.ndb");

            const char c = '\u00E1';
            IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testChar.ndb"),
                                                               MultiBuffer.DefaultBufferSizeForData,
                                                               new MockSession("test"));
            fsi.SetWritePosition(0, false);
            fsi.WriteChar(c, false);
            fsi.Close();
            fsi = new FileSystemInterface(new FileIdentification("testChar.ndb"),
                                          MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
            fsi.SetReadPosition(0);
            var c2 = fsi.ReadChar();
            AssertEquals(c, c2);
            fsi.Close();
        }
コード例 #16
0
 public virtual void TestLong()
 {
     DeleteBase("testLong.ndb");
     const long i = 259999865;
     IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testLong.ndb"),
                                                        MultiBuffer.DefaultBufferSizeForData,
                                                        new MockSession("test"));
     fsi.SetWritePosition(0, false);
     fsi.WriteLong(i, false);
     fsi.Close();
     fsi = new FileSystemInterface(new FileIdentification("testLong.ndb"),
                                   MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
     fsi.SetReadPosition(0);
     var i2 = fsi.ReadLong();
     AssertEquals(i, i2);
     fsi.Close();
 }
コード例 #17
0
 public virtual void TestString()
 {
     var baseName = GetBaseName();
     const string s = "ola chico, como você está ??? eu estou bem até amanhã de manhã, áááá'";
     IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification(baseName),
                                                        MultiBuffer.DefaultBufferSizeForData,
                                                        new MockSession("test"));
     fsi.SetWritePosition(0, false);
     fsi.WriteString(s, false);
     fsi.Close();
     fsi = new FileSystemInterface(new FileIdentification(baseName), MultiBuffer.DefaultBufferSizeForData,
                                   new MockSession("test"));
     fsi.SetReadPosition(0);
     var s2 = fsi.ReadString();
     fsi.Close();
     AssertEquals(s, s2);
 }
コード例 #18
0
 public virtual void TestShort()
 {
     DeleteBase("testShort.ndb");
     const short s = 4598;
     IFileSystemInterface fsi = new FileSystemInterface(new FileIdentification("testShort.ndb"),
                                                        MultiBuffer.DefaultBufferSizeForData,
                                                        new MockSession("test"));
     fsi.SetWritePosition(0, false);
     fsi.WriteShort(s, false);
     fsi.Close();
     fsi = new FileSystemInterface(new FileIdentification("testShort.ndb"),
                                   MultiBuffer.DefaultBufferSizeForData, new MockSession("test"));
     fsi.SetReadPosition(0);
     var s2 = fsi.ReadShort();
     AssertEquals(s, s2);
     fsi.Close();
 }