Beispiel #1
0
 public void LoadMappedfile()
 {
     try
     {
         var map = MappedFile.LoadMap("map1.dat", "../../../Db/");
         Assert.IsTrue(map != null);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Beispiel #2
0
        public void DeleteTest()
        {
            try
            {
                var map = MappedFile.LoadMap("map1.dat", "../../../Db/");
                map.Delete(0);
                var dbDoc = JsonConvert.DeserializeObject <TestDocument>(map.Read(0));

                Assert.IsNull(dbDoc);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Beispiel #3
0
        public void ReadMapTest()
        {
            try
            {
                var map = MappedFile.LoadMap("map1.dat", "../../../Db/");
                var doc = new TestDocument
                {
                    FirstName   = "Steve",
                    LastName    = "Ruben",
                    DateOfBirth = new DateTime(1891, 10, 11),
                    Height      = 5.6,
                    Weight      = 200.00
                };

                var dbDoc = JsonConvert.DeserializeObject <TestDocument>(map.Read(0));
                Assert.IsTrue(dbDoc.FirstName.Equals(doc.FirstName));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Beispiel #4
0
        public void WriteManyMapTest()
        {
            try
            {
                var map = MappedFile.LoadMap("map1.dat", "../../../Db/");
                var doc = new TestDocument
                {
                    FirstName   = "Steve",
                    LastName    = "Ruben",
                    DateOfBirth = new DateTime(1891, 10, 11),
                    Height      = 5.6,
                    Weight      = 200.00
                };

                var docJson = JsonConvert.SerializeObject(doc);
                var docs    = new List <string>
                {
                    docJson,
                    docJson,
                    docJson,
                    docJson,
                    docJson,
                    docJson,
                    docJson,
                    docJson,
                    docJson,
                    docJson,
                    docJson,
                    docJson
                };

                var indicies = docs.AsParallel().Select(map.Write).ToList();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Beispiel #5
0
        public void WriteMapTest()
        {
            try
            {
                var map = MappedFile.LoadMap("map1.dat", "../../../Db/");
                var doc = new TestDocument
                {
                    FirstName   = "Steve",
                    LastName    = "Ruben",
                    DateOfBirth = new DateTime(1891, 10, 11),
                    Height      = 5.6,
                    Weight      = 200.00
                };

                var docJson = JsonConvert.SerializeObject(doc);
                var index   = map.Write(docJson);

                Assert.IsTrue(index != -1);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }