Пример #1
0
        public async Task Dequeue_PendingAndAlreadyProcessedItem_ReturnsPendingItem(QueueItemStatus status)
        {
            using (var scope = new IsolationScope(TestFixtureContext.Provider))
            {
                var connection = scope.Provider.GetRequiredService <IDbConnection>();
                await connection.ExecuteSqlAsync("INSERT INTO Kiukie.Queue(StatusId, Payload) OUTPUT Inserted.Id VALUES(@StatusId, @Payload)", new StringItem(status, "Processed"));

                await connection.ExecuteSqlAsync("INSERT INTO Kiukie.Queue(StatusId, Payload) OUTPUT Inserted.Id VALUES(@StatusId, @Payload)", new StringItem(QueueItemStatus.Pending, "Pending"));

                var queue = CreateQueue(connection);
                var item  = await queue.DequeueAsync();

                Assert.IsNotNull(item);
                Assert.AreEqual("Pending", item.Payload);
            }
        }
Пример #2
0
        /// <summary>
        /// Convert a boolean to visibility property.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="targetType">
        /// The target type.
        /// </param>
        /// <param name="parameter">
        /// The parameter. (A boolean which inverts the output)
        /// </param>
        /// <param name="culture">
        /// The culture.
        /// </param>
        /// <returns>
        /// Visibility property
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                QueueItemStatus status = (QueueItemStatus)value;
                switch (status)
                {
                case QueueItemStatus.Waiting:
                case QueueItemStatus.InProgress:
                    return(Visibility.Collapsed);

                default:
                    return(Visibility.Visible);
                }
            }

            return(Visibility.Collapsed);
        }
Пример #3
0
 public StringItem(QueueItemStatus status, string payload)
 {
     StatusId = (int)status;
     Payload  = payload;
 }
Пример #4
0
 public QueueItem(string fullPathForItem)
 {
     fullPath = fullPathForItem;
     status   = QueueItemStatus.Pending;
 }