public void CancelAsync_When_IsAsych_Is_False() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = false; //Act _fx.CancelAsync(); //Assert Assert.NotEqual(FxWorkerStatus.CancellationPending, _fx.WorkerStatus); }
public void CancelAsync_When_IsAsych_Is_True_And_IsBusy_Is_True() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = true; _fx.AsynchOp = AsyncOperationManager.CreateOperation(null);// forces IsBusy to true //Act _fx.CancelAsync(); //Assert Assert.Equal(FxWorkerStatus.CancellationPending, _fx.WorkerStatus); }
public void UpdateStatus_Fires_StatusChanged_Event_If_Status_Changes() { //Arrange var helper = new HelperForSimpleFx(); _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.StatusChanged += new FxStatusChangeEventHandler<ISimpleFx, FxStatusChangeEventArgs>(helper.StatusChanged_DummyHandler); //Act _fx.UpdateStatus(FxStatus.Complete, StatusChangeDriver.NormalTransition, null); //Assert Assert.Equal(1, helper.StatusChanged_TimesCalled); Assert.NotNull(helper.RecievedEventArgs); }
public void Reset_Throws_Ex_If_IsBusy_Is_True() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = false; _fx.WorkerStatus = FxWorkerStatus.ExecutingSynch;// IsBusy returns true //Act, Assert var ex = Assert.Throws<InvalidOperationException>(() => _fx.Reset()); }
public void Reset() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = false; _fx.WorkerStatus = FxWorkerStatus.Completed;// IsBusy returns true //Act _fx.Reset(); //Assert Assert.Null(_fx.AsynchOp); Assert.False(_fx.IsAsynch); Assert.Equal(FxWorkerStatus.Uninitialized, _fx.WorkerStatus); Assert.Equal(FxStatus.UnInitialized, _fx.Status); Assert.Equal(0, _fx.PercentProgress); Assert.False(_fx.CompletionCalled); Assert.False(_fx.IsValidContinue); Assert.Null(_fx.OutputException); Assert.Null(_fx.OutputMssg); }
public void IsError_Returns_True_If_WorkerStatus_Is_Error(FxWorkerStatus status, bool expectedResult) { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); //Act _fx.WorkerStatus = status; //Assert Assert.Equal(expectedResult, _fx.IsError); }
public void ExecComplete_When_WorkerStatus_Is_Uninitialized() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.CompletionCalled = false; _fx.WorkerStatus = FxWorkerStatus.Uninitialized; var helper = new HelperForSimpleFx(); _fx.ExecuteCompleted += new FxCompletedEventHandler<ISimpleFx, FxCompletedEventArgs>(helper.ExecuteCompleted_DummyHandler); Exception ex = null; string mssg = null; bool isCancelled = false; int progAtCompletion = 100; //Act _fx.ExecComplete(progAtCompletion, isCancelled, ex, mssg); //Assert Assert.Equal(1, helper.ExecuteCompleted_TimesCalled); Assert.NotNull(helper.RecievedEventArgs); Assert.Null(_fx.AsynchOp); }
public void WrapUp_With_Error_And_OutputException_Is_Null() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.WorkerStatus = FxWorkerStatus.Completed;// makes IsCancelled return false _fx.IsValidContinue = false; _fx.OutputException = null; var mockOutPortMgr = new Mock<IOutputPortMgr>(); //Act _fx.WrapUp(mockOutPortMgr.Object); //Assert Assert.Equal(FxStatus.Error, _fx.Status); Assert.Equal(FxWorkerStatus.Error, _fx.WorkerStatus); Assert.True(_fx.CompletionCalled); }
public void IsBusy_Returns_True_When_IsAsynch_Is_True_And_AsynchOp_Is_Not_Null() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = true; _fx.AsynchOp = AsyncOperationManager.CreateOperation(null); //Act bool result = _fx.IsBusy; //Assert Assert.True(result); _asyncOp = null; }
public void IsBusy_Returns_False_When_IsAsynch_Is_True_And_AsynchOp_Is_Null() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = true; _fx.AsynchOp = null; //Act bool result = _fx.IsBusy; //Assert Assert.False(result); }
public void ExecWorkerCleanUp_Throws_Ex_When_IsAsynch_Is_False() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = false; NullReferenceException ex = new NullReferenceException(); //Act, Assert var x = Assert.Throws<FxExecutionErrorException>(() => _fx.ExecWorkerCleanUp(ex)); }
public void ExecWorkerCleanUp_Throws_Ex_When_Exception_Param_Is_Null() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = true; //Act, Assert var ex = Assert.Throws<InvalidOperationException>(() => _fx.ExecWorkerCleanUp(null)); }
public void ExecWorkerCleanUp() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = true; NullReferenceException ex = new NullReferenceException(); //Act _fx.ExecWorkerCleanUp(ex); //Assert Assert.Equal(FxStatus.Error, _fx.Status); Assert.Equal(FxWorkerStatus.Error, _fx.WorkerStatus); Assert.True(_fx.CompletionCalled); }
public void ExecuteAsync_Calls_Cancel_And_Reset_If_IsBusy_Is_True() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); var mockParamMgr = new Mock<IParamMgr>(); var mockInPortMgr = new Mock<IInputPortMgr>(); var mockOutPortMgr = new Mock<IOutputPortMgr>(); var mockSettingsMgr = new Mock<ISimpleSettingsMgr>(); _fx.AsynchOp = AsyncOperationManager.CreateOperation(null); // forces IsBusy to true //Act _fx.ExecuteAsync(mockParamMgr.Object, mockInPortMgr.Object, mockSettingsMgr.Object, mockOutPortMgr.Object); //Assert Assert.False(_fx.ExecuteWorkerCalled); }
public void UpdateStatus_Updates_FxStatus() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); FxStatus status = _fx.Status; FxStatus newStatus = FxStatus.Complete; //Act _fx.UpdateStatus(newStatus, StatusChangeDriver.NormalTransition, null); //Assert FxStatus actualStatus = _fx.Status; Assert.Equal(newStatus, actualStatus); }
public void IsBusy_Return_When_IsAsynch_Is_False_Is_Based_On_WorkerStatus(FxWorkerStatus status, bool expectedResult) { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsAsynch = false; _fx.WorkerStatus = status; //Act bool result = _fx.IsBusy; //Assert Assert.Equal(expectedResult, result); }
public void WrapUp_When_IsValidContinue_Is_True_And_IsCancelled_Is_False() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.IsValidContinue = true; _fx.WorkerStatus = FxWorkerStatus.Completed;// makes IsCancelled return false var mockOutPortMgr = new Mock<IOutputPortMgr>(); //Act _fx.WrapUp(mockOutPortMgr.Object); //Assert Assert.Equal(FxStatus.Complete, _fx.Status); Assert.Equal(FxWorkerStatus.Completed, _fx.WorkerStatus); Assert.True(_fx.CompletionCalled); }
public void IsCancelled_Returns_True_If_WorkerStatus_Is_CancellationPending(FxWorkerStatus status, bool expectedResult) { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); //Act _fx.WorkerStatus = status; //Assert Assert.Equal(expectedResult, _fx.IsCancelled); }
public void ExecCompleted_Updates_Statuses_And_Calls_ExecComplete() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); //Act _fx.ExecCompleted(3, new Exception(), "blah"); //Assert Assert.Equal(FxWorkerStatus.Completed, _fx.WorkerStatus); Assert.Equal(FxStatus.Complete, _fx.Status); Assert.True(_fx.CompletionCalled); }
public void ExecComplete_Throws_Ex_When_WorkerStatus_Is_ExecutingSynch() { //Arrange _fx = new SimpleFxBaseTestClass(Guid.NewGuid()); _fx.CompletionCalled = false; _fx.WorkerStatus = FxWorkerStatus.ExecutingSynch; var helper = new HelperForSimpleFx(); _fx.ExecuteCompleted += new FxCompletedEventHandler<ISimpleFx, FxCompletedEventArgs>(helper.ExecuteCompleted_DummyHandler); Exception ex = null; string mssg = null; bool isCancelled = false; int progAtCompletion = 100; //Act, Assert var x2 = Assert.Throws<InvalidOperationException>(() => _fx.ExecComplete(progAtCompletion, isCancelled, ex, mssg)); }