Пример #1
0
        public void TestI()
        {
            var obj = new DbTable(new string[]
            {
                "Name",
                "Age",
                "Job"
            });

            string[]   Names  = { "Mike", "Nike", "Jess", "Eric", "Tram" };
            string[][] Values = { new string[] { "Mike", "15", "Student" },
                                  new string[] { "Nike", "12", "Student" },
                                  new string[] { "Jess", "12", "Student" },
                                  new string[] { "Eric", "11", "Student" },
                                  new string[] { "Tram", "12", "Teacher" } };
            obj.AddEntry(Names, Values);
            Assert.IsTrue(obj.Count == 5);

            obj.Export("test.dbtable");
            obj.Dispose();

            obj = new DbTable("test.dbtable");

            Assert.IsTrue(obj.Count == 5);
            Assert.IsTrue(obj.GetFieldLength == 3);
            Assert.IsTrue(obj.GetEntriesNames.Length == 5);
            Assert.IsTrue(obj.GetEntriesNames[0] == "Mike");
            Assert.IsTrue(obj.GetEntriesNames[1] == "Nike");
            Assert.IsTrue(obj.GetEntriesNames[4] == "Tram");

            obj.Dispose();
        }
Пример #2
0
        public void TestE()
        {
            var obj = new DbTable(new string[]
            {
                "Name",
                "Age",
                "Job"
            });

            // Add multiple entries at the same time
            string[]   Names  = { "Mike", "Nike", "Jess", "Eric", "Tram" };
            string[][] Values = { new string[] { "Mike", "15", "Student" },
                                  new string[] { "Nike", "12", "Student" },
                                  new string[] { "Jess", "12", "Student" },
                                  new string[] { "Eric", "11", "Student" },
                                  new string[] { "Tram", "12", "Teacher" } };
            obj.AddEntry(Names, Values);

            Assert.IsTrue(obj.Count == 5);
            Assert.IsTrue(obj.GetFieldLength == 3);

            // Remove multiple entries
            obj.RemoveEntry(Names);
            Assert.IsTrue(obj.Count == 0);
            Assert.IsTrue(obj.GetFieldLength == 3);

            obj.Dispose();
        }
Пример #3
0
        public void TestC()
        {
            DbTable obj = new DbTable(new string[]
            {
                "Name",
                "Age",
                "Job"
            });

            // Add entries one by one
            obj.AddEntry("Mike", new string[] { "Mike", "15", "Student" });
            obj.AddEntry("Nike", new string[] { "Nike", "12", "Student" });
            obj.AddEntry("Jess", new string[] { "Jess", "12", "Student" });
            obj.AddEntry("Eric", new string[] { "Eric", "11", "Student" });
            obj.AddEntry("Tram", new string[] { "Tram", "12", "Teacher" });

            Assert.IsTrue(obj.Count == 5);
            Assert.IsTrue(obj.GetFieldLength == 3);
            Assert.IsTrue(obj.GetEntriesNames.Length == 5);
            Assert.IsTrue(obj.GetEntriesNames[0] == "Mike");
            Assert.IsTrue(obj.GetEntriesNames[1] == "Nike");
            Assert.IsTrue(obj.GetEntriesNames[4] == "Tram");

            obj.Dispose();

            obj = new DbTable(new string[]
            {
                "Name",
                "Age",
                "Job"
            });

            // Add multiple entries at the same time
            string[]   Names  = { "Mike", "Nike", "Jess", "Eric", "Tram" };
            string[][] Values = { new string[] { "Mike", "15", "Student" },
                                  new string[] { "Nike", "12", "Student" },
                                  new string[] { "Jess", "12", "Student" },
                                  new string[] { "Eric", "11", "Student" },
                                  new string[] { "Tram", "12", "Teacher" } };
            obj.AddEntry(Names, Values);

            Assert.IsTrue(obj.Count == 5);
            Assert.IsTrue(obj.GetFieldLength == 3);
            Assert.IsTrue(obj.GetEntriesNames.Length == 5);
            Assert.IsTrue(obj.GetEntriesNames[0] == "Mike");
            Assert.IsTrue(obj.GetEntriesNames[1] == "Nike");
            Assert.IsTrue(obj.GetEntriesNames[4] == "Tram");

            obj.Dispose();
        }
Пример #4
0
        public void TestA()
        {
            DbTable obj = new DbTable(new string[]
            {
                "Name",
                "Age"
            });

            Assert.IsTrue(obj.FieldNames[0] == "Name");
            Assert.IsFalse(obj.FieldNames[1] != "Age");
            Assert.IsTrue(obj.GetFieldLength == 2);
            Assert.IsTrue(obj.Count == 0);

            obj.Dispose();
        }
Пример #5
0
        public void TestB()
        {
            DbTable obj = new DbTable(new string[]
            {
                "Name",
                "Age"
            });

            obj.AddEntry("Mike", new string[] { "Mike", "15" });
            Assert.IsTrue(obj.Count == 1);
            Assert.IsTrue(obj.GetFieldLength == 2);
            Assert.IsTrue(obj["Mike"][0] == "Mike");
            Assert.IsTrue(obj["Mike"][1] == "15");

            obj.Dispose();
        }
Пример #6
0
        public void TestF()
        {
            var obj = new DbTable(new string[]
            {
                "Name",
                "Age",
                "Job"
            });

            // Add multiple entries at the same time
            string[]   Names  = { "Mike", "Nike", "Jess", "Eric", "Tram" };
            string[][] Values = { new string[] { "Mike", "15", "Student" },
                                  new string[] { "Nike", "12", "Student" },
                                  new string[] { "Jess", "12", "Student" },
                                  new string[] { "Eric", "11", "Student" },
                                  new string[] { "Tram", "12", "Teacher" } };
            obj.AddEntry(Names, Values);

            Assert.IsTrue(obj["Mike"][1] == "15");
            Assert.IsTrue(obj["Nike"][1] == "12");
            Assert.IsTrue(obj["Nike"][2] == "Student");

            // Replace single entry
            string[] Single = { "Mike", "30", "Lawyers" };
            obj.ReplaceEntry("Mike", Single);

            Assert.IsTrue(obj["Mike"][1] == "30");
            Assert.IsTrue(obj["Mike"][2] == "Lawyers");

            // Replace multiple entries
            string[][] NewValues = { new string[] { "Mike", "10", "Student" },
                                     new string[] { "Nike", "25", "Hackers" },
                                     new string[] { "Jess", "11", "Student" },
                                     new string[] { "Eric", "09", "Student" },
                                     new string[] { "Tram", "10", "Teacher" } };
            obj.ReplaceEntry(Names, NewValues);

            Assert.IsTrue(obj["Mike"][1] == "10");
            Assert.IsTrue(obj["Nike"][1] == "25");
            Assert.IsTrue(obj["Nike"][2] == "Hackers");

            obj.Dispose();
        }
Пример #7
0
        public void TestD()
        {
            DbTable obj = new DbTable(new string[]
            {
                "Name",
                "Age"
            });

            // Add a single entry
            obj.AddEntry("Mike", new string[] { "Mike", "15" });
            Assert.IsTrue(obj.Count == 1);
            Assert.IsTrue(obj.GetFieldLength == 2);
            Assert.IsTrue(obj["Mike"][0] == "Mike");
            Assert.IsTrue(obj["Mike"][1] == "15");

            // Remove that entry
            obj.RemoveEntry("Mike");
            Assert.IsTrue(obj.Count == 0);
            Assert.IsTrue(obj.GetFieldLength == 2);

            obj.Dispose();
        }