public async Task WhenCreatorExists_ShouldCreateSnapshot() { await this.DatabaseTestAsync(async testDatabase => { this.guidCreator.Setup(v => v.CreateSqlSequential()).Returns(SnapshotId); this.timestampCreator.Setup(v => v.Create()).Returns(Now); this.target = new CreateCreatorFreeAccessUsersSnapshotDbStatement( this.guidCreator.Object, this.timestampCreator.Object, testDatabase); await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); await this.target.ExecuteAsync(CreatorId); var expectedCreatorFreeAccessUsersSnapshot = new CreatorFreeAccessUsersSnapshot(SnapshotId, Now, CreatorId.Value); var expectedCreatorFreeAccessUsersItem1 = new CreatorFreeAccessUsersSnapshotItem(SnapshotId, null, Email1); var expectedCreatorFreeAccessUsersItem2 = new CreatorFreeAccessUsersSnapshotItem(SnapshotId, null, Email2); return(new ExpectedSideEffects { Inserts = new List <IIdentityEquatable> { expectedCreatorFreeAccessUsersSnapshot, expectedCreatorFreeAccessUsersItem1, expectedCreatorFreeAccessUsersItem2, } }); }); }
public async Task WhenCreatorDoesNotExist_ShouldCreateEmptySnapshot() { await this.DatabaseTestAsync(async testDatabase => { this.guidCreator.Setup(v => v.CreateSqlSequential()).Returns(SnapshotId); this.timestampCreator.Setup(v => v.Create()).Returns(Now); this.target = new CreateCreatorFreeAccessUsersSnapshotDbStatement( this.guidCreator.Object, this.timestampCreator.Object, testDatabase); await this.CreateDataAsync(testDatabase); await testDatabase.TakeSnapshotAsync(); var creatorId = UserId.Random(); await this.target.ExecuteAsync(creatorId); var expectedCreatorFreeAccessUsersSnapshot = new CreatorFreeAccessUsersSnapshot(SnapshotId, Now, creatorId.Value); return(new ExpectedSideEffects { Inserts = new List <IIdentityEquatable> { expectedCreatorFreeAccessUsersSnapshot, } }); }); }
public void Initialize() { this.guidCreator = new Mock <IGuidCreator>(); this.timestampCreator = new Mock <ISnapshotTimestampCreator>(); this.target = new CreateCreatorFreeAccessUsersSnapshotDbStatement( this.guidCreator.Object, this.timestampCreator.Object, new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object); }