Exemplo n.º 1
0
        public void EmptyAll()
        {
            var builder = new DatabaseBuilder();

            builder.Append(new Sample[] { });

            var bin = builder.Build();
            var db  = new MemoryDatabase(bin);

            db.SampleTable.All.Any().Should().BeFalse();
        }
Exemplo n.º 2
0
        public void ReplaceAll(System.Collections.Generic.IList <SkillMaster> data)
        {
            var newData = CloneAndSortBy(data, x => (x.SkillId, x.SkillLevel), System.Collections.Generic.Comparer <(int SkillId, int SkillLevel)> .Default);
            var table   = new SkillMasterTable(newData);

            memory = new MemoryDatabase(
                memory.SampleTable,
                table,
                memory.UserLevelTable

                );
        }
Exemplo n.º 3
0
        public void ReplaceAll(System.Collections.Generic.IList <Sample> data)
        {
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                table,
                memory.SkillMasterTable,
                memory.UserLevelTable

                );
        }
Exemplo n.º 4
0
        public void All()
        {
            var builder = new DatabaseBuilder();

            builder.Append(CreateData());

            var bin = builder.Build();
            var db  = new MemoryDatabase(bin);

            db.SampleTable.All.Select(x => x.Id).ToArray().Should().BeEquivalentTo(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            db.SampleTable.AllReverse.Select(x => x.Id).ToArray().Should().BeEquivalentTo(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }.Reverse());
            db.SampleTable.SortByAge.Select(x => x.Id).OrderBy(x => x).ToArray().Should().BeEquivalentTo(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
        }
Exemplo n.º 5
0
        public void Issue57()
        {
            var builder = new DatabaseBuilder();

            builder.Append(CreateData());

            var bin = builder.Build();
            var db  = new MemoryDatabase(bin);

            db.SampleTable.FindRangeByAge(2, 2).Select(x => x.Id).ToArray().Should().BeEquivalentTo(new int[] { });
            db.SampleTable.FindRangeByAge(30, 50).Select(x => x.Id).ToArray().Should().BeEquivalentTo(new int[] { 7, 8 });
            db.SampleTable.FindRangeByAge(100, 100).Select(x => x.Id).ToArray().Should().BeEquivalentTo(new int[] { });
        }
Exemplo n.º 6
0
        public void Diff(Sample[] addOrReplaceData)
        {
            var data    = DiffCore(memory.SampleTable.GetRawDataUnsafe(), addOrReplaceData, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                table,
                memory.SkillMasterTable,
                memory.UserLevelTable

                );
        }
Exemplo n.º 7
0
        public void RemoveSample(int[] keys)
        {
            var data    = RemoveCore(memory.SampleTable.GetRawDataUnsafe(), keys, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                table,
                memory.SkillMasterTable,
                memory.UserLevelTable

                );
        }
Exemplo n.º 8
0
        public void SingleDb()
        {
            var builder = new DatabaseBuilder();

            builder.Append(CreateData());

            var bin = builder.Build();
            var db  = new MemoryDatabase(bin);

            db.SampleTable.FindById(8).Age.Should().Be(49);

            var tableInfo = MemoryDatabase.GetTableInfo(bin);

            tableInfo[0].TableName.Should().Be("Sample");
        }
Exemplo n.º 9
0
        public void ReplaceAll(System.Collections.Generic.IList <ItemMaster> data)
        {
            var newData = CloneAndSortBy(data, x => x.ItemId, System.Collections.Generic.Comparer <int> .Default);
            var table   = new ItemMasterTable(newData);

            memory = new MemoryDatabase(
                memory.QuestMasterTable,
                table,
                memory.QuestMasterEmptyValidateTable,
                memory.ItemMasterEmptyValidateTable,
                memory.SequentialCheckMasterTable,
                memory.SingleMasterTable,
                memory.FailTable,
                memory.SampleTable,
                memory.SkillMasterTable,
                memory.TestMasterTable,
                memory.UserLevelTable

                );
        }
Exemplo n.º 10
0
        public void Diff(QuestMaster[] addOrReplaceData)
        {
            var data    = DiffCore(memory.QuestMasterTable.GetRawDataUnsafe(), addOrReplaceData, x => x.QuestId, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.QuestId, System.Collections.Generic.Comparer <int> .Default);
            var table   = new QuestMasterTable(newData);

            memory = new MemoryDatabase(
                table,
                memory.ItemMasterTable,
                memory.QuestMasterEmptyValidateTable,
                memory.ItemMasterEmptyValidateTable,
                memory.SequentialCheckMasterTable,
                memory.SingleMasterTable,
                memory.FailTable,
                memory.SampleTable,
                memory.SkillMasterTable,
                memory.TestMasterTable,
                memory.UserLevelTable

                );
        }
Exemplo n.º 11
0
        public void RemoveSample(int[] keys)
        {
            var data    = RemoveCore(memory.SampleTable.GetRawDataUnsafe(), keys, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                memory.QuestMasterTable,
                memory.ItemMasterTable,
                memory.QuestMasterEmptyValidateTable,
                memory.ItemMasterEmptyValidateTable,
                memory.SequentialCheckMasterTable,
                memory.SingleMasterTable,
                memory.FailTable,
                table,
                memory.SkillMasterTable,
                memory.TestMasterTable,
                memory.UserLevelTable

                );
        }
Exemplo n.º 12
0
        public void WithNull()
        {
            var builder = new DatabaseBuilder();

            builder.Append(new Sample[] { new Sample
                                          {
                                              Age       = 10,
                                              FirstName = null,
                                              Id        = 999,
                                              LastName  = "abcde"
                                          } });

            var bin = builder.Build();
            var db  = new MemoryDatabase(bin);

            var sample = db.SampleTable.FindById(999);

            sample.Age.Should().Be(10);
            sample.FirstName.Should().BeNull();
            sample.LastName.Should().Be("abcde");
        }
Exemplo n.º 13
0
        public void Meta()
        {
            var metaDb = MemoryDatabase.GetMetaDatabase();

            var sampleTable = metaDb.GetTableInfo("s_a_m_p_l_e");

            sampleTable.TableName.Should().Be("s_a_m_p_l_e");

            sampleTable.Properties[0].Name.Should().Be("Id");
            sampleTable.Properties[0].NameLowerCamel.Should().Be("id");
            sampleTable.Properties[0].NameSnakeCase.Should().Be("id");

            sampleTable.Properties[2].Name.Should().Be("FirstName");
            sampleTable.Properties[2].NameLowerCamel.Should().Be("firstName");
            sampleTable.Properties[2].NameSnakeCase.Should().Be("first_name");

            var primary = sampleTable.Indexes[0];

            primary.IsUnique.Should().BeTrue();
            primary.IndexProperties[0].Name.Should().Be("Id");
        }
Exemplo n.º 14
0
        public void ReplaceAll(System.Collections.Generic.IList <PersonModel> data)
        {
            var newData = CloneAndSortBy(data, x => x.RandomId, System.StringComparer.Ordinal);
            var table   = new PersonModelTable(newData);

            memory = new MemoryDatabase(
                table,
                memory.QuestMasterTable,
                memory.ItemMasterTable,
                memory.QuestMasterEmptyValidateTable,
                memory.ItemMasterEmptyValidateTable,
                memory.SequentialCheckMasterTable,
                memory.SingleMasterTable,
                memory.FailTable,
                memory.SampleTable,
                memory.SkillMasterTable,
                memory.TestMasterTable,
                memory.UserLevelTable

                );
        }
Exemplo n.º 15
0
        public void Diff(PersonModel[] addOrReplaceData)
        {
            var data    = DiffCore(memory.PersonModelTable.GetRawDataUnsafe(), addOrReplaceData, x => x.RandomId, System.StringComparer.Ordinal);
            var newData = CloneAndSortBy(data, x => x.RandomId, System.StringComparer.Ordinal);
            var table   = new PersonModelTable(newData);

            memory = new MemoryDatabase(
                table,
                memory.QuestMasterTable,
                memory.ItemMasterTable,
                memory.QuestMasterEmptyValidateTable,
                memory.ItemMasterEmptyValidateTable,
                memory.SequentialCheckMasterTable,
                memory.SingleMasterTable,
                memory.FailTable,
                memory.SampleTable,
                memory.SkillMasterTable,
                memory.TestMasterTable,
                memory.UserLevelTable

                );
        }
Exemplo n.º 16
0
 public ImmutableBuilder(MemoryDatabase memory)
 {
     this.memory = memory;
 }