public async Task WhenCreatorExists_ShouldCreateSnapshot() { await this.DatabaseTestAsync(async testDatabase => { this.timestampCreator.Setup(v => v.Create()).Returns(Now); this.target = new CreateSubscriberSnapshotDbStatement( this.timestampCreator.Object, testDatabase); var user = await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); await this.target.ExecuteAsync(SubscriberId); var expectedSubscriberSnapshot = new SubscriberSnapshot(Now, SubscriberId.Value, user.Email); return(new ExpectedSideEffects { Inserts = new List <IIdentityEquatable> { expectedSubscriberSnapshot } }); }); }
public async Task WhenCreatorDoesNotExist_ShouldCreateEmptySnapshot() { await this.DatabaseTestAsync(async testDatabase => { this.timestampCreator.Setup(v => v.Create()).Returns(Now); this.target = new CreateSubscriberSnapshotDbStatement( this.timestampCreator.Object, testDatabase); var user = await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); var subscriberId = UserId.Random(); await this.target.ExecuteAsync(subscriberId); var expectedCreatorChannelSnapshot = new SubscriberSnapshot(Now, subscriberId.Value, null); return(new ExpectedSideEffects { Inserts = new List <IIdentityEquatable> { expectedCreatorChannelSnapshot, } }); }); }
public void Initialize() { this.timestampCreator = new Mock <ISnapshotTimestampCreator>(); this.target = new CreateSubscriberSnapshotDbStatement( this.timestampCreator.Object, new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object); }