当前位置: 首页>>代码示例>>C#>>正文


C# TestClass.GetType方法代码示例

本文整理汇总了C#中TestClass.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# TestClass.GetType方法的具体用法?C# TestClass.GetType怎么用?C# TestClass.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestClass的用法示例。


在下文中一共展示了TestClass.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

 public static void Main(String[] args) {
 Environment.ExitCode = 1; 
 bool bResult = true;
 Console.WriteLine("ReflectionInsensitiveLookup: Test using reflection to do case-insensitive lookup with high chars.");
 TestClass tc = new TestClass();
 Assembly currAssembly = tc.GetType().Module.Assembly;
 String typeName = tc.GetType().FullName;
 Type tNormal = currAssembly.GetType(typeName);
 if (tNormal!=null) {
 Console.WriteLine("Found expected type.");
 } else {
 bResult = false;
 Console.WriteLine("Unable to load expected type.");
 }
 Type tInsensitive = currAssembly.GetType(typeName, false, true);
 if (tInsensitive!=null) {
 Console.WriteLine("Found expected insensitive type.");
 } else {	
 bResult = false;
 Console.WriteLine("Unable to load expected insensitive type.");
 }
 if (bResult) {
 Environment.ExitCode = 0;
 Console.WriteLine("Passed!");
 } else {
 Console.WriteLine("Failed!");
 }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:28,代码来源:coreflectioninsensitivelookup.cs

示例2: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Say Hello to my little darling! ");

            var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            var fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
            var productVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;

            Console.WriteLine("{0} -- {1} -- {2}", assemblyVersion, fileVersion, productVersion);

            // AssemblyTitle
            Console.WriteLine(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileDescription);            

            var testClass = new TestClass();
            testClass.DoNothing();

            // AssemblyTitle
            Console.WriteLine(FileVersionInfo.GetVersionInfo(testClass.GetType().Assembly.Location).FileDescription);            

            var testClassassemblyVersion = testClass.GetType().Assembly.GetName().Version.ToString();
            var testClassfileVersion = FileVersionInfo.GetVersionInfo(testClass.GetType().Assembly.Location).FileVersion;
            var testClassproductVersion = FileVersionInfo.GetVersionInfo(testClass.GetType().Assembly.Location).ProductVersion;

            Console.WriteLine("{0} -- {1} -- {2}", testClassassemblyVersion, testClassfileVersion, testClassproductVersion);

            Console.WriteLine(DateTime.Parse("2012-01-01 00:00:00"));
        }
开发者ID:BrunoCaimar,项目名称:MsBuildRelatedStuff,代码行数:27,代码来源:Program.cs

示例3: PosTest2

    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: returns the Type of the object encompassed or referred to by the current reference type.");
        try
        {
            TestClass myClass = new TestClass();
            Type type1 = myClass.GetType();
            Type type2 = type1.GetElementType();
            if (type2!=null)
            {
                TestLibrary.TestFramework.LogError("003", "GetElementType error!");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:27,代码来源:typegetelementtype.cs

示例4: PosTest6

 public void PosTest6()
 {
     TestClass tc = new TestClass();
     Type tpA = tc.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event3", BindingFlags.NonPublic | BindingFlags.Instance);
     MethodInfo methodinfo = eventinfo.GetRaiseMethod(false);
     Assert.Null(methodinfo);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:8,代码来源:EventInfoGetRaiseMethod2.cs

示例5: TestNonNativeAttributes

 public virtual void TestNonNativeAttributes()
 {
     var tc = new TestClass();
     var classInfo =
         ClassIntrospector.Introspect(tc.GetType(), true).
             GetMainClassInfo();
     AssertEquals(0, classInfo.GetAllNonNativeAttributes().Count);
 }
开发者ID:spolnik,项目名称:ndatabase,代码行数:8,代码来源:StorageEngineTest.cs

示例6: PosTest2

 public void PosTest2()
 {
     TestClass tc = new TestClass();
     Type tpA = tc.GetType();
     EventInfo eventinfo = tpA.GetEvent("Event1");
     MethodInfo methodinfo = eventinfo.GetRaiseMethod(false);
     Assert.Null(methodinfo);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:8,代码来源:EventInfoGetRaiseMethod2.cs

示例7: TestaddTrueForSpecified1

 public void TestaddTrueForSpecified1()
 {
     IList<Object> elements = new List<Object>();
     elements.Add("test");
     TestClass testClass = new TestClass();
     HelpMethods.addTrueForSpecified(elements, testClass.GetType().GetMethod("hasSpecified"));
     Assert.IsTrue(elements.Count == 2);
     Assert.IsTrue(elements[1].Equals(true));
 }
开发者ID:ChristophGr,项目名称:loom-csharp,代码行数:9,代码来源:TestHelpMethods.cs

示例8: TestDumpClass

    public void TestDumpClass()
    {
        var testClass = new TestClass() { x = 5, y = 7, z = 0 };
        testClass.list = new List<int>() { { 3 }, { 1 }, { 4 } };

        Assert.AreEqual( "{\"@type\":\"" + testClass.GetType().FullName + "\",\"x\":5,\"y\":7,\"list\":[3,1,4]}", JSON.Dump( testClass ) );

        Assert.IsTrue( beforeEncodeCallbackFired );
    }
开发者ID:pbhogan,项目名称:TinyJSON,代码行数:9,代码来源:TestClassType.cs

示例9: TestNonNativeAttributes

        public virtual void TestNonNativeAttributes()
		{
			TestClass tc = new TestClass
				();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo classInfo = NeoDatis.Odb.OdbConfiguration
				.GetCoreProvider().GetClassIntrospector().Introspect(tc.GetType(), true).GetMainClassInfo
				();
			AssertEquals(0, classInfo.GetAllNonNativeAttributes().Count);
		}
开发者ID:ekicyou,项目名称:pasta,代码行数:9,代码来源:StorageEngineTest.cs

示例10: TestAddTrueForSpecifiedFieldsWithAnObjectListWhereSpecifiedIsDfinedAsParameters

        public void TestAddTrueForSpecifiedFieldsWithAnObjectListWhereSpecifiedIsDfinedAsParameters()
        {
            ///A specified field is a field that is created from wsdl.exe to indicated if a primitiv type like boolean is set or not
            IList<Object> elements = new List<Object>();
            elements.Add("test");
            TestClass testClass = new TestClass();
            HelpMethods.AddTrueForSpecified(elements, testClass.GetType().GetMethod("hasSpecified"));

            Assert.AreEqual<int>(elements.Count, 2);
            Assert.AreEqual<Boolean>((bool)elements[1], true);
        }
开发者ID:openengsb,项目名称:loom-csharp,代码行数:11,代码来源:TestHelpMethods.cs

示例11: TestAddTrueForSpecifiedFieldsWithAnObjectListWhereNoSpecifiedIsDfinedAsParameters

        public void TestAddTrueForSpecifiedFieldsWithAnObjectListWhereNoSpecifiedIsDfinedAsParameters()
        {
            IList<Object> elements = new List<Object>();
            elements.Add("test");
            elements.Add("test1");
            TestClass testClass = new TestClass();
            HelpMethods.AddTrueForSpecified(elements, testClass.GetType().GetMethod("hasNoSpecified"));

            Assert.AreEqual<int>(elements.Count, 2);
            Assert.AreEqual<String>(elements[1].ToString(), "test1");
        }
开发者ID:openengsb,项目名称:loom-csharp,代码行数:11,代码来源:TestHelpMethods.cs

示例12: Activate_SetsPropertyValue

        public void Activate_SetsPropertyValue()
        {
            // Arrange
            var instance = new TestClass();
            var typeInfo = instance.GetType().GetTypeInfo();
            var property = typeInfo.GetDeclaredProperty("IntProperty");
            var activator = new PropertyActivator<int>(property, valueAccessor: (val) => val + 1);

            // Act
            activator.Activate(instance, 123);

            // Assert
            Assert.Equal(124, instance.IntProperty);
        }
开发者ID:leloulight,项目名称:Common,代码行数:14,代码来源:PropertyActivatorTest.cs

示例13: RunTest

        public static TestResult[] RunTest( TestClass instance )
        {
            var results = new List<TestResult>();

              foreach ( var method in GetTestMethods( instance.GetType() ) )
              {

            instance.Initialize();

            results.Add( RunTest( instance, method ) );

            instance.Cleanup();

              }

              return results.ToArray();
        }
开发者ID:h2h,项目名称:WebTest,代码行数:17,代码来源:TestManager.cs

示例14: Activate_InvokesValueAccessorWithExpectedValue

        public void Activate_InvokesValueAccessorWithExpectedValue()
        {
            // Arrange
            var instance = new TestClass();
            var typeInfo = instance.GetType().GetTypeInfo();
            var property = typeInfo.GetDeclaredProperty("IntProperty");
            var invokedWith = -1;
            var activator = new PropertyActivator<int>(
                property,
                valueAccessor: (val) =>
                {
                    invokedWith = val;
                    return val;
                });

            // Act
            activator.Activate(instance, 123);

            // Assert
            Assert.Equal(123, invokedWith);
        }
开发者ID:leloulight,项目名称:Common,代码行数:21,代码来源:PropertyActivatorTest.cs

示例15: PosTest1

    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1:  override isByRefImpl and Only these type which BaseType is BaseClass Return true ,TestClass as test object ");
        try
        {
            TestClass myobject = new TestClass();
            if (myobject.GetType().IsByRef)
            {
                TestLibrary.TestFramework.LogError("001", "TestClass is not Passed by reference.");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:23,代码来源:typeisbyrefimpl.cs


注:本文中的TestClass.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。