public void InvokesOnFinishedOnceWhenOpenOrThrowDisposed() { object receivedInOnFinished = null; var passedToPlayer = new object(); var onFinishedCount = 0; var action = new Action <object>( o => { receivedInOnFinished = o; onFinishedCount++; }); var setup = new ResolveSetup <object>(new ResolveSetupArgs( this._resolveOpen, p => { var disposable = p(this._uri, passedToPlayer); disposable.Dispose(); })); setup.OnFinished(action).OpenOrThrow(); Assert.AreEqual(1, onFinishedCount); Assert.AreEqual(passedToPlayer, receivedInOnFinished); }
public void InvokesAppropriateResolveOpenMethodOnOpenOrThrow() { var setup = new ResolveSetup <string>(new ResolveSetupArgs(this._resolveOpen, _ => { })); setup.OpenOrThrow(); this._resolveOpen.Received(1).OpenOrThrow(); }
/// <summary> /// Открывает объект, полученный через URI, заданной функцией, предварительно передав /// делегат вызова настроек. /// </summary> /// <param name="launchAction">Функция, открывающая объект, полученный через URI.</param> /// <returns>Результат вызова заданной функции.</returns> private IDisposable SendPlayerAndInvoke(Func <IShellResolveOpen, IDisposable> launchAction) { var player = ResolveSetup <TResolved> .CreatePlayer(this._onReady, this._onFinished); if (player != null) { this._playerSender(player); } return(launchAction(this._resolveOpen)); }
public void DoesntInvokeCallbackWhenSetupOnFinished() { var wasCalled = false; var setup = new ResolveSetup <string>( new ResolveSetupArgs(this._resolveOpen, _ => wasCalled = true)); setup.OnFinished(s => { }); Assert.IsFalse(wasCalled); }
public void DoesntInvokeOnFinishedWhenOpenOrThrow() { var wasCalled = false; var action = new Action <object>(o => wasCalled = true); var setup = new ResolveSetup <object>( new ResolveSetupArgs(this._resolveOpen, p => p(this._uri, new object()))); setup.OnFinished(action).OpenOrThrow(); Assert.IsFalse(wasCalled); }
public void LogsWhenResolvedIncompatibleOnOpenOrThrow() { var resolved = new List <int>(); var setup = new ResolveSetup <StringBuilder>(new ResolveSetupArgs( this._resolveOpen, p => p(this._uri, resolved))); var expectedTypeName = typeof(StringBuilder).Name; var resolvedTypeName = resolved.GetType().Name; setup.OnReady(_ => { }).OpenOrThrow(); this._traceListener.Received(1).TraceEvent( Arg.Any <TraceEventCache>(), Arg.Any <string>(), TraceEventType.Warning, Arg.Any <int>(), Arg.Any <string>(), Arg.Is <object[]>(ps => ps.Contains(expectedTypeName) && ps.Contains(resolvedTypeName))); }
public void InvokesOnReadyOnceWhenOpen() { object receivedInOnReady = null; var passedToPlayer = new object(); var onReadyCount = 0; var action = new Action <object>( o => { receivedInOnReady = o; onReadyCount++; }); var setup = new ResolveSetup <object>(new ResolveSetupArgs( this._resolveOpen, p => p(this._uri, passedToPlayer))); setup.OnReady(action).Open(); Assert.AreEqual(1, onReadyCount); Assert.AreEqual(passedToPlayer, receivedInOnReady); }