本文整理汇总了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!");
}
}
示例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"));
}
示例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;
}
示例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);
}
示例5: TestNonNativeAttributes
public virtual void TestNonNativeAttributes()
{
var tc = new TestClass();
var classInfo =
ClassIntrospector.Introspect(tc.GetType(), true).
GetMainClassInfo();
AssertEquals(0, classInfo.GetAllNonNativeAttributes().Count);
}
示例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);
}
示例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));
}
示例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 );
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}