本文整理汇总了C#中TestClass类的典型用法代码示例。如果您正苦于以下问题:C# TestClass类的具体用法?C# TestClass怎么用?C# TestClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestClass类属于命名空间,在下文中一共展示了TestClass类的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: Log
private static IEnumerable<Trace> Log(
TestClass original,
TestClass current)
{
return new AuditTrails()
.Log(original, current);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
}
示例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);
}
示例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());
}
}
示例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 };
}
示例12: OnExitTests
public OnExitTests()
{
t = new TestClass();
Monitor.Enter (sync);
execInfo.Clear();
execInfo2.Clear();
}
示例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();
}
示例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];
}
}
示例15: InterfaceTest3
public static bool InterfaceTest3()
{
TestClass tc = new TestClass();
IInterfaceAB b = tc;
bool result = (b.A() == 2);
return result;
}