public void RemoveFromQueue_ReallyDeletesTheJobFromTheQueue()
        {
            // Arrange
            var id            = CreateJobQueueRecord(_storage, "1", "default");
            var processingJob = new PostgreSqlFetchedJob(_storage, _options, id, "1", "default");

            // Act
            processingJob.RemoveFromQueue();

            // Assert
            var count = _storage.UseConnection(connection =>
                                               connection.Query <long>(@"select count(*) from """ + GetSchemaName() + @""".""jobqueue""").Single());

            Assert.Equal(0, count);
        }
示例#2
0
        private static void UseConnection(Action <IDbConnection, PostgreSqlStorage> action)
        {
            var storage = new PostgreSqlStorage(ConnectionUtils.GetConnectionString());

            storage.UseConnection(connection =>
            {
                action(connection, storage);

                return(true);
            });
        }
        private static long CreateJobQueueRecord(PostgreSqlStorage storage, string jobId, string queue)
        {
            string arrangeSql = @"
insert into """ + GetSchemaName() + @""".""jobqueue"" (""jobid"", ""queue"", ""fetchedat"")
values (@id, @queue, now() at time zone 'utc') returning ""id""";

            return
                ((long)
                 storage.UseConnection(connection => connection.Query(arrangeSql, new { id = Convert.ToInt32(jobId, CultureInfo.InvariantCulture), queue = queue })
                                       .Single()
                                       .id));
        }