/// <summary> /// Verifies the state of the data source provided by our mDataSourceSupplier. /// </summary> protected void VerifyState( IDataSource <object> dataSource, IDataSource <object> dataSourceWithResult, bool isClosed, bool isFinished, bool hasResult, object result, bool hasFailed, Exception failureCause) { DataSourceTestUtils.VerifyState( (AbstractDataSource <object>)dataSource, isClosed, isFinished, hasResult, result, hasFailed, failureCause); // DataSourceTestUtils.VerifyState will call dataSource.GetResult() which should forward to // underlyingDataSource.GetResult() if (dataSourceWithResult != null) { ((MockAbstractDataSource <object>)dataSourceWithResult).VerifyMethodInvocation( "GetResult", 1); } VerifyNoMoreInteractionsAll(); }
public void TestLifeCycle_Failure_Close() { Subscribe(); // failure Exception throwable = new Exception(); _dataSource.SetFailure(throwable); VerifySubscribers(DataSourceTestUtils.ON_FAILURE); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.FAILED, throwable); // close _dataSource.Close(); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.FAILED, throwable); }
public void TestLifeCycle_LastResult_Close() { Subscribe(); // Last result IValue value = new MockValue(); _dataSource.SetResult(value, DataSourceTestUtils.LAST); VerifySubscribers(DataSourceTestUtils.ON_NEW_RESULT); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITH_RESULT, value, DataSourceTestUtils.NOT_FAILED, null); // Close _dataSource.Close(); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.NOT_FAILED, null); }
public void TestInitialState() { DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.NOT_FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.NOT_FAILED, null); }
public void TestLifeCycle_AfterFailure() { Subscribe(); // failure Exception throwable = new Exception(); _dataSource.SetFailure(throwable); VerifySubscribers(DataSourceTestUtils.ON_FAILURE); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.FAILED, throwable); // try intermediate _dataSource.SetResult(new MockValue(), DataSourceTestUtils.INTERMEDIATE); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.FAILED, throwable); // try last _dataSource.SetResult(new MockValue(), DataSourceTestUtils.LAST); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.FAILED, throwable); // try failure _dataSource.SetFailure(new Exception()); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.FAILED, throwable); }
public void TestLifeCycle_AfterSuccess() { Subscribe(); // success IValue value = new MockValue(); _dataSource.SetResult(value, DataSourceTestUtils.LAST); VerifySubscribers(DataSourceTestUtils.ON_NEW_RESULT); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITH_RESULT, value, DataSourceTestUtils.NOT_FAILED, null); // try intermediate _dataSource.SetResult(new MockValue(), DataSourceTestUtils.INTERMEDIATE); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITH_RESULT, value, DataSourceTestUtils.NOT_FAILED, null); // try last _dataSource.SetResult(new MockValue(), DataSourceTestUtils.LAST); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITH_RESULT, value, DataSourceTestUtils.NOT_FAILED, null); // try failure _dataSource.SetFailure(new Exception()); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITH_RESULT, value, DataSourceTestUtils.NOT_FAILED, null); }
public void TestLifeCycle_AfterClose() { Subscribe(); // close _dataSource.Close(); VerifySubscribers(DataSourceTestUtils.ON_CANCELLATION); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.CLOSED, DataSourceTestUtils.NOT_FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.NOT_FAILED, null); // try intermediate _dataSource.SetResult(new MockValue(), DataSourceTestUtils.INTERMEDIATE); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.CLOSED, DataSourceTestUtils.NOT_FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.NOT_FAILED, null); // try last _dataSource.SetResult(new MockValue(), DataSourceTestUtils.LAST); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.CLOSED, DataSourceTestUtils.NOT_FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.NOT_FAILED, null); // try failure _dataSource.SetFailure(new Exception()); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.CLOSED, DataSourceTestUtils.NOT_FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.NOT_FAILED, null); }
public void TestLifeCycle_IntermediateResult_Failure_Close() { Subscribe(); // intermediate result IValue value1 = new MockValue(); _dataSource.SetResult(value1, DataSourceTestUtils.INTERMEDIATE); VerifySubscribers(DataSourceTestUtils.ON_NEW_RESULT); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.NOT_FINISHED, DataSourceTestUtils.WITH_RESULT, value1, DataSourceTestUtils.NOT_FAILED, null); // failure Exception throwable = new Exception(); _dataSource.SetFailure(throwable); VerifySubscribers(DataSourceTestUtils.ON_FAILURE); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.NOT_CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITH_RESULT, value1, DataSourceTestUtils.FAILED, throwable); // close _dataSource.Close(); VerifySubscribers(DataSourceTestUtils.NO_INTERACTIONS); DataSourceTestUtils.VerifyState( _dataSource, DataSourceTestUtils.CLOSED, DataSourceTestUtils.FINISHED, DataSourceTestUtils.WITHOUT_RESULT, null, DataSourceTestUtils.FAILED, throwable); }