本文整理汇总了C#中EventListener类的典型用法代码示例。如果您正苦于以下问题:C# EventListener类的具体用法?C# EventListener怎么用?C# EventListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventListener类属于命名空间,在下文中一共展示了EventListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Level
public Level(EventListener sysCall, StaticData sdb, ViewDB vdb, Viewport view)
{
disp = new EventDispatcher();
state = new State(sdb);
op = new Operator();
gui = new GUI(vdb, view, op.OnSelect, disp);
disp.MapInput(InputType.MouseLeft_Up, EventType.Select);
disp.MapInput(InputType.MouseRight_Up, EventType.Action);
disp.MapInput(InputType.RightShift_Down, EventType.Waypoint);
disp.MapInput(InputType.RightShift_Up, EventType.WaypointOff);
disp.MapInput(InputType.LeftShift_Down, EventType.Waypoint);
disp.MapInput(InputType.LeftShift_Up, EventType.WaypointOff);
disp.MapInput(InputType.Up_Down, EventType.CameraUp);
disp.MapInput(InputType.Right_Down, EventType.CameraRight);
disp.MapInput(InputType.Down_Down, EventType.CameraDown);
disp.MapInput(InputType.Left_Down, EventType.CameraLeft);
disp.MapInput(InputType.Up_Up, EventType.CameraUpEnd);
disp.MapInput(InputType.Right_Up, EventType.CameraRightEnd);
disp.MapInput(InputType.Down_Up, EventType.CameraDownEnd);
disp.MapInput(InputType.Left_Up, EventType.CameraLeftEnd);
disp.MapInput(InputType.Escape_Up, EventType.End);
disp.AddListener(this, EventType.Game);
disp.AddListener(sysCall, EventType.System);
}
示例2: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
using (new global::NUnit.Core.TestContext())
{
var testResult = new TestResult(this);
Log.Debug("Test Starting: " + TestName.FullName);
listener.TestStarted(TestName);
var stopwatch = new Stopwatch();
stopwatch.Start();
switch (RunState)
{
case RunState.Runnable:
case RunState.Explicit:
DoTest(_test, testResult);
break;
case RunState.NotRunnable:
testResult.Invalid(IgnoreReason);
break;
case RunState.Ignored:
testResult.Ignore(IgnoreReason);
break;
default:
testResult.Skip(IgnoreReason);
break;
}
stopwatch.Stop();
testResult.Time = stopwatch.Elapsed.Seconds;
listener.TestFinished(testResult);
return testResult;
}
}
示例3: SetUp
public void SetUp()
{
_Un = new MyObject("a", 0);
_Deux = new MyObject("b", 1);
_Trois = new MyObject("c", 2);
_Quatre = new MyObject("d", 3);
_Cinq = new MyObject("e", 4);
_DecoratedOriginalElements = new List<MyObject>();
_DecoratedOriginalElements.Add(_Un); _DecoratedOriginalElements.Add(_Deux); _DecoratedOriginalElements.Add(_Trois); _DecoratedOriginalElements.Add(_Quatre); _DecoratedOriginalElements.Add(_Cinq);
_ListForComparison = new List<IObject>();
_ListForComparison.AddRange(_DecoratedOriginalElements);
_OriginalElements = new List<MyObject>();
_OriginalElements.AddRange(_DecoratedOriginalElements);
_SCMC = SafeCollectionModifierConverter<MyObject, IObject>.GetSafeCollectionModifierConverterDerived<MyObject, IObject>(_DecoratedOriginalElements);
_IML = _SCMC;
_ChangedList = _IML.MofifiableCollection;
_EL = new EventListener<EventArgs>();
_SCMC.OnCommit += _EL.SingleElementChangedListener;
}
示例4: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
var successCount = 0;
TestResult failureResult = null;
for (var i = 0; i < this.tryCount; i++)
{
var result = base.Run(listener, filter);
if (!TestFailed(result))
{
if (i == 0)
{
return result;
}
if (++successCount >= this.requiredPassCount)
{
return result;
}
}
else
{
failureResult = result;
}
}
return failureResult;
}
示例5: RunTest
TestResult RunTest(EventListener listener)
{
listener.TestStarted(base.TestName);
TestResult nunitTestResult = new TestResult(this);
if (_pendingException != null)
{
nunitTestResult.Failure(_pendingException.Message, _pendingException.StackTrace, FailureSite.Test);
}
else if (RunState == RunState.NotRunnable)
{
nunitTestResult.SetResult(ResultState.NotRunnable, IgnoreReason, "", FailureSite.Test);
}
else
{
var testResult = SpecificationRunner.RunTest(this._testContext, new List<string>());
NativeTestResult.ApplyToNunitResult(testResult, nunitTestResult);
}
listener.TestFinished(nunitTestResult);
return nunitTestResult;
}
示例6: Scene
public Scene(Camera2D camera, EventListener listener = null)
{
this.root = new Actor();
this.root.SetScene(this);
this.camera = camera;
this.listener = listener;
}
示例7: Run
public TestResult Run(EventListener listener, IFilter filter, string path, string suiteName, string testName)
{
TestSuite rootTS = LoadTestSuite (path, suiteName);
TextWriter origStdout = Console.Out;
TextWriter origStderr = Console.Error;
Console.SetOut (stdout);
Console.SetError (stderr);
string cdir = Environment.CurrentDirectory;
Environment.CurrentDirectory = Path.GetDirectoryName (path);
try {
Test nt = null;
if (testName != null) {
foreach (Test t in rootTS.Tests)
if (t.Name == testName) {
nt = t;
break;
}
} else
nt = rootTS;
if (nt == null)
throw new Exception ("Test " + suiteName + "." + testName + " not found.");
return nt.Run (listener, filter);
} finally {
Environment.CurrentDirectory = cdir;
Console.SetOut (origStdout);
Console.SetError (origStderr);
}
}
示例8: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
using ( new DirectorySwapper( AssemblyHelper.GetDirectoryName( FixtureType.Assembly ) ) )
{
return base.Run(listener, filter);
}
}
示例9: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
test.Parent = Parent;
TestResult result = null;
for (var i = 1; i < retryCount; i++)
{
try
{
result = test.Run(listener, filter);
if (result.IsFailure || result.IsError)
{
var message = string.Format("Rerunning '{0}'", TestName);
Log.Info(message); Console.WriteLine(message);
result = test.Run(listener, filter);
}
}
// In Case SetUp or TearDown failed
catch (Exception e)
{
Log.Info(e.Message); Console.WriteLine(e);
}
}
return result;
}
示例10: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
var result = new TestResult(this);
lock (testClosure) {
try {
testClosure.TestMethod();
TestNonExceptionCondition(result);
} catch (IgnoreException iex) {
result.Ignore(iex.Message);
} catch (InconclusiveException icex) {
result.Invalid(icex.Message);
} catch (Exception ex) {
TestExceptionCondition(result, ex);
}
try {
testClosure.TearDown();
} catch (Exception ex) {
result.Failure("Exception in tear-down: "+ex.Message, ex.StackTrace);
}
}
listener.TestFinished(result);
return result;
}
示例11: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
listener.TestStarted(base.TestName);
long ticks = DateTime.Now.Ticks;
var testResult = new TestResultShim();
Exception existingError = null;
_globalSetup.PrepareForTestPosition(Position, out existingError);
if (existingError != null)
{
TestResultUtil.Error(testResult, TestExtensions.GetMultilineName(this), existingError, null, TestResultShim.Site.SetUp);
}
else
{
List<string> traceMessages = null;
try
{
RunTestMethod(testResult, out traceMessages);
}
catch (Exception e)
{
var globalTraceMessages = _globalSetup.GetTraceMessages();
TestResultUtil.Error(testResult, TestExtensions.GetMultilineName(this), e, globalTraceMessages.Concat(traceMessages));
}
}
var nunitTestResult = new TestResult(this);
NativeTestResult.ApplyToNunitResult(testResult, nunitTestResult);
nunitTestResult.Time = ((DateTime.Now.Ticks - ticks)) / 10000000.0;
listener.TestFinished(nunitTestResult);
return nunitTestResult;
}
示例12: EventPump
/// <summary>
/// Constructor
/// </summary>
/// <param name="eventListener">The EventListener to receive events</param>
/// <param name="events">The event queue to pull events from</param>
/// <param name="autostop">Set to true to stop pump after RunFinished</param>
public EventPump( EventListener eventListener, EventQueue events, bool autostop)
{
this.eventListener = eventListener;
this.events = events;
this.events.SetWaitHandleForSynchronizedEvents(this.synchronousEventSent);
this.autostop = autostop;
}
示例13: Run
public override TestResult Run( EventListener listener )
{
using( new TestContext() )
{
TestCaseResult testResult = MakeTestCaseResult();
listener.TestStarted( this.TestName );
long startTime = DateTime.Now.Ticks;
switch (this.RunState)
{
case RunState.Runnable:
case RunState.Explicit:
Run(testResult);
break;
case RunState.Skipped:
testResult.Skip(IgnoreReason);
break;
default:
case RunState.NotRunnable:
case RunState.Ignored:
testResult.Ignore(IgnoreReason);
break;
}
long stopTime = DateTime.Now.Ticks;
double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
testResult.Time = time;
listener.TestFinished(testResult);
return testResult;
}
}
示例14: Run
public override TestResult Run(EventListener listener, ITestFilter filter)
{
listener.TestStarted(base.TestName);
long ticks = DateTime.Now.Ticks;
TestResult testResult = new TestResult(this);
Exception existingError = null;
_globalSetup.PrepareForTestPosition(Position, out existingError);
if (existingError != null)
{
TestResultUtil.Error(testResult, existingError, null, FailureSite.SetUp);
}
else
{
List<string> traceMessages = null;
try
{
RunTestMethod(testResult, out traceMessages);
}
catch (Exception e)
{
var globalTraceMessages = _globalSetup.GetTraceMessages();
TestResultUtil.Error(testResult, e, globalTraceMessages.Concat(traceMessages));
}
}
double num3 = ((double)(DateTime.Now.Ticks - ticks)) / 10000000.0;
testResult.Time = num3;
listener.TestFinished(testResult);
return testResult;
}
示例15: Run
/// <summary>
/// Override Run, setting Fixture to that of the Parent.
/// </summary>
/// <param name="listener"></param>
/// <param name="filter"></param>
/// <returns></returns>
public override TestResult Run(EventListener listener, ITestFilter filter)
{
if (this.Parent != null)
{
this.Fixture = this.Parent.Fixture;
TestSuite suite = this.Parent as TestSuite;
if (suite != null)
{
this.setUpMethods = suite.GetSetUpMethods();
this.tearDownMethods = suite.GetTearDownMethods();
}
}
// DYNAMIC: Get the parameters, and add the methods here.
TestResult result = base.Run(listener, filter);
if (this.isTheory && result.ResultState == ResultState.Inconclusive)
result.SetResult(
ResultState.Failure,
this.TestCount == 0
? "No test cases were provided"
: "All test cases were inconclusive",
null);
this.Fixture = null;
this.setUpMethods = null;
this.tearDownMethods = null;
return result;
}