本文整理汇总了C#中TestClass类的典型用法代码示例。如果您正苦于以下问题:C# TestClass类的具体用法?C# TestClass怎么用?C# TestClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestClass类属于命名空间,在下文中一共展示了TestClass类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Log
private static IEnumerable<Trace> Log(
TestClass original,
TestClass current)
{
return new AuditTrails()
.Log(original, current);
}
开发者ID:c4rm4x,项目名称:C4rm4x.Tools,代码行数:7,代码来源:AuditTrailsTest.Log.Basic.cs
示例3: PosTest2
public bool PosTest2()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("Return the property get_Current in the IEnumerator 2");
try
{
Dictionary<TestClass, TestClass> dictionary = new Dictionary<TestClass, TestClass>();
TestClass Tkey1 = new TestClass();
TestClass TVal1 = new TestClass();
dictionary.Add(Tkey1, TVal1);
Dictionary<TestClass, TestClass>.Enumerator enumer = dictionary.GetEnumerator();
IEnumerator iEnumer = (IEnumerator)enumer;
while(iEnumer.MoveNext())
{
object objCurrent = iEnumer.Current;
KeyValuePair<TestClass, TestClass> keyVal = new KeyValuePair<TestClass, TestClass>(Tkey1, TVal1);
if (!objCurrent.Equals(keyVal))
{
TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
retVal = false;
}
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
retVal = false;
}
return retVal;
}
开发者ID:CheneyWu,项目名称:coreclr,代码行数:30,代码来源:dictionaryenumeratorienumeratorget_current.cs
示例4: runTest_Click
private void runTest_Click(object sender, EventArgs e)
{
TestClass test = new TestClass();
var result = test.Test();
//var result = test.Read(new Guid("6242395E-B14A-4F9E-B95C-FEEF425E9860"));
resultLbl.Text = result.ClientId.ToString();
}
开发者ID:ot-brian-mackey,项目名称:DapperDemo,代码行数:7,代码来源:Form1.cs
示例5: PosTest2
public bool PosTest2()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("Return the property get_Entry in the IDictionaryEnumerator 2");
try
{
Dictionary<TestClass,TestClass> dictionary = new Dictionary<TestClass,TestClass>();
TestClass Tkey1 = new TestClass();
TestClass TVal1 = new TestClass();
dictionary.Add(Tkey1,TVal1);
Dictionary<TestClass,TestClass>.Enumerator enumer = dictionary.GetEnumerator();
IDictionaryEnumerator idicEnumer = (IDictionaryEnumerator)enumer;
if (idicEnumer.MoveNext())
{
DictionaryEntry entryVal = idicEnumer.Entry;
if (entryVal.Key != Tkey1 || entryVal.Value != TVal1)
{
TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
retVal = false;
}
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
retVal = false;
}
return retVal;
}
开发者ID:l1183479157,项目名称:coreclr,代码行数:29,代码来源:dictionaryenumeratoridictionaryenumeratorget_entry.cs
示例6: Main
public static int Main( string[] astrArguments )
{
TestClass tc = new TestClass();
int nType = 1;
if ( astrArguments.Length > 0 )
nType = Convert.ToInt32( astrArguments[ 0 ] );
switch ( nType )
{
case 1:
new TestClass1().Run();
break;
case 2:
new TestClass2().Run();
break;
case 3:
new TestClass3().Run();
break;
default:
Console.WriteLine( "Unknown test: " + nType );
break;
}
return 0;
}
开发者ID:ilya11211,项目名称:nprof,代码行数:25,代码来源:TestClass.cs
示例7: PosTest2
public bool PosTest2()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("Invoke the method Reset in the KeyCollection IEnumerator 2");
try
{
Dictionary<TestClass, TestClass> dic = new Dictionary<TestClass, TestClass>();
TestClass Tkey1 = new TestClass();
TestClass TVal1 = new TestClass();
dic.Add(Tkey1,TVal1);
IEnumerator keycollectIEnumer = (IEnumerator)new Dictionary<TestClass, TestClass>.KeyCollection(dic).GetEnumerator();
while (keycollectIEnumer.MoveNext()) { }
keycollectIEnumer.Reset();
if (keycollectIEnumer.MoveNext())
{
if (!keycollectIEnumer.Current.Equals(Tkey1))
{
TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
retVal = false;
}
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
retVal = false;
}
return retVal;
}
开发者ID:CheneyWu,项目名称:coreclr,代码行数:29,代码来源:keycollectionenumeratorienumeratorreset.cs
示例8: Should_work_same_way_as_memory_stream_on_read
public void Should_work_same_way_as_memory_stream_on_read()
{
var serializer = new JsonSerializer();
var origin = new TestClass
{
Name = "FFasdf fasd FASDfas fadsfa dafsdf asdf a fsd ",
CreatedAt = DateTime.Now,
IsObsolete = true,
Count = 31241325351
};
using (var writer = new JsonTextWriter(new StreamWriter(_ethalonStream)))
{
serializer.Serialize(writer, origin);
}
_testStream.ChangeBuffer(_ethalonBuffer);
using (var reader = new JsonTextReader(new StreamReader(_testStream)))
{
var reburnished = serializer.Deserialize<TestClass>(reader);
Assert.That(reburnished.Name, Is.EqualTo(origin.Name));
Assert.That(reburnished.CreatedAt, Is.EqualTo(origin.CreatedAt));
Assert.That(reburnished.IsObsolete, Is.EqualTo(origin.IsObsolete));
Assert.That(reburnished.Count, Is.EqualTo(origin.Count));
}
}
开发者ID:Codestellation,项目名称:Quarks,代码行数:28,代码来源:ReusableStreamTests.cs
示例9: CanUseRefFieldAndVariableClosures
public void CanUseRefFieldAndVariableClosures()
{
var x = new TestClass();
Expression<Func<object, string>> expected = o => "" + x + instanceTestClass;
Func<object, string> compiled = o => "" + x + instanceTestClass;
Test(expected, compiled);
}
开发者ID:BeeWarloc,项目名称:DelegateDecompiler,代码行数:7,代码来源:ClosuresTest.cs
示例10: Write_WritesDataTypes_ToUnderlyingStream_WhenNotBuffering
public void Write_WritesDataTypes_ToUnderlyingStream_WhenNotBuffering()
{
// Arrange
var expected = new[] { "True", "3", "18446744073709551615", "Hello world", "3.14", "2.718" };
var unbufferedWriter = new Mock<TextWriter>();
unbufferedWriter.SetupGet(w => w.Encoding).Returns(Encoding.UTF8);
var buffer = new ViewBuffer(new TestViewBufferScope(), "some-name");
var writer = new RazorTextWriter(unbufferedWriter.Object, buffer, new HtmlTestEncoder());
var testClass = new TestClass();
// Act
writer.Flush();
writer.Write(true);
writer.Write(3);
writer.Write(ulong.MaxValue);
writer.Write(testClass);
writer.Write(3.14);
writer.Write(2.718m);
// Assert
Assert.Null(buffer.BufferSegments);
foreach (var item in expected)
{
unbufferedWriter.Verify(v => v.Write(item), Times.Once());
}
}
开发者ID:phinq19,项目名称:git_example,代码行数:26,代码来源:RazorTextWriterTest.cs
示例11: GetTestCases
public IEnumerable<object> GetTestCases()
{
yield return new CETData() { Description = "box null to int?", Expression = Expression.Convert(Expression.Constant(null), typeof(int?)), ExpectedValue = null };
yield return new CETData() { Description = "box enum to int?", Expression = Expression.Convert(Expression.Constant(TestEnum.Foo), typeof(int?)), ExpectedValue = 3 };
yield return new CETData() { Description = "box null to enum? to int?", Expression = Expression.Convert(Expression.Convert(Expression.Constant(null), typeof(TestEnum?)), typeof(int?)), ExpectedValue = null };
yield return new CETData() { Description = "convert enum? null to int?", Expression = Expression.Convert(Expression.Constant((TestEnum?)null), typeof(int?)), ExpectedValue = null };
yield return new CETData() { Description = "add int", Expression = Expression.Add(Expression.Constant(1), Expression.Constant(2)), ExpectedValue = 3 };
yield return new CETData() { Description = "add int to null", Expression = Expression.Add(Expression.Constant(1, typeof(int?)), Expression.Constant(null, typeof(int?))), ExpectedValue = null };
yield return new CETData() { Description = "add int? to int?", Expression = Expression.Add(Expression.Constant(1, typeof(int?)), Expression.Constant(2, typeof(int?))), ExpectedValue = 3 };
yield return new CETData() { Description = "bitwise and", Expression = Expression.And(Expression.Constant(1, typeof(int?)), Expression.Constant(3, typeof(int?))), ExpectedValue = 0x1 };
yield return new CETData() { Description = "logical and", Expression = Expression.AndAlso(Expression.Constant(true), Expression.Constant(true)), ExpectedValue = true };
yield return new CETData() { Description = "logical and", Expression = Expression.AndAlso(Expression.Constant(false), Expression.Constant(true)), ExpectedValue = false };
yield return new CETData() { Description = "subtract int", Expression = Expression.Subtract(Expression.Constant(1), Expression.Constant(2)), ExpectedValue = -1 };
yield return new CETData() { Description = "equality int==int", Expression = Expression.Equal(Expression.Constant(1), Expression.Constant(2)), ExpectedValue = false };
yield return new CETData() { Description = "equality int!=int", Expression = Expression.NotEqual(Expression.Constant(1), Expression.Constant(2)), ExpectedValue = true };
yield return new CETData() { Description = "equality int==int?", Expression = Expression.Equal(Expression.Convert(Expression.Constant(1), typeof(int?)), Expression.Convert(Expression.Constant(2), typeof(int?))), ExpectedValue = false };
yield return new CETData() { Description = "equality int!=int?", Expression = Expression.NotEqual(Expression.Convert(Expression.Constant(1), typeof(int?)), Expression.Convert(Expression.Constant(2), typeof(int?))), ExpectedValue = true };
yield return new CETData() { Description = "equality int==int?null", Expression = Expression.Equal(Expression.Convert(Expression.Constant(1), typeof(int?)), Expression.Convert(Expression.Constant(null), typeof(int?))), ExpectedValue = false };
yield return new CETData() { Description = "equality int!=int?null", Expression = Expression.NotEqual(Expression.Convert(Expression.Constant(1), typeof(int?)), Expression.Convert(Expression.Constant(null), typeof(int?))), ExpectedValue = true };
var fieldtest = new TestClass() { field = "foo" };
yield return new CETData() { Description = "field access", Expression = ((Expression<Func<string>>)(() => fieldtest.field)).Body, ExpectedValue = "foo" };
var propertytest = new TestClass() { property = "foo" };
yield return new CETData() { Description = "property access", Expression = ((Expression<Func<string>>)(() => propertytest.property)).Body, ExpectedValue = "foo" };
yield return new CETData() { Description = "decrement int", Expression = Expression.Decrement(Expression.Constant(1)), ExpectedValue = 0 };
yield return new CETData() { Description = "increment int", Expression = Expression.Increment(Expression.Constant(1)), ExpectedValue = 2 };
yield return new CETData() { Description = "one's complement int", Expression = Expression.OnesComplement(Expression.Constant(1)), ExpectedValue = ~1 };
yield return new CETData() { Description = "one's complement int", Expression = Expression.OnesComplement(Expression.Constant(-1)), ExpectedValue = ~-1 };
}
开发者ID:daszat,项目名称:zetbox,代码行数:34,代码来源:ConstantEvaluatorTests.cs
示例12: OnExitTests
public OnExitTests()
{
t = new TestClass();
Monitor.Enter (sync);
execInfo.Clear();
execInfo2.Clear();
}
开发者ID:mshmelev,项目名称:Shaspect,代码行数:7,代码来源:OnExitTests.cs
示例13: Main
private static void Main(string[] args)
{
// var sm = new SDSkillManager();
// var s = sm.GetAllSkills();
// foreach (var skill in s)
// {
// Console.WriteLine($"Skill id : {skill.ID}\n");
// skill.SetCurrentPlayerLevel(0);
// Console.WriteLine($"Skill can not be used... : {skill.CanBeUsed()}\n");
// skill.SetCurrentPlayerLevel(5);
// Console.WriteLine($"Skill can be used... : {skill.CanBeUsed()}\n");
// skill.TryActivateSkill();
// skill.TryActivateSkill(); // Should not run because of cooldown
// Console.WriteLine($"{skill.Name} is running : {skill.IsInUse} \n");
// Console.WriteLine($"{skill.Name} can be blocked? : {skill.CanBeBlocked} \n");
// Console.WriteLine($"{skill.Name} setting it to can be blocked\n");
// skill.CanBeBlocked = true;
// Console.WriteLine($"{skill.Name} can be blocked? : {skill.CanBeBlocked} \n");
// Console.WriteLine($"{skill.Name} is blocked? : {skill.IsBlocked} \n");
// Console.WriteLine($"{skill.Name} blocking it\n");
// skill.IsBlocked = true;
// Console.WriteLine($"{skill.Name} is blocked? : {skill.IsBlocked} \n");
// Console.WriteLine($"{skill.Name} trying activate blocked skill... Was it successfull : {skill.TryActivateSkill()}\n");
// Console.WriteLine($"{skill.Name} Immediate activation of blocked skill!!" +
// $" Banzaiiii!! : {skill.ActivateSkillImmediately()}\n");
// Console.WriteLine($"{skill.Name} unblocking it\n");
// skill.IsBlocked = false;
// }
// Console.ReadKey();
// Create methods
// var t0 = new FwTimer(1f);
// var t1 = new FwTimer();
// var t2 = new FwTimer(10, TimerType.Inverted);
// var t4 = new FwTimer(2, TimerType.Inverted, TimerLogStatus.Disabled);
// t4.Start();
// t4.Pause();
// t4.TimePassed();
// t4.TimeLeft();
// t4.TimeIncrease(1f);
// t4.TimeDecrease(1.0);
FwTimer timer = new FwTimer(3000);
TestClass tc = new TestClass();
timer.Elapsed += tc.OnEndOne;
timer.Elapsed += tc.OnEndTwo;
Console.WriteLine("Launching timer");
timer.Start();
Console.WriteLine("Timer launched");
// Console.ReadKey();
FwTimer timer2 = new FwTimer() {IntervalSeconds = 3};
TestClass tc2 = new TestClass();
timer2.Elapsed += tc2.OnEndOne;
timer2.Elapsed += tc2.OnEndTwo;
Console.WriteLine("Launching timer");
timer.Start();
Console.WriteLine("Timer launched");
// Console.ReadKey();
}
开发者ID:Delacrowa,项目名称:project1,代码行数:60,代码来源:Program.cs
示例14: InitBase
protected void InitBase()
{
projectContent = new MockProjectContent();
projectContent.Language = LanguageProperties.None;
// Create the base test class.
outerClass = new MockClass(projectContent, "MyTests.A");
projectContent.Classes.Add(outerClass);
// Create the inner test class.
// Note the use of the DotNetName "MyTests.A+InnerTest".
innerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass);
innerClass.Attributes.Add(new MockAttribute("TestFixture"));
MockMethod method = new MockMethod(innerClass, "FooBar");
method.Attributes.Add(new MockAttribute("Test"));
innerClass.Methods.Add(method);
outerClass.InnerClasses.Add(innerClass);
// Add another inner class that is not a test class.
nonTestInnerClass = new MockClass(projectContent, "MyTests.A.InnerBClass", outerClass);
outerClass.InnerClasses.Add(nonTestInnerClass);
// Add another inner class with the same name as the InnerATest.
// This makes sure duplicate classes are not added.
MockClass duplicateInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass);
duplicateInnerClass.Attributes.Add(new MockAttribute("TestFixture"));
outerClass.InnerClasses.Add(duplicateInnerClass);
testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
testProject = new TestProject(null, projectContent, testFrameworks);
if (testProject.TestClasses.Count > 0) {
testClass = testProject.TestClasses[0];
}
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:35,代码来源:InnerClassTestFixtureBase.cs
示例15: InterfaceTest3
public static bool InterfaceTest3()
{
TestClass tc = new TestClass();
IInterfaceAB b = tc;
bool result = (b.A() == 2);
return result;
}
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:7,代码来源:InterfaceTest.cs
示例16: 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: Remove a function from the delegate which contains only 1 callback function");
try
{
DelegateRemoveImpl delctor = new DelegateRemoveImpl();
TestClass tcInstance = new TestClass();
delctor.starkWork = new booldelegate(tcInstance.StartWork_Bool);
delctor.starkWork -= new booldelegate(tcInstance.StartWork_Bool);
if (null != delctor.starkWork)
{
TestLibrary.TestFramework.LogError("001", "remove failure " );
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
开发者ID:CheneyWu,项目名称:coreclr,代码行数:28,代码来源:delegateremoveimpl.cs
示例17: Main
static void Main(string[] args)
{
Console.WriteLine("----- Main AppDomain -----");
var control = new TestClass();
control.DoWork();
Console.WriteLine("Int: {0}", control.ReturnIntResult());
Console.WriteLine("Complex A: {0} B: {1}", control.ReturnComplexResult().A, control.ReturnComplexResult().B);
Console.WriteLine();
Console.WriteLine("----- New AppDomain -----");
AppDomain newDomain = AppDomain.CreateDomain("TestDomain");
newDomain.UnhandledException += new UnhandledExceptionEventHandler(newDomain_UnhandledException);
string assembly = typeof(TestClass).Assembly.FullName;
string type = typeof(TestClass).FullName;
var handle = newDomain.CreateInstance(assembly, type);
TestClass secondary = handle.Unwrap() as TestClass;
Console.WriteLine("Int: {0}", secondary.ReturnIntResult());
Console.WriteLine("Complex A: {0} B: {1}", secondary.ReturnComplexResult().A, secondary.ReturnComplexResult().B);
try
{
secondary.ThrowException();
}
catch (Exception ex)
{
Console.WriteLine("Exception: {0}", ex.Message);
}
Console.WriteLine();
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
开发者ID:Thor132,项目名称:CSProto,代码行数:34,代码来源:Program.cs
示例18: CombineClass
public void CombineClass()
{
var prev = new TestClass()
{
PString = "prev",
FString1 = "prev",
FString2 = "prev",
FInt = 1,
NInt = 0,
Array1 = new int[]{1, 2, 3},
Array2 = new int[]{1, 2, 3}
};
var next = new TestClass()
{
PString = "next",
FString1 = "next",
FString2 = null,
FInt = 0,
NInt = null,
Array1 = null,
Array2 = new int[]{3, 3, 3}
};
var result = _combiner.Combine(prev, next);
Assert.That(result.PString, Is.EqualTo("next"));
Assert.That(result.FString1, Is.EqualTo("next"));
Assert.That(result.FString2, Is.EqualTo("prev"));
Assert.That(result.FInt, Is.EqualTo(1));
Assert.That(result.NInt, Is.EqualTo(0));
Assert.That(result.Array1, Is.EquivalentTo(new int[] { 1, 2, 3 }));
Assert.That(result.Array2, Is.EquivalentTo(new int[] { 3, 3, 3 }));
}
开发者ID:namelesstwice,项目名称:NConfiguration,代码行数:34,代码来源:ComplexTests.cs
示例19: Main
private static int Main()
{
TestClass _this = new TestClass();
if (!Test_NEWOBJ(_this, 0, true))
{
Console.WriteLine("Failed => 101");
return 101;
}
if (!Test_NEWOBJ(_this, 1, true))
{
Console.WriteLine("Failed => 102");
return 102;
}
if (!Test_NEWOBJ(_this, 2, false))
{
Console.WriteLine("Failed => 103");
return 103;
}
if (!Test_NEWOBJ(_this, 3, false))
{
Console.WriteLine("Failed => 104");
return 104;
}
Console.WriteLine("Passed => 100");
return 100;
}
开发者ID:CheneyWu,项目名称:coreclr,代码行数:26,代码来源:castclass_newobj.cs
示例20: Init
public void Init()
{
// Add a test class.
MockProjectContent projectContent = new MockProjectContent();
projectContent.Language = LanguageProperties.None;
MockClass c = new MockClass("RootNamespace.MyTestFixture");
c.Attributes.Add(new MockAttribute("TestFixture"));
c.ProjectContent = projectContent;
projectContent.Classes.Add(c);
// Add first method.
MockMethod method = new MockMethod("MyTest");
method.Attributes.Add(new MockAttribute("Test"));
method.DeclaringType = c;
c.Methods.Add(method);
// Add duplicate method.
c.Methods.Add(method);
// Add a base class that has duplicate methods.
MockClass baseClass = new MockClass("RootNamespace.MyTestFixtureBase");
baseClass.Attributes.Add(new MockAttribute("TestFixture"));
baseClass.ProjectContent = projectContent;
projectContent.Classes.Add(baseClass);
c.BaseClass = baseClass;
baseClass.Methods.Add(method);
baseClass.Methods.Add(method);
// Create test class.
testClass = new TestClass(c);
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:31,代码来源:DuplicateMethodNameTestFixture.cs
注:本文中的TestClass类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论