public async Task WhenTheSubscriptionExists_ItShouldDeleteTheSubscription() { await this.DatabaseTestAsync(async testDatabase => { this.target = new UnsubscribeFromChannelDbStatement(testDatabase, this.requestSnapshot); await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); await this.target.ExecuteAsync(UserId, Subscriptions[0].ChannelId); var deletion = new ChannelSubscription( Subscriptions[0].ChannelId.Value, null, UserId.Value, null, Subscriptions[0].AcceptedPrice.Value, PriceLastAcceptedDate, SubscriptionStartDate); return(new ExpectedSideEffects { Delete = deletion }); }); }
public async Task ItShouldRequestSnapshotAfterUpdate() { await this.DatabaseTestAsync(async testDatabase => { var trackingDatabase = new TrackingConnectionFactory(testDatabase); this.target = new UnsubscribeFromChannelDbStatement(trackingDatabase, this.requestSnapshot); await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); this.requestSnapshot.VerifyConnectionDisposed(trackingDatabase); await this.target.ExecuteAsync(UserId, Subscriptions[0].ChannelId); this.requestSnapshot.VerifyCalledWith(UserId, SnapshotType.SubscriberChannels); var deletion = new ChannelSubscription( Subscriptions[0].ChannelId.Value, null, UserId.Value, null, Subscriptions[0].AcceptedPrice.Value, PriceLastAcceptedDate, SubscriptionStartDate); return(new ExpectedSideEffects { Delete = deletion }); }); }
public async Task WhenTheUserDoesNotExist_ItShouldDoNothing() { await this.DatabaseTestAsync(async testDatabase => { this.target = new UnsubscribeFromChannelDbStatement(testDatabase, this.requestSnapshot); await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); await this.target.ExecuteAsync(new UserId(Guid.NewGuid()), Subscriptions[0].ChannelId); return(ExpectedSideEffects.None); }); }
public async Task ItShouldBeIdempotent() { await this.DatabaseTestAsync(async testDatabase => { this.target = new UnsubscribeFromChannelDbStatement(testDatabase, this.requestSnapshot); await this.CreateDataAsync(testDatabase); await this.target.ExecuteAsync(UserId, Subscriptions[0].ChannelId); await testDatabase.TakeSnapshotAsync(); await this.target.ExecuteAsync(UserId, Subscriptions[0].ChannelId); return(ExpectedSideEffects.None); }); }
public async Task ItShouldNotUpdateIfSnapshotFails() { await this.DatabaseTestAsync(async testDatabase => { this.target = new UnsubscribeFromChannelDbStatement(testDatabase, this.requestSnapshot); await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); this.requestSnapshot.ThrowException(); await ExpectedException.AssertExceptionAsync <SnapshotException>( () => this.target.ExecuteAsync(UserId, Subscriptions[0].ChannelId)); return(ExpectedSideEffects.TransactionAborted); }); }
public void TestInitialize() { this.requestSnapshot = new MockRequestSnapshotService(); this.target = new UnsubscribeFromChannelDbStatement(new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object, this.requestSnapshot); }