示例#1
0
            public void AssertEquals(ByteArrayClass other)
            {
                Assert.AreEqual(Id, other.Id);
                var actual = other.Bytes;

                CollectionAssert.AreEqual(Bytes, actual);
            }
示例#2
0
        public void ByteArrayWhere()
        {
            //Byte Arrays for comparisson
            ByteArrayClass[] byteArrays = new ByteArrayClass[] {
                new ByteArrayClass() { bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 } }, //Range check
                new ByteArrayClass() { bytes = new byte[] { 0 } }, //null bytes need to be handled correctly
                new ByteArrayClass() { bytes = new byte[] { 0, 0 } },
                new ByteArrayClass() { bytes = new byte[] { 0, 1, 0 } },
                new ByteArrayClass() { bytes = new byte[] { 1, 0, 1 } },
                new ByteArrayClass() { bytes = new byte[] { } }, //Empty byte array should stay empty (and not become null)
                new ByteArrayClass() { bytes = null } //Null should be supported
            };

            SQLiteConnection database = new SQLiteConnection(TestPath.GetTempFileName());
            database.CreateTable<ByteArrayClass>();

            byte[] criterion = new byte[] { 1, 0, 1 };

            //Insert all of the ByteArrayClass
            int id = 0;
            foreach (ByteArrayClass b in byteArrays)
            {
                database.Insert(b);
                if (b.bytes != null && criterion.SequenceEqual<byte>(b.bytes))
                    id = b.ID;
            }
            Assert.AreNotEqual(0, id, "An ID wasn't set");

            //Get it back out
            ByteArrayClass fetchedByteArray = database.Table<ByteArrayClass>().Where(x => x.bytes == criterion).First();
            Assert.IsNotNull(fetchedByteArray);
            //Check they are the same
            Assert.AreEqual(id, fetchedByteArray.ID);
        }
示例#3
0
        public void LargeByteArray()
        {
            const int byteArraySize = 1024 * 1024;
            var       bytes         = new byte[byteArraySize];

            for (int i = 0; i < byteArraySize; i++)
            {
                bytes[i] = (byte)(i % 256);
            }

            var byteArray = new ByteArrayClass
            {
                bytes = bytes
            };

            var database = new SQLiteConnection(_sqlite3Platform, TestPath.GetTempFileName());

            database.CreateTable <ByteArrayClass>();

            //Insert the ByteArrayClass
            database.Insert(byteArray);

            //Get it back out
            ByteArrayClass[] fetchedByteArrays = database.Table <ByteArrayClass>().ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, 1);

            //Check they are the same
            byteArray.AssertEquals(fetchedByteArrays[0]);
        }
示例#4
0
        // [Description("Create A large byte array and check it can be stored and retrieved correctly")]
        public void LargeByteArrayTest()
        {
            const int byteArraySize = 1024 * 1024;
            var       bytes         = new byte[byteArraySize];

            for (int i = 0; i < byteArraySize; i++)
            {
                bytes[i] = (byte)(i % 256);
            }

            var byteArray = new ByteArrayClass {
                Bytes = bytes
            };

            var database = new OrmTestSession();

            database.CreateTable <ByteArrayClass>();

            //Insert the ByteArrayClass
            database.Insert(byteArray);

            //Get it back out
            ByteArrayClass[] fetchedByteArrays = database.Table <ByteArrayClass>().ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, 1);

            //Check they are the same
            byteArray.AssertEquals(fetchedByteArrays[0]);
        }
示例#5
0
        public void ByteArrayWhere()
        {
            //Byte Arrays for comparisson
            ByteArrayClass[] byteArrays = new ByteArrayClass[] {
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 }
                },                                                                                                   //Range check
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0 }
                },                                                                 //null bytes need to be handled correctly
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 1, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 0, 1 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { }
                },                                                               //Empty byte array should stay empty (and not become null)
                new ByteArrayClass()
                {
                    bytes = null
                }                                                     //Null should be supported
            };

            var db = TestDb.GetMemoryDb();

            db.CreateTable <ByteArrayClass>();

            byte[] criterion = new byte[] { 1, 0, 1 };

            //Insert all of the ByteArrayClass
            int id = 0;

            foreach (ByteArrayClass b in byteArrays)
            {
                db.Insert(b);
                if (b.bytes != null && criterion.SequenceEqual <byte>(b.bytes))
                {
                    id = b.ID;
                }
            }
            Assert.AreNotEqual(0, id, "An ID wasn't set");

            //Get it back out
            ByteArrayClass fetchedByteArray = db.Table <ByteArrayClass>().Where(x => x.bytes == criterion).First();

            Assert.IsNotNull(fetchedByteArray);
            //Check they are the same
            Assert.AreEqual(id, fetchedByteArray.ID);
        }
示例#6
0
        public void ByteArrays()
        {
            //Byte Arrays for comparisson
            ByteArrayClass[] byteArrays = new ByteArrayClass[] {
                new ByteArrayClass() { bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 } }, //Range check
                new ByteArrayClass() { bytes = new byte[] { 0 } }, //null bytes need to be handled correctly
                new ByteArrayClass() { bytes = new byte[] { 0, 0 } },
                new ByteArrayClass() { bytes = new byte[] { 0, 1, 0 } },
                new ByteArrayClass() { bytes = new byte[] { 1, 0, 1 } },
                new ByteArrayClass() { bytes = new byte[] { } }, //Empty byte array should stay empty (and not become null)
                new ByteArrayClass() { bytes = null } //Null should be supported
            };

            SQLiteConnection database = new SQLiteConnection(TestPath.GetTempFileName());
            database.CreateTable<ByteArrayClass>();

            //Insert all of the ByteArrayClass
            foreach (ByteArrayClass b in byteArrays)
                database.Insert(b);

            //Get them back out
            ByteArrayClass[] fetchedByteArrays = database.Table<ByteArrayClass>().OrderBy(x => x.ID).ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, byteArrays.Length);
            //Check they are the same
            for (int i = 0; i < byteArrays.Length; i++)
            {
                byteArrays[i].AssertEquals(fetchedByteArrays[i]);
            }
        }
        public void ByteArrayWhereNull()
        {
            //Byte Arrays for comparisson
            ByteArrayClass[] byteArrays = new ByteArrayClass[] {
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 }
                },                                                                                   //Range check
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0 }
                },                                                 //null bytes need to be handled correctly
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 1, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 0, 1 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { }
                },                                               //Empty byte array should stay empty (and not become null)
                new ByteArrayClass()
                {
                    bytes = null
                }                                     //Null should be supported
            };

            var database = new SQLiteConnection(_sqlite3Platform, TestPath.GetTempFileName());

            database.CreateTable <ByteArrayClass>();

            byte[] criterion = null;

            //Insert all of the ByteArrayClass
            int id = 0;

            foreach (ByteArrayClass b in byteArrays)
            {
                database.Insert(b);
                if (b.bytes == null)
                {
                    id = b.ID;
                }
            }
            Assert.AreNotEqual(0, id, "An ID wasn't set");

            //Get it back out
            ByteArrayClass fetchedByteArray = database.Table <ByteArrayClass>().Where(x => x.bytes == criterion).First();

            Assert.IsNotNull(fetchedByteArray);
            //Check they are the same
            Assert.AreEqual(id, fetchedByteArray.ID);
        }
示例#8
0
        public void LargeByteArray()
        {
            const int byteArraySize = 1024 * 1024;

            byte[] bytes = new byte[byteArraySize];
            for (int i = 0; i < byteArraySize; i++)
            {
                bytes[i] = (byte)(i % 256);
            }

            ByteArrayClass byteArray = new ByteArrayClass()
            {
                bytes = bytes
            };

            var db = TestDb.GetMemoryDb();

            db.CreateTable <ByteArrayClass>();

            //Insert the ByteArrayClass
            db.Insert(byteArray);

            //Get it back out
            ByteArrayClass[] fetchedByteArrays = db.Table <ByteArrayClass>().ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, 1);

            //Check they are the same
            byteArray.AssertEquals(fetchedByteArrays[0]);
        }
示例#9
0
        public void ByteArray_deserialize_should_be_correct()
        {
            string         json = "{\"ByteArray\": [0, 1, 2, 3],\"NullByteArray\": null}";
            ByteArrayClass c    = JsonSerializer.ToObject <ByteArrayClass>(json);

            Assert.IsNotNull(c.ByteArray);
            Assert.AreEqual(4, c.ByteArray.Length);
            CollectionAssert.AreEquivalent(new byte[] { 0, 1, 2, 3 }, c.ByteArray);
        }
示例#10
0
        public void ByteArray_Base64_deserialize_should_be_correct()
        {
            string         json           = "{\"ByteArray\":\"VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ==\",\"NullByteArray\":null}";
            var            TestData       = System.Text.Encoding.UTF8.GetBytes("This is some test data!!!");
            ByteArrayClass byteArrayClass = JsonSerializer.ToObject <ByteArrayClass>(json);

            CollectionAssert.AreEquivalent(TestData, byteArrayClass.ByteArray);
            Assert.AreEqual(null, byteArrayClass.NullByteArray);
        }
示例#11
0
        public void ByteArrays()
        {
            ByteArrayClass[] byteArrays = new ByteArrayClass[]
            {
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 }
                },                                                                                   //Range check
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0 }
                },                                                                 //null bytes need to be handled correctly
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 1, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 0, 1 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { }
                },                                               //Empty byte array should stay empty (and not become null)
                new ByteArrayClass()
                {
                    bytes = null
                }                                                     //Null should be supported
            };

            SQLiteConnection database = new SQLiteConnection(Path.GetTempFileName());

            database.CreateTable <ByteArrayClass>();

            //Insert all of the ByteArrayClass
            foreach (ByteArrayClass b in byteArrays)
            {
                database.Insert(b);
            }

            //Get them back out
            ByteArrayClass[] fetchedByteArrays = database.Table <ByteArrayClass>().OrderBy(x => x.ID).ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, byteArrays.Length);

            //Check they are the same
            for (int i = 0; i < byteArrays.Length; i++)
            {
                byteArrays[i].AssertEquals(fetchedByteArrays[i]);
            }
        }
示例#12
0
        public void ByteArrays()
        {
            //Byte Arrays for comparisson
            ByteArrayClass[] byteArrays = new ByteArrayClass[] {
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 }
                },                                                                                                   //Range check
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0 }
                },                                                                 //null bytes need to be handled correctly
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 0, 1, 0 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { 1, 0, 1 }
                },
                new ByteArrayClass()
                {
                    bytes = new byte[] { }
                },                                                               //Empty byte array should stay empty (and not become null)
                new ByteArrayClass()
                {
                    bytes = null
                }                                                     //Null should be supported
            };

            var db = TestDb.GetMemoryDb();

            db.CreateTable <ByteArrayClass>();

            //Insert all of the ByteArrayClass
            foreach (ByteArrayClass b in byteArrays)
            {
                db.Insert(b);
            }

            //Get them back out
            ByteArrayClass[] fetchedByteArrays = db.Table <ByteArrayClass>().OrderBy(x => x.ID).ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, byteArrays.Length);
            //Check they are the same
            for (int i = 0; i < byteArrays.Length; i++)
            {
                byteArrays[i].AssertEquals(fetchedByteArrays[i]);
            }
        }
        public void SerializeByteArrayClass()
        {
            ByteArrayClass byteArrayClass = new ByteArrayClass();

            byteArrayClass.ByteArray     = TestData;
            byteArrayClass.NullByteArray = null;

            string json = JsonConvert.SerializeObject(byteArrayClass, Formatting.Indented);

            Assert.AreEqual("{\r\n  \"ByteArray\": \"VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ==\",\r\n  \"NullByteArray\": null\r\n}", json);
        }
示例#14
0
        public void DeserializeByteArrayClass()
        {
            string json = @"{
  ""ByteArray"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="",
  ""NullByteArray"": null
}";

            ByteArrayClass byteArrayClass = JsonConvert.DeserializeObject <ByteArrayClass>(json);

            CollectionAssert.AreEquivalent(TestData, byteArrayClass.ByteArray);
            Assert.AreEqual(null, byteArrayClass.NullByteArray);
        }
示例#15
0
        public void DeserializeByteArrayFromJsonArray()
        {
            string json = @"{
  ""ByteArray"": [0, 1, 2, 3],
  ""NullByteArray"": null
}";

            ByteArrayClass c = JsonConvert.DeserializeObject <ByteArrayClass>(json);

            Assert.IsNotNull(c.ByteArray);
            Assert.AreEqual(4, c.ByteArray.Length);
            CollectionAssert.AreEquivalent(new byte[] { 0, 1, 2, 3 }, c.ByteArray);
        }
    public void SerializeByteArrayClass()
    {
      ByteArrayClass byteArrayClass = new ByteArrayClass();
      byteArrayClass.ByteArray = TestData;
      byteArrayClass.NullByteArray = null;

      string json = JsonConvert.SerializeObject(byteArrayClass, Formatting.Indented, new BinaryConverter());

      Assert.AreEqual(@"{
  ""ByteArray"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="",
  ""NullByteArray"": null
}", json);
    }
示例#17
0
			public void AssertEquals(ByteArrayClass other)
			{
				Assert.AreEqual(other.ID, ID);
				if (other.bytes == null || bytes == null) {
					Assert.IsNull (other.bytes);
					Assert.IsNull (bytes);
				}
				else {
					Assert.AreEqual(other.bytes.Length, bytes.Length);
					for (var i = 0; i < bytes.Length; i++) {
						Assert.AreEqual(other.bytes[i], bytes[i]);
					}
				}
			}
示例#18
0
        public void ByteArrayClass_serialize_should_be_correct_format()
        {
            var            TestData       = System.Text.Encoding.UTF8.GetBytes("This is some test data!!!");
            ByteArrayClass byteArrayClass = new ByteArrayClass
            {
                ByteArray     = TestData,
                NullByteArray = null
            };

            string json = JsonSerializer.ToJson(byteArrayClass);

            Assert.IsTrue(JsonValidator.IsValid(json));
            Assert.AreEqual("{\"ByteArray\":[84,104,105,115,32,105,115,32,115,111,109,101,32,116,101,115,116,32,100,97,116,97,33,33,33],\"NullByteArray\":null}", json);
        }
示例#19
0
        public void SerializeByteArrayClass()
        {
            ByteArrayClass byteArrayClass = new ByteArrayClass();

            byteArrayClass.ByteArray     = TestData;
            byteArrayClass.NullByteArray = null;

            string json = JsonConvert.SerializeObject(byteArrayClass, Formatting.Indented);

            StringAssert.AreEqual(@"{
  ""ByteArray"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="",
  ""NullByteArray"": null
}", json);
        }
示例#20
0
        public void SerializeObjectForBinaryDataSucceeds()
        {
            var byteArrayClass = new ByteArrayClass
            {
                ByteArray     = k_TestData,
                NullByteArray = null
            };

            var json = JsonConvert.SerializeObject(byteArrayClass, Formatting.Indented);

            StringUtils.AssertAreEqualWithNormalizedLineEndings(@"{
  ""ByteArray"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="",
  ""NullByteArray"": null
}", json);
        }
        public void EmptyByteArraySavedAndRetrievedCorrectlyTest()
        {
            //Empty byte array should stay empty (and not become null)
            var byteArray = new ByteArrayClass { Bytes = new byte[] { } };

            var database = new OrmTestSession();
            database.CreateTable<ByteArrayClass>();

            database.Insert(byteArray);

            //Get them back out
            var fetchedByteArray = database.Table<ByteArrayClass>().Single();

            //Check they are the same
            ArrayAssert.AreEqual(byteArray.Bytes, fetchedByteArray.Bytes);
        }
示例#22
0
        public void ByteArrayClass_use_option_serialize_should_be_correct_format()
        {
            var            TestData       = System.Text.Encoding.UTF8.GetBytes("This is some test data!!!");
            ByteArrayClass byteArrayClass = new ByteArrayClass
            {
                ByteArray     = TestData,
                NullByteArray = null
            };

            string json = JsonSerializer.ToJson(byteArrayClass, new JsonSerializerOption()
            {
                IsByteArrayFormatBase64 = true
            });

            Assert.IsTrue(JsonValidator.IsValid(json));
            Assert.AreEqual("{\"ByteArray\":\"VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ==\",\"NullByteArray\":null}", json);
        }
示例#23
0
 public void AssertEquals(ByteArrayClass other)
 {
     Assert.AreEqual(other.ID, ID);
     if (other.bytes == null || bytes == null)
     {
         Assert.IsNull(other.bytes);
         Assert.IsNull(bytes);
     }
     else
     {
         Assert.AreEqual(other.bytes.Length, bytes.Length);
         for (int i = 0; i < bytes.Length; i++)
         {
             Assert.AreEqual(other.bytes[i], bytes[i]);
         }
     }
 }
示例#24
0
        public void NullByteArraySavedAndRetrievedCorrectlyTest()
        {
            var byteArray = new ByteArrayClass {
                Bytes = null
            };

            var database = new OrmTestSession();

            database.CreateTable <ByteArrayClass>();

            database.Insert(byteArray);

            //Get them back out
            var fetchedByteArray = database.Table <ByteArrayClass>().Single();

            //Check they are the same
            ArrayAssert.AreEqual(byteArray.Bytes, fetchedByteArray.Bytes);
        }
示例#25
0
        public void EmptyByteArraySavedAndRetrievedCorrectlyTest()
        {
            //Empty byte array should stay empty (and not become null)
            var byteArray = new ByteArrayClass {
                Bytes = new byte[] { }
            };

            var database = new OrmTestSession();

            database.CreateTable <ByteArrayClass>();

            database.Insert(byteArray);

            //Get them back out
            var fetchedByteArray = database.Table <ByteArrayClass>().Single();

            //Check they are the same
            ArrayAssert.AreEqual(byteArray.Bytes, fetchedByteArray.Bytes);
        }
示例#26
0
        public void LargeByteArray()
        {
            const int byteArraySize = 1024 * 1024;
            byte[] bytes = new byte[byteArraySize];
            for (int i = 0; i < byteArraySize; i++)
                bytes[i] = (byte)(i % 256);

            ByteArrayClass byteArray = new ByteArrayClass() { bytes = bytes };

            SQLiteConnection database = new SQLiteConnection(TestPath.GetTempFileName());
            database.CreateTable<ByteArrayClass>();

            //Insert the ByteArrayClass
            database.Insert(byteArray);

            //Get it back out
            ByteArrayClass[] fetchedByteArrays = database.Table<ByteArrayClass>().ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, 1);

            //Check they are the same
            byteArray.AssertEquals(fetchedByteArrays[0]);
        }
示例#27
0
 public void AssertEquals(ByteArrayClass other)
 {
     Assert.AreEqual(other.ID, ID);
     CollectionAssert.AreEqual(other.bytes, bytes);
 }
示例#28
0
 public void LoadBuiltinClasses()
 {
     classes["Int"]               = new IntClass();
     classes["Float"]             = new FloatClass();
     classes["Boolean"]           = new BooleanClass();
     classes["String"]            = new StringClass();
     classes["Char"]              = new CharClass();
     classes["Byte"]              = new ByteClass();
     classes["Message"]           = new MessageClass();
     classes["Unassigned"]        = new UnassignedClass();
     classes["Tuple"]             = new TupleClass();
     classes["NameValue"]         = new NameValueClass();
     classes["Lambda"]            = new LambdaClass();
     classes["Void"]              = new VoidClass();
     classes["Some"]              = new SomeClass();
     classes["None"]              = new NoneClass();
     classes["Array"]             = new ArrayClass();
     classes["Iterator"]          = new IteratorClass();
     classes["LazyIterator"]      = new LazyIteratorClass();
     classes["StreamIterator"]    = new StreamIteratorClass();
     classes["Any"]               = new AnyClass();
     classes["Placeholder"]       = new PlaceholderClass();
     classes["Range"]             = new RangeClass();
     classes["Dictionary"]        = new DictionaryClass();
     classes["Container"]         = new ContainerClass();
     classes["Unmatched"]         = new UnmatchedClass();
     classes["Complex"]           = new ComplexClass();
     classes["Rational"]          = new RationalClass();
     classes["Long"]              = new LongClass();
     classes["Lazy"]              = new LazyClass();
     classes["YieldingInvokable"] = new YieldingInvokableClass();
     classes["Del"]               = new DelClass();
     classes["Slice"]             = new SliceClass();
     classes["End"]               = new EndClass();
     classes["List"]              = new ListClass();
     classes["Arguments"]         = new ArgumentsClass();
     classes["Symbol"]            = new SymbolClass();
     classes["Infinity"]          = new InfinityClass();
     classes["OpenRange"]         = new OpenRangeClass();
     classes["KeyValue"]          = new KeyValueClass();
     classes["Regex"]             = new RegexClass();
     classes["Pattern"]           = new PatternClass();
     classes["PackageFunction"]   = new PackageFunctionClass();
     classes["Sys"]               = new SysClass();
     classes["Math"]              = new MathClass();
     classes["RuntimeFunction"]   = new RuntimeFunctionClass();
     classes["Reference"]         = new ReferenceClass();
     classes["Group"]             = new RegexGroupClass();
     classes["Match"]             = new RegexMatchClass();
     classes["Date"]              = new DateClass();
     classes["Interval"]          = new IntervalClass();
     classes["TypeConstraint"]    = new TypeConstraintClass();
     classes["ByteArray"]         = new ByteArrayClass();
     classes["Selector"]          = new SelectorClass();
     classes["Number"]            = new NumberClass();
     classes["Collection"]        = new CollectionClass();
     classes["TextFinding"]       = new TextFindingClass();
     classes["SkipTake"]          = new SkipTakeClass();
     classes["Constructor"]       = new ConstructorClass();
     classes["MutString"]         = new MutStringClass();
     classes["Error"]             = new ErrorClass();
     classes["Success"]           = new SuccessClass();
     classes["Failure"]           = new FailureClass();
     classes["Optional"]          = new OptionalClass();
     classes["Result"]            = new ResultClass();
     classes["Monad"]             = new MonadClass();
     classes["Unit"]              = new UnitClass();
     classes["YieldReturn"]       = new YieldReturnClass();
     classes["Index"]             = new IndexClass();
     classes["Cycle"]             = new CycleClass();
     classes["Set"]               = new SetClass();
 }
示例#29
0
 public void AssertEquals(ByteArrayClass other)
 {
     Assert.AreEqual(other.ID, ID);
     CollectionAssert.AreEqual(other.bytes, bytes);
 }
        public void ZeroByteArraySavedAndRetrievedCorrectlyTest()
        {
            var byteArray = new ByteArrayClass { Bytes = new byte[] { 0 } };

            var database = new OrmTestSession();
            database.CreateTable<ByteArrayClass>();

            database.Insert(byteArray);

            //Get them back out
            var fetchedByteArray = database.Table<ByteArrayClass>().Single();

            //Check they are the same
            ArrayAssert.AreEqual(byteArray.Bytes, fetchedByteArray.Bytes);
        }
        public void SerializeByteArrayClass()
        {
            ByteArrayClass byteArrayClass = new ByteArrayClass();
            byteArrayClass.ByteArray = TestData;
            byteArrayClass.NullByteArray = null;

            string json = JsonConvert.SerializeObject(byteArrayClass, Formatting.Indented);

            Assert.AreEqual("{\r\n  \"ByteArray\": \"VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ==\",\r\n  \"NullByteArray\": null\r\n}", json);
        }
        // [Description("Create A large byte array and check it can be stored and retrieved correctly")]
        public void LargeByteArrayTest()
        {
            const int byteArraySize = 1024 * 1024;
            var bytes = new byte[byteArraySize];
            for (int i = 0; i < byteArraySize; i++)
            {
                bytes[i] = (byte)(i % 256);
            }

            var byteArray = new ByteArrayClass { Bytes = bytes };

            var database = new OrmTestSession();
            database.CreateTable<ByteArrayClass>();

            //Insert the ByteArrayClass
            database.Insert(byteArray);

            //Get it back out
            ByteArrayClass[] fetchedByteArrays = database.Table<ByteArrayClass>().ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, 1);

            //Check they are the same
            byteArray.AssertEquals(fetchedByteArrays[0]);
        }
 public void AssertEquals(ByteArrayClass other)
 {
     Assert.AreEqual(Id, other.Id);
     var actual = other.Bytes;
     CollectionAssert.AreEqual(Bytes, actual);
 }
示例#34
0
        public void LargeByteArray()
        {
            const int byteArraySize = 1024*1024;
            var bytes = new byte[byteArraySize];
            for (int i = 0; i < byteArraySize; i++)
            {
                bytes[i] = (byte) (i%256);
            }

            var byteArray = new ByteArrayClass
            {
                bytes = bytes
            };

            var database = new SQLiteConnection(_sqlite3Platform, TestPath.CreateTemporaryDatabase());
            database.CreateTable<ByteArrayClass>();

            //Insert the ByteArrayClass
            database.Insert(byteArray);

            //Get it back out
            ByteArrayClass[] fetchedByteArrays = database.Table<ByteArrayClass>().ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, 1);

            //Check they are the same
            byteArray.AssertEquals(fetchedByteArrays[0]);
        }