public void ShouldInsertNewQueueItemToDatabase() { _target.Send(Message); _queueRepository.Verify(_ => _.Insert(It.Is <Queue>(q => q.Body.Equals(Message) && q.Created.Equals(_currentDateUtc) && (q.IsProcessed == false) && (q.Processed == null) && (q.Type == Key.ToString())))); }
public void ShouldTakeNextUnprocessedMessage() { _queueRepository .Setup(_ => _.GetNextByType(Key.ToString())) .Returns(new[] { _queue }.AsQueryable()); var result = _target.Read(); result.Should().NotBeNullOrEmpty(); result.Should().BeEquivalentTo(QueueMessage); _queue.IsProcessed.Should().BeTrue(); _queue.Processed.ShouldBeEquivalentTo(_currentDateUtc); }
public string Read() { var queueElement = _queueRepository .GetNextByType(_key.ToString()) .FirstOrDefault(); if (queueElement == null) { return(null); } queueElement.IsProcessed = true; queueElement.Processed = _timeService.GetUtc(); return(queueElement.Body); }
public void Send(string message) { if (string.IsNullOrEmpty(message)) { throw new ArgumentNullException(nameof(message)); } var queueElement = new Queue { Body = message, Created = _timeService.GetUtc(), IsProcessed = false, Processed = null, Type = _key.ToString() }; _queueRepository.Insert(queueElement); }