Example #1
0
        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
                    }
                });
            });
        }
Example #2
0
        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,
                    }
                });
            });
        }
Example #3
0
        public void Initialize()
        {
            this.timestampCreator = new Mock <ISnapshotTimestampCreator>();

            this.target = new CreateSubscriberSnapshotDbStatement(
                this.timestampCreator.Object,
                new Mock <IFifthweekDbConnectionFactory>(MockBehavior.Strict).Object);
        }