public void TestNestedGenericCacheTypes()
        {
            var cfg = new CacheConfiguration(TestUtils.TestName)
            {
                QueryEntities = new[] { new QueryEntity(typeof(int), typeof(GenericTest <GenericTest2 <string> >)) }
            };

            var cache = Ignition.GetIgnite().GetOrCreateCache <int, GenericTest <GenericTest2 <string> > >(cfg);
            var key   = 1;
            var value = new GenericTest <GenericTest2 <string> >(new GenericTest2 <string>("foo"));

            cache[key] = value;

            var query = cache.AsCacheQueryable()
                        .Where(x => x.Value.Foo.Bar == value.Foo.Bar)
                        .Select(x => x.Value.Foo);

            var sql = query.ToCacheQueryable().GetFieldsQuery().Sql;
            var res = query.ToList();

            Assert.AreEqual(1, res.Count);
            Assert.AreEqual(value.Foo.Bar, res[0].Bar);

            var expectedSql = string.Format("select _T0.FOO from \"{0}\".GENERICTEST as", cache.Name);

            StringAssert.StartsWith(expectedSql, sql);
        }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        public static void RunTests()
        {
            Console = Boot.Console;

            Console.Goto(20, 0);
            Console.Color = Colors.Yellow;
            Console.Write("[");
            Console.Color = Colors.White;
            Console.Write("Tests");
            Console.Color = Colors.Yellow;
            Console.Write("]");

            var stringTest = new StringTest();
            var interfaceTest = new InterfaceTest();
            var genericsTest = new GenericTest();
            var generics2Test = new Generic2Test();
            var isInstanceTest = new IsInstTest();
            var exceptionTest = new ExceptionTest();
            var plugTestTest = new PlugTestTest();
            var compareTest = new ComparisonTest();
            var simpleTest = new SimpleTest();

            stringTest.Test();
            interfaceTest.Test();
            genericsTest.Test();
            generics2Test.Test();
            isInstanceTest.Test();
            exceptionTest.Test();
            plugTestTest.Test();
            compareTest.Test();
            simpleTest.Test();
        }
        public void TestGenericQueryTypes()
        {
            var ignite = Ignition.Start(TestUtils.GetTestConfiguration());

            var cfg = new CacheConfiguration(TestUtils.TestName)
            {
                QueryEntities = new[] { new QueryEntity(typeof(GenericTest <int>), typeof(GenericTest2 <string>)) }
            };

            var cache = ignite.GetOrCreateCache <GenericTest <int>, GenericTest2 <string> >(cfg);
            var key   = new GenericTest <int>(1);
            var value = new GenericTest2 <string>("foo");

            cache[key] = value;

            var binType          = ignite.GetBinary().GetBinaryType(value.GetType());
            var expectedTypeName = BinaryBasicNameMapper.FullNameInstance.GetTypeName(value.GetType().FullName);
            var expectedTypeId   = BinaryUtils.GetStringHashCodeLowerCase(expectedTypeName);

            Assert.AreEqual(expectedTypeName, binType.TypeName);
            Assert.AreEqual(expectedTypeId, binType.TypeId);

            var queryEntity = cache.GetConfiguration().QueryEntities.Single();

            Assert.AreEqual(expectedTypeName, queryEntity.ValueTypeName);

            var sqlRes = cache.Query(new SqlFieldsQuery("SELECT Foo, Bar from GENERICTEST2")).Single();

            Assert.AreEqual(key.Foo, sqlRes[0]);
            Assert.AreEqual(value.Bar, sqlRes[1]);
        }
示例#4
0
        static void Main(string[] args)
        {
            Ghost fastGhost = new Ghost("FastGhost", 5, 10);
            Spawner Spawner = new Spawner(fastGhost);

            List<Ghost> fastGhosts = new List<Ghost>();

            for (int i = 0; i < 10; i++)
            {
                fastGhosts.Add((Ghost) Spawner.SpawnMonster());

                fastGhosts[i].PrintStats();

            }

            // -----------
            // using callbacks:
            Spawner ghostCallbackSpawner = new Spawner(fastGhost.SpawnGhost);
            Ghost g = (Ghost) ghostCallbackSpawner.SpawnMonsterViaCallback();
            g.PrintStats();

            // -----------
            // generic test (similar to C++ templates):
            GenericTest<int> _tInt = new GenericTest<int>(5);
            GenericTest<string> _tString = new GenericTest<string>("hello");
            _tInt.Write();
            _tString.Write();

            SpawnerFor<Ghost> spawnerForGhost = new SpawnerFor<Ghost>();
            Ghost gg = spawnerForGhost.SpawnMonster();
            gg.PrintStats();

            Console.ReadLine();
        }
示例#5
0
        /// <summary>
        /// 
        /// </summary>
        public static void RunTests()
        {
            Screen.Goto(23, 0);
            Screen.Color = Colors.Yellow;
            Screen.Write("[");
            Screen.Color = Colors.White;
            Screen.Write("Tests");
            Screen.Color = Colors.Yellow;
            Screen.Write("]");

            var stringTest = new StringTest();
            var interfaceTest = new InterfaceTest();
            var genericsTest = new GenericTest();
            var generics2Test = new Generic2Test();
            var isInstanceTest = new IsInstTest();
            var exceptionTest = new ExceptionTest();
            var plugTestTest = new PlugTestTest();

            stringTest.Test();
            interfaceTest.Test();
            genericsTest.Test();
            generics2Test.Test();
            isInstanceTest.Test();
            exceptionTest.Test();
            plugTestTest.Test();
        }
示例#6
0
 public static void test()
 {
     GenericTest <int, int> test1;
     var t2 = new GenericTest <int, float>();
     // string doesn't have a parameterless constructor:
     // GenericTest<string, int> t3 =
     //      new GenericTest<string, int>();
     GenericTest <int, B> t4 = new GenericTest <int, B>();
 }
    public static void staticMethodDemo()
    {
        GenericTest <int, string> .statMethod(1);

        GenericTest <int, string> .statMethod(2);

        GenericTest <int, bool> .statMethod(3);

        System.Console.WriteLine("<int, string>    typeCounter: " +
                                 GenericTest <int, string> .typeCounter);
        System.Console.WriteLine("<int, bool>      typeCounter: " +
                                 GenericTest <int, bool> .typeCounter);
    }
示例#8
0
        //static void Main(string[] args)
        //{
        //    int intValue = default;
        //    BigIntger bitIntValue = default;

        //    Console.WriteLine(intValue);
        //    Console.WriteLine(bitIntValue);

        //    string text = default;
        //    Console.WriteLine(text ?? "(null)");
        //}

        static void Main(string[] args)
        {
            GenericTest <int> t = new GenericTest <int>();

            Console.WriteLine(t.GetDefaultValue());

            int        intValue    = default;
            BigInteger bigIntValue = default;

            Console.WriteLine(intValue);        // 출력 결과: 0
            Console.WriteLine(bigIntValue);     // 출력 결과: 0

            string txt = default;

            Console.WriteLine(txt ?? "(null)"); // 출력 결과: (null)
        }
示例#9
0
        /// <summary>
        ///
        /// </summary>
        public static void RunTests()
        {
            Console = Boot.Console;

            Console.Goto(2, 0);
            Console.Color = Colors.Yellow;
            Console.Write("[");
            Console.Color = Colors.White;
            Console.Write("Tests");
            Console.Color = Colors.Yellow;
            Console.Write("]");
            Console.WriteLine();
            Console.WriteLine();
            Console.Color = Colors.Yellow;

            var delegateTest = new DelegateTest();
            var stringTest = new StringTest();
            var interfaceTest = new InterfaceTest();
            var genericsTest = new GenericTest();
            var generics2Test = new Generic2Test();
            var isInstanceTest = new IsInstanceTest();
            var exceptionTest = new ExceptionTest();
            var plugTestTest = new PlugTestTest();
            var compareTest = new ComparisonTest();
            var simpleTest = new OptimizationTest();
            var reflectionTest = new ReflectionTest();
            var arrayTest = new ArrayTest();
            var int64Test = new Int64Test();
            var otherTest = new OtherTest();

            delegateTest.Test();
            stringTest.Test();
            interfaceTest.Test();
            genericsTest.Test();
            generics2Test.Test();
            isInstanceTest.Test();
            exceptionTest.Test();
            plugTestTest.Test();
            compareTest.Test();
            simpleTest.Test();

            //reflectionTest.Test();
            arrayTest.Test();
            int64Test.Test();
            otherTest.Test();
        }
示例#10
0
        public static void JsonTest8()
        {
            //T如果非热更,是可以的
            Console.WriteLine("Generic Test where T in local");
            GenericTest <int> g = new GenericTest <int>();

            g.name = "intTest";
            g.data = new List <int>()
            {
                0, 1, 2, 3, 4, 5
            };
            var js = JsonMapper.ToJson(g);

            Console.WriteLine("js:\n" + js);
            var gObj = JsonMapper.ToObject <GenericTest <int> >(js);

            Console.WriteLine(gObj.ToString());
            Console.WriteLine("====================");

            //T如果热更,也是可以的
            Console.WriteLine("Generic Test where T in hotfix");
            GenericTest <DataClass> d = new GenericTest <DataClass>();

            d.name = "dataClassTest";
            d.data = new List <DataClass>()
            {
                new DataClass()
                {
                    code = 200,
                    msg  = "测试200"
                },
                new DataClass()
                {
                    code = 404,
                    msg  = "测试404"
                }
            };
            js = JsonMapper.ToJson(d);
            Console.WriteLine("js:\n" + js);
            var gObj2 = JsonMapper.ToObject <GenericTest <DataClass> >(js);

            Console.WriteLine(gObj2.ToString());
            Console.WriteLine("====================");
        }
示例#11
0
        private TestCase CreateTestCase(string source, GenericTest test)
        {
            var directory = Path.GetDirectoryName(source);
            // VS will open the file, but not jump to the line number if the path contais "\.\", so make sure we handle this
            var path = test.CodeFilePath != null ? Path.Combine(directory, test.CodeFilePath.StartsWith(".\\") ? test.CodeFilePath.Substring(2) : test.CodeFilePath) : null;
            var line = test.LineNumber;

            // SUPERBODGE (See Issue #3)
            // If we don't have the location of the test, but we have a stack, parse it out
            // This is temporary until we can find a better way to get filename/line numbers via Jasmine
            if (path == null && !string.IsNullOrWhiteSpace(test.ErrorStackTrace))
                TryParseLocationFromStack(test, out path, out line);

            return new TestCase(test.Name, ExecutorUri, source)
            {
                DisplayName = test.DisplayName,
                CodeFilePath = path,
                LineNumber = line
            };
        }
示例#12
0
        static void Main(string[] args)
        {
            GenericTest <int, string> gt = new GenericTest <int, string>();

            gt.genericTypeMethod(1);
            gt.genericTypeMethod("Hallo Welt!");

            GenericTest <int, string> .genericListType(new List <string>());

            GenericTest <int, string> .genericListType(new List <bool>());

            GenericTest <int, string> .statMethod(1);

            GenericTest <int, string> .statMethod(2);

            GenericTest <int, bool> .statMethod(3);

            Console.WriteLine("<int, string>    typeCounter: " + GenericTest <int, string> .typeCounter);
            Console.WriteLine("<int, bool>      typeCounter: " + GenericTest <int, bool> .typeCounter);
        }
示例#13
0
        private TestResult CreateTestResult(string source, GenericTest test)
        {
            var directory = Path.GetDirectoryName(source);
            // VS will open the file, but not jump to the line number if the path contais "\.\", so make sure we handle this
            var path = test.CodeFilePath != null ? Path.Combine(directory, test.CodeFilePath.StartsWith(".\\") ? test.CodeFilePath.Substring(2) : test.CodeFilePath) : null;

            var testCase = new TestCase(test.Name, ExecutorUri, source)
            {
                DisplayName = test.DisplayName,
                CodeFilePath = path,
                LineNumber = test.LineNumber
            };

            return new TestResult(testCase)
            {
                Outcome = test.Outcome,
                ErrorMessage = test.ErrorMessage,
                ErrorStackTrace = test.ErrorStackTrace
            };
        }
示例#14
0
        private void TryParseLocationFromStack(GenericTest test, out string path, out int line)
        {
            // First line is the error message
            // Then there's one line of our framework; but just to be a bit more future-proof, exclude any that look like extension
            var possibleLines = test.ErrorStackTrace.Split('\n').Skip(1).Where(l => !l.ToLower().Contains(ExtensionFolder.ToLower()));

            foreach (var matchingLine in possibleLines)
            {
                var match = Regex.Match(matchingLine, @"\((.+):(\d+):\d+\)", RegexOptions.Compiled);

                if (match.Groups.Count >= 3)
                {
                    path = match.Groups[1].Value.Replace("/", @"\");
                    line = int.Parse(match.Groups[2].Value);
                    return;
                }
            }

            path = null;
            line = 0;
        }
        public void TestNestedGenericQueryTypes()
        {
            var ignite = Ignition.Start(TestUtils.GetTestConfiguration());

            var cfg = new CacheConfiguration(TestUtils.TestName)
            {
                QueryEntities = new[] { new QueryEntity(typeof(int), typeof(GenericTest <GenericTest2 <string> >)) }
            };

            var cache = ignite.GetOrCreateCache <int, GenericTest <GenericTest2 <string> > >(cfg);
            var value = new GenericTest <GenericTest2 <string> >(new GenericTest2 <string>("foobar"));

            cache[1] = value;

            var sqlRes = cache.Query(new SqlFieldsQuery("SELECT Bar from GENERICTEST")).Single().Single();

            Assert.AreEqual(value.Foo.Bar, sqlRes);

            var valTypeName = value.GetType().FullName;

            Assert.IsNotNull(valTypeName);
        }
示例#16
0
        public void TestNestedGenericQueryTypes()
        {
            var ignite = Ignition.Start(TestUtils.GetTestConfiguration());

            var cfg = new CacheConfiguration(TestUtils.TestName)
            {
                QueryEntities = new[] { new QueryEntity(typeof(int), typeof(GenericTest <GenericTest2 <string> >)) }
            };

            var cache = ignite.GetOrCreateCache <int, GenericTest <GenericTest2 <string> > >(cfg);
            var value = new GenericTest <GenericTest2 <string> >(new GenericTest2 <string>("foobar"));

            cache[1] = value;

            var tableName = cache.Query(new SqlFieldsQuery(
                                            "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?", cache.Name))
                            .Single().Single(); // The table name is weird, see IGNITE-14064.

            var sqlRes = cache.Query(new SqlFieldsQuery(string.Format("SELECT Bar from \"{0}\"", tableName)))
                         .Single().Single();

            Assert.AreEqual(value.Foo.Bar, sqlRes);
        }
示例#17
0
        public static void Main(string[] args)
        {
            Fourmi fourmi1 = new Fourmi();
            Fruit  fruit1  = new Fruit()
            {
                DateCueilette = DateTime.Now.AddDays(-5)
            };

            Console.WriteLine($"La fourmi mange un fruit {Zoo.NourrirAnimal(fourmi1, fruit1)}");

            Fruit fruit2 = new Fruit()
            {
                DateCueilette = DateTime.Now.AddDays(-12)
            };

            Console.WriteLine($"La fourmi mange un fruit {Zoo.NourrirAnimal(fourmi1, fruit2)}");

            Pate pate1 = new Pate()
            {
                DatePeremption = DateTime.Now.AddDays(1)
            };
            Pate pate2 = new Pate()
            {
                DatePeremption = DateTime.Now.AddDays(-1)
            };

            //Console.WriteLine($"La fourmi mange un fruit {Zoo.NourrirAnimal(fourmi1, pate1)}");

            Chat chat1 = new Chat();

            Console.WriteLine($"Le chat mange de la paté {Zoo.NourrirAnimal(chat1, pate1)}");
            Console.WriteLine($"Le chat mange de la paté {Zoo.NourrirAnimal(chat1, pate2)}");

            GenericTest <Chat> .ListElements();

            Console.ReadLine();
        }
示例#18
0
        public void TestGenericQueryTypes()
        {
            var ignite = Ignition.Start(TestUtils.GetTestConfiguration());

            var cfg = new CacheConfiguration(TestUtils.TestName)
            {
                QueryEntities = new[] { new QueryEntity(typeof(GenericTest <int>), typeof(GenericTest2 <string>)) }
            };

            var cache = ignite.GetOrCreateCache <GenericTest <int>, GenericTest2 <string> >(cfg);
            var key   = new GenericTest <int>(1);
            var value = new GenericTest2 <string>("foo");

            cache[key] = value;

            var binType          = ignite.GetBinary().GetBinaryType(value.GetType());
            var expectedTypeName = BinaryBasicNameMapper.FullNameInstance.GetTypeName(value.GetType().FullName);
            var expectedTypeId   = BinaryUtils.GetStringHashCodeLowerCase(expectedTypeName);

            Assert.AreEqual(expectedTypeName, binType.TypeName);
            Assert.AreEqual(expectedTypeId, binType.TypeId);

            var queryEntity = cache.GetConfiguration().QueryEntities.Single();

            Assert.AreEqual(expectedTypeName, queryEntity.ValueTypeName);

            var tableName = cache.Query(new SqlFieldsQuery(
                                            "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?", cache.Name))
                            .Single().Single(); // The table name is weird, see IGNITE-14064.

            var sqlRes = cache.Query(new SqlFieldsQuery(string.Format("SELECT Foo, Bar from \"{0}\"", tableName)))
                         .Single();

            Assert.AreEqual(key.Foo, sqlRes[0]);
            Assert.AreEqual(value.Bar, sqlRes[1]);
        }
示例#19
0
    static void Main(string[] args)
    {
        var test = new GenericTest();

        test.MyGenericMethod(Guid.NewGuid());
    }
示例#20
0
 public static void Main()
 {
     GenericTest.Test();
 }
示例#21
0
    public void TestGeneric()
    {
        GenericTest tGT = new GenericTest();

        tGT.Test();
    }
示例#22
0
 public static void Run()
 {
     var a = new GenericTest <string>();
     var b = new GenericTest <int>();
 }