public void Should_log_enqueued_pim_request()
        {
            // Arrange
            var messageResult = new EnqueuedRequest
            {
                MessageId = _enqueuedRequestMessageId,
                PrimaryAction = "TestPrimary",
                SecondaryAction = "TestSecondary",
                RequestItem = new ProductQueryRequestItem{ CreatedOn = DateTime.Now },
                EnqueuedAt = DateTime.Now
            };

            // Act
            _repository.LogEnqueuedRequest(messageResult);

            // Assert
            var lastMessages = _repository.GetRecentRequests(2);
            Assert.That(lastMessages.Any(msg => msg.MessageId == _enqueuedRequestMessageId), Is.True);
        }
Пример #2
0
        public void LogEnqueuedRequest(EnqueuedRequest enqueuedRequest)
        {
            var query = string.Format(
                "INSERT INTO {0}(MessageId, PrimaryAction, SecondaryAction, RequestItem, EnqueuedAt) " +
                "VALUES(@MessageId, @PrimaryAction, @SecondaryAction, @RequestItem, @EnqueuedAt);", TableName);

            using (var conn = new SQLiteConnection(_connectionString))
            {
                conn.Open();
                using (var cmd = new SQLiteCommand(query, conn))
                {
                    cmd.Parameters.AddWithValue("@MessageId", enqueuedRequest.MessageId);
                    cmd.Parameters.AddWithValue("@PrimaryAction", enqueuedRequest.PrimaryAction);
                    cmd.Parameters.AddWithValue("@SecondaryAction", enqueuedRequest.SecondaryAction);
                    cmd.Parameters.AddWithValue("@RequestItem", JsonConvert.SerializeObject(enqueuedRequest.RequestItem));
                    cmd.Parameters.AddWithValue("@EnqueuedAt", enqueuedRequest.EnqueuedAt);

                    cmd.ExecuteNonQuery();
                }
            }
        }