Exemplo n.º 1
0
        protected void InsertEmployeesBase()
        {
            var provider = GetIntProvider();

            using (var cn = GetConnection())
            {
                DropTable(cn, "Organization");
                provider.CreateTable <Organization>(cn);

                DropTable(cn, "Employee");
                provider.CreateTable <EmployeeInt>(cn);

                var tdg = new TestDataGenerator();
                tdg.Generate <Organization>(5, (record) =>
                {
                    record.Name = tdg.Random(Source.UniqueWidget);
                }, (records) =>
                {
                    foreach (var record in records)
                    {
                        provider.Save(cn, record);
                    }
                });

                var orgIds = cn.Query <int>("SELECT Id FROM Organization").ToArray();

                tdg.Generate <EmployeeInt>(100, (record) =>
                {
                    record.OrganizationId = tdg.Random(orgIds);
                    record.FirstName      = tdg.Random(Source.FirstName);
                    record.LastName       = tdg.Random(Source.LastName);
                    record.Email          = $"{record.FirstName}.{record.LastName}@nowhere.org";
                }, (records) =>
                {
                    foreach (var record in records)
                    {
                        provider.Save(cn, record);
                    }
                });
            }
        }
        private void InitItemTables()
        {
            using (var cn = GetConnection())
            {
                DropTable(cn, "Item");
                DropTable(cn, "ItemType");
                GetIntProvider().CreateTable <ItemType>(cn);
                GetIntProvider().CreateTable <Item>(cn);

                var tdg = new TestDataGenerator();
                tdg.Generate <ItemType>(10, (it) =>
                {
                    it.Name = tdg.Random(Source.WidgetName) + tdg.RandomInRange(100, 999).ToString();
                }, (records) =>
                {
                    foreach (var record in records)
                    {
                        GetIntProvider().Save(cn, record);
                    }
                });
            }
        }
Exemplo n.º 3
0
        public void CheckEnumerator()
        {
            var table_ = TestDataGenerator.GetTestData();

            List <int> keys = new List <int> {
                0, 1, 2, 3
            };
            List <string> values = new List <string> {
                "Нуль", "Один", "Два", "Три"
            };

            keys.Reverse();
            values.Reverse();

            int keyIndex    = 0;
            int valuesIndex = 0;

            foreach (var item in table_)
            {
                Assert.True(item.Key == keys[keyIndex++] &&
                            item.Value == values[valuesIndex++], "Enumerating was failed");
            }
        }
Exemplo n.º 4
0
        public void ContainsKey(int key, bool expectedResult)
        {
            var table_ = TestDataGenerator.GetTestData();

            Assert.True(table_.ContainsKey(key) == expectedResult, $"Container doesn't contain key = {key}");
        }
Exemplo n.º 5
0
        public void CheckCount()
        {
            var table_ = TestDataGenerator.GetTestData();

            Assert.True(table_.Count == 4, $"Counting was failed");
        }
Exemplo n.º 6
0
        public void RemoveOneElementByKey(int key, bool expectedResult)
        {
            var table_ = TestDataGenerator.GetTestData();

            Assert.True(table_.Remove(key) == expectedResult, $"Failed to remove element by key = {key}");
        }
Exemplo n.º 7
0
        public void TestingIt()
        {
            MutableGlobalTracer.Initialize(globalTracer: new FakeConsoleTracer("A"));
            TestDataGenerator.GenerateTestData().Wait();
            return;

            MutableGlobalTracer.Initialize(globalTracer: new FakeConsoleTracer("A"));

            using (GlobalTracer.Instance
                   .BuildSpan("Overall")
                   .StartActive())
            {
                // Op 1
                var operation1 = Task.Run(
                    async() =>
                {
                    //using (MutableGlobalTracer.UseTracer(new FakeFileTracer("Operation1 Path")))
                    using (MutableGlobalTracer.UseTracer(new FakeConsoleTracer("B")))
                    {
                        using (GlobalTracer.Instance
                               .BuildSpan("Operation1.1")
                               .StartActive())
                        {
                        }

                        // To make sure operation3 has also started before this finishes
                        await Task.Delay(100);

                        using (GlobalTracer.Instance
                               .BuildSpan("Operation1.2")
                               .StartActive())
                        {
                        }
                    }
                });

                // Op 2
                //var operation2 = Task.Run(
                //    async () =>
                //    {
                //        using (MutableGlobalTracer.UsingTracer(new FakeFileTracer("Operation2 Path"))
                //            .BuildSpan("Operation2")
                //            .StartActive())
                //        {
                //        }
                //    });

                // Op 3
                var operation3 = Task.Run(
                    async() =>
                {
                    using (MutableGlobalTracer.UseTracer(new FakeConsoleTracer("C")))
                    {
                        using (GlobalTracer.Instance
                               .BuildSpan("Operation3.1")
                               .StartActive())
                        {
                        }

                        // To make sure operation3 has also started before this finishes
                        await Task.Delay(100);

                        using (GlobalTracer.Instance
                               .BuildSpan("Operation3.2")
                               .StartActive())
                        {
                        }
                    }
                });

                operation1.Wait();
                operation3.Wait();
            }
        }