private async Task ArchiveAppAsync(ArchiveApp command) { var appId = command.AppId; var app = await grainFactory.GetGrain <IAppGrain>(appId).GetStateAsync(); if (IsFound(app.Value, true)) { await Index().RemoveAsync(appId); } foreach (var contributorId in app.Value.Contributors.Keys) { await Index(contributorId).RemoveAsync(appId); } }
public async Task ArchiveApp_should_create_events_and_update_state() { var command = new ArchiveApp(); await ExecuteCreateAsync(); var result = await sut.ExecuteAsync(CreateCommand(command)); result.ShouldBeEquivalent(new EntitySavedResult(5)); LastEvents .ShouldHaveSameEvents( CreateEvent(new AppArchived()) ); A.CallTo(() => appPlansBillingManager.ChangePlanAsync(command.Actor.Identifier, AppId, AppName, null)); }
public async Task Should_remove_app_from_indexes_when_app_gets_archived() { SetupApp(isArchived: true); var command = new ArchiveApp { AppId = appId }; var context = new CommandContext(command, commandBus) .Complete(); await sut.HandleAsync(context); A.CallTo(() => indexByName.RemoveAsync(appId.Id)) .MustHaveHappened(); A.CallTo(() => indexForUser.RemoveAsync(appId.Id)) .MustHaveHappenedOnceExactly(); }
public async Task ArchiveApp_should_create_events_and_update_archived_flag() { var command = new ArchiveApp(); await ExecuteCreateAsync(); var result = await PublishAsync(command); result.ShouldBeEquivalent(new EntitySavedResult(4)); Assert.True(sut.Snapshot.IsArchived); LastEvents .ShouldHaveSameEvents( CreateEvent(new AppArchived()) ); A.CallTo(() => appPlansBillingManager.ChangePlanAsync(command.Actor.Identifier, AppNamedId, null, A <string?> ._)) .MustHaveHappened(); }
public async Task Should_remove_app_from_indexes_on_archive(bool isArchived) { SetupApp(0, isArchived); var command = new ArchiveApp { AppId = appId }; var context = new CommandContext(command, commandBus) .Complete(); await sut.HandleAsync(context); A.CallTo(() => indexByName.RemoveAsync(appId.Id)) .MustHaveHappened(); A.CallTo(() => indexByUser.RemoveAsync(appId.Id)) .MustHaveHappened(); }
public async Task Should_also_remove_app_from_client_index_when_created_by_client() { SetupApp(fromClient: true); var command = new ArchiveApp { AppId = appId }; var context = new CommandContext(command, commandBus) .Complete(); await sut.HandleAsync(context); A.CallTo(() => indexByName.RemoveAsync(appId.Id)) .MustHaveHappened(); A.CallTo(() => indexForUser.RemoveAsync(appId.Id)) .MustHaveHappened(); A.CallTo(() => indexForClient.RemoveAsync(appId.Id)) .MustHaveHappened(); }
public void ArchiveApp(ArchiveApp command) { RaiseEvent(SimpleMapper.Map(command, new AppArchived())); }
public void ArchiveApp(ArchiveApp command) { Raise(command, new AppArchived()); }
private void ArchiveApp(ArchiveApp command) { Raise(command, new AppArchived()); }