public async Task Initialize_order_of_operations_are_correct() { // Arrange const string loadingOperation = "Loading"; const string loadOperation = "Load"; const string loadedOPeration = "Loaded"; var operationResults = new List <Tuple <string, bool> >(); componentFixture.Loading += async(component) => await TaskFromAction.Invoke( () => operationResults.Add(new Tuple <string, bool>(loadingOperation, true))); componentFixture.Loaded += (component, args) => operationResults.Add(new Tuple <string, bool>(loadedOPeration, true)); componentFixture.LoadDelegate = () => TaskFromAction.Invoke( () => operationResults.Add(new Tuple <string, bool>(loadOperation, true))); // Arrange await this.componentFixture.Initialize(); // Assert Assert.IsTrue(operationResults[0].Item1 == loadingOperation && operationResults[0].Item2, "Loading was not invoked first."); Assert.IsTrue(operationResults[1].Item1 == loadOperation && operationResults[1].Item2, "Load was not invoked 2nd."); Assert.IsTrue(operationResults[2].Item1 == loadedOPeration && operationResults[2].Item2, "Loaded was not invoked last."); }
public void Exception_thrown_when_action_is_null() { // Act Task task = TaskFromAction.Invoke(null); // Assert Assert.Fail(); }
public async Task Returns_awaitable_task_when_invoked() { // Arrange bool isCallbackFinished = false; // Act await TaskFromAction.Invoke(() => isCallbackFinished = true); // Assert Assert.IsTrue(isCallbackFinished, "Callback was not called."); }
public async Task Initialize_invokes_load_method() { // Arrange bool loading = false; componentFixture.LoadDelegate = () => TaskFromAction.Invoke(() => loading = true); // Arrange await this.componentFixture.Initialize(); // Assert Assert.IsTrue(loading); }
public async Task Delete_invokes_unload_method() { // Arrange bool deleting = false; componentFixture.UnloadDelegate = () => TaskFromAction.Invoke(() => deleting = true); // Arrange await this.componentFixture.Delete(); // Assert Assert.IsTrue(deleting); }
public async Task Initialize_raises_loading_began_event() { // Arrange bool loading = false; componentFixture.Loading += async(component) => await TaskFromAction.Invoke(() => loading = true); componentFixture.LoadDelegate = () => Task.FromResult(true); // Arrange await this.componentFixture.Initialize(); // Assert Assert.IsTrue(loading); }
public async Task Delete_raises_delete_began_event() { // Arrange bool deleting = false; componentFixture.Deleting += async(component) => await TaskFromAction.Invoke(() => deleting = true); componentFixture.UnloadDelegate = () => Task.FromResult(true); // Arrange await this.componentFixture.Delete(); // Assert Assert.IsTrue(deleting); }