本文整理汇总了C#中System.TestClass类的典型用法代码示例。如果您正苦于以下问题:C# TestClass类的具体用法?C# TestClass怎么用?C# TestClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestClass类属于System命名空间,在下文中一共展示了TestClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComplexTest
public void ComplexTest()
{
var instance = new TestClass
{
Bar = new TestClass1
{
Foo = "test"
}
};
var str = TypeSerializer.SerializeToString(instance);
var jsv = new JsvConverter();
var result = jsv.DeserializeFromString<TestClass>(str);
Assert.AreEqual("test", result.Bar.Foo);
var foo = new TestClass1
{
Foo = "test1"
};
var result1 = jsv.DeserializeFromString<TestClass1>(TypeSerializer.SerializeToString(foo));
Assert.AreEqual("test1", result1.Foo);
}
示例2: Should_return_actual_objects_HashCode
public void Should_return_actual_objects_HashCode()
{
const string testString = "Hello World!";
var @class = new TestClass { TestValue = testString };
var reader = new PropertyReader<TestClass>("TestValue");
reader.GetItemHashCode(@class).ShouldEqual(testString.GetHashCode());
}
示例3: SerializeObject_WriteJson_AreEqual
public void SerializeObject_WriteJson_AreEqual(string value)
{
var source = new TestClass { HighestCsrSeasonId = new Guid(value) };
var target = JsonConvert.SerializeObject(source);
Assert.AreEqual($"{{\"HighestCsrSeasonId\":\"{value}\"}}", target);
}
示例4: SetValueToNull
public void SetValueToNull()
{
ReflectorMember member = ReflectorMember.Create(GetMember("InnerClass"));
TestClass testClass = new TestClass();
member.SetValue(testClass, null);
Assert.IsNull(testClass.InnerClass);
}
示例5: FindActualPropertyWithInvalidProperty
public void FindActualPropertyWithInvalidProperty()
{
TestClass testValue = new TestClass();
testValue.Name = "My name";
object property = DynamicValueUtility.FindActualProperty(testValue, "Name");
Assert.IsNull(property, "Property found");
}
示例6: OnCreate
//int count = 1;
//static readonly string[] Tests = new String[] {
//"Add Object Authorization Rules", "Test Auth Begin Edit Rules"};
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
//Intent myIntent = new Intent(this.BaseContext, (Java.Lang.Class)new UnitDriven.MainActivity().Class);
//myIntent.AddFlags(ActivityFlags.NewTask);
//StartActivity(myIntent);
Csla.DataPortal.ProxyTypeName = "Local";
TestClass a = new TestClass();
////Csla.ApplicationContext.User = new System.Security.Principal.GenericPrincipal(new System.Security.Principal.GenericIdentity(string.Empty), new string[] { });
// Get our button from the layout resource,
// and attach an event to it
//btnAddObjectAuthorizationRules = FindViewById<Button>(Resource.Id.btnAddObjectAuthorizationRules);
//lblAddObjectAuthorizationRules = FindViewById<TextView>(Resource.Id.lblAddObjectAuthorizationRules);
//btnAddObjectAuthorizationRules.Click += delegate { CheckAddObjectAuthorizationRules(); };
////System.Security.Principal.GenericPrincipal dontErase = new System.Security.Principal.GenericPrincipal(new System.Security.Principal.GenericIdentity(string.Empty), new string[] { });
////Csla.Security.UnauthenticatedPrincipal _principal = new Csla.Security.UnauthenticatedPrincipal();
LoadTestItems(System.Reflection.Assembly.GetExecutingAssembly());
}
示例7: SetValue
public void SetValue()
{
ReflectorMember member = ReflectorMember.Create(GetMember("Name"));
TestClass testClass = new TestClass();
member.SetValue(testClass, "Hello");
Assert.AreEqual("Hello", testClass.Name);
}
示例8: CanDisposeWithUsings
public void CanDisposeWithUsings()
{
using(var myObject = new TestClass())
{
myObject.Should().NotBeNull();
}
}
示例9: DictionaryOfObjects
public void DictionaryOfObjects()
{
TestClass profileObject1 = new TestClass();
profileObject1.Field1 = "apples";
profileObject1.Field2 = 100;
profileObject1.Field3 = false;
TestClass profileObject2 = new TestClass();
profileObject2.Field1 = "oranges";
profileObject2.Field2 = 200;
profileObject2.Field3 = true;
Hashtable hash = new Hashtable();
hash["object1"] = profileObject1;
hash["object2"] = profileObject2;
this.profile.SetProfile(this.ident, hash);
IDictionary result = (IDictionary)this.profile.GetProfile(this.ident);
Assert.AreEqual(hash.Count, result.Count, "item count");
TestClass resultObject1 = (TestClass)result["object1"];
Assert.AreEqual(profileObject1.Field1, resultObject1.Field1);
Assert.AreEqual(profileObject1.Field2, resultObject1.Field2);
Assert.AreEqual(profileObject1.Field3, resultObject1.Field3);
TestClass resultObject2 = (TestClass)result["object2"];
Assert.AreEqual(profileObject2.Field1, resultObject2.Field1);
Assert.AreEqual(profileObject2.Field2, resultObject2.Field2);
Assert.AreEqual(profileObject2.Field3, resultObject2.Field3);
}
示例10: Main
private static void Main(string[] args)
{
var testClass = new TestClass("TestInstance");
Console.WriteLine("Test of integer param to a method. Expected value: 5 Return Value:" + testClass.Add(2, 3));
Console.WriteLine("Test of double param to a method. Expected value: 4 Return Value:" + testClass.Subtract(6, 2));
Console.WriteLine("Test of return value of a method. Expected value: TestInstance Return Value:" + testClass.GetName());
Console.WriteLine("Test of generic parameters to a method. Expected value: TestClass Return Value:" + testClass.GetTypeName<TestClass>());
Console.WriteLine("Test of generic parameters to a method. Expected value: TestClass Return Value:" + testClass.GetTypeName<TestClass>(testClass));
string name = "Punit", name2 = string.Empty;
Console.WriteLine("Test of ref parameters to a method. Expected value: Punit.appended Return Value:" + testClass.GetRefValue(ref name));
Console.WriteLine("Value of name (ref)" + name);
Console.WriteLine("Test of out parameters to a method. Expected value: new Value Return Value:" + testClass.GetOutValue(out name2));
Console.WriteLine("Value of name (out)" + name2);
Console.WriteLine("Test of static method. Expected value: NewInstance Return Value:" + TestClass.Create().Name);
Console.WriteLine("Test of array as parameter to a method. Expected value: 2 Return Value:" + testClass.GetArrayCount(new[] { "new1", "new2" }));
Console.WriteLine("Test of optional parameter to a method. Expected value: 8 Return Value:" + testClass.AddOptional(3));
Console.WriteLine("Test of optional parameter to a method. Expected value: 10 Return Value:" + testClass.AddOptional(3, 7));
Console.WriteLine("Test call of delegate");
TestClass.MyDelegate delegateDefinition = new TestClass.MyDelegate(DelegateCalled);
testClass.CallDelegate(delegateDefinition);
Console.WriteLine("Name is: " + testClass.NameProperty);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
示例11: IsDisposedIsFalseByDefault
public void IsDisposedIsFalseByDefault()
{
var myObject = new TestClass();
myObject.Should().NotBeNull();
myObject.IsDisposed.Should().BeFalse();
//Assert.False(myObject.IsDisposed);
}
示例12: Return_TestAttribute_When_GetAttribute_Is_Called_With_Member
public void Return_TestAttribute_When_GetAttribute_Is_Called_With_Member()
{
var testClass = new TestClass();
var memberInfo = ReflectionUtility.GetMemberInfo(() => testClass.TestProperty);
var attribute = ReflectionUtility.GetAttribute<TestAttribute>(memberInfo);
Assert.IsNotNull(attribute);
}
示例13: ReadOnlyProperty_instance_setter
public void ReadOnlyProperty_instance_setter()
{
var instance = new TestClass();
dynamic expando = new Expando(instance);
expando.ReadOnlyFullName = "John Doe";
}
示例14: SetPropertyPathValue_GivenSecondLevelProperty_ReturnsCorrectValue
public void SetPropertyPathValue_GivenSecondLevelProperty_ReturnsCorrectValue()
{
var test = new TestClass();
ReflectionHelper.SetPropertyPathValue(test, "InnerTestClassObject.SomeIntProperty", 42);
Assert.AreEqual(42, test.InnerTestClassObject.SomeIntProperty);
}
示例15: IfPropertyStepping
public void IfPropertyStepping ()
{
var test = new TestClass ();
if (test.OneLineProperty == "someInvalidValue6049e709-7271-41a1-bc0a-f1f1b80d4125")/*0c64d51c-40b3-4d20-b7e3-4e3e641ec52a*/
return;
Console.Write ("");/*ac7625ef-ebbd-4543-b7ff-c9c5d26fd8b4*/
}