コード例 #1
0
        private async Task CreateQueueAsync(CreateQueueCommand command)
        {
            var queue = new Queue(
                command.NewQueueId.Value,
                command.BlogId.Value,
                null,
                command.Name.Value,
                DateTime.UtcNow);

            var releaseDate = new WeeklyReleaseTime(
                command.NewQueueId.Value,
                null,
                (byte)command.InitialWeeklyReleaseTime.Value);

            // Assuming no lock escalation, this transaction will hold X locks on the new rows and IX locks further up the hierarchy,
            // so no deadlocks are to be expected.
            using (var transaction = TransactionScopeBuilder.CreateAsync())
            {
                using (var connection = this.connectionFactory.CreateConnection())
                {
                    await connection.InsertAsync(queue);

                    await connection.InsertAsync(releaseDate);
                }

                transaction.Complete();
            }
        }
コード例 #2
0
        public async Task ItShouldCreateWeeklyReleaseTime()
        {
            await this.DatabaseTestAsync(async testDatabase =>
            {
                this.InitializeTarget(testDatabase);
                await this.CreateEntitiesAsync(testDatabase);
                await testDatabase.TakeSnapshotAsync();

                await this.target.HandleAsync(Command);

                var expectedWeeklyReleaseTime = new WeeklyReleaseTime(
                    QueueId.Value,
                    null,
                    (byte)InitialWeeklyReleaseTime.Value);

                return(new ExpectedSideEffects
                {
                    Insert = expectedWeeklyReleaseTime,
                    ExcludedFromTest = entity => entity is Queue
                });
            });
        }