public async Task ShouldGetCreatedAndDeletedProductMessage() { MessageManager messageManager = new MessageManager(_client); //var result = await messageManager.QueryMessagesAsync(null, "createdAt desc"); var result = await messageManager.QueryMessagesAsync(string.Format("resource(id=\"{0}\") and resource(typeId=\"product\")", _testProductId)); Assert.NotNull(result); var messages = result.Result; Assert.NotNull(messages); Assert.NotNull(messages.Results); Assert.IsTrue(messages.Results.Count == 2); Assert.IsFalse(messages.Results.Any(m => string.IsNullOrEmpty(m.Type))); Assert.IsTrue(messages.Results.Count(m => m.Type.Equals("ProductCreated")) == 1); Assert.IsTrue(messages.Results.Count(m => m.Type.Equals("ProductDeleted")) == 1); ProductCreatedMessage productCreatedMessage = messages.Results.First(m => m.Type.Equals("ProductCreated")) as ProductCreatedMessage; Assert.NotNull(productCreatedMessage); Assert.NotNull(productCreatedMessage.ProductProjection); ProductDeletedMessage productDeletedMessage = messages.Results.First(m => m.Type.Equals("ProductDeleted")) as ProductDeletedMessage; Assert.NotNull(productDeletedMessage); Assert.NotNull(productDeletedMessage.CurrentProjection); Assert.NotNull(productDeletedMessage.RemovedImageUrls); }
public async Task <ActionResult> CreateAndPublishMessageToAzureServiceBus(string code, string description, CancellationToken cancellationToken) { try { var msg = new ProductCreatedMessage() { Id = Guid.NewGuid(), CreationDateTime = DateTime.UtcNow, ProductCode = code, ProductDescription = description, ProductId = new Guid("CDD8341C-BBA6-4049-9B14-D400D3C068D1") }; await _messageBus.PublishMessage(msg, "ticket-orders"); return(Ok(msg)); } catch (RequestTimeoutException) { return(StatusCode((int)HttpStatusCode.RequestTimeout)); } catch (Exception) { return(StatusCode((int)HttpStatusCode.RequestTimeout)); } }
private void buttonInsert_Click(object sender, EventArgs e) { IProductCreatedEvent eventMessage = new ProductCreatedMessage { ProductNumber = int.Parse(textBoxInsertID.Text), Description = textBoxInsertDesc.Text, Name = textBoxInsertName.Text, EventId = Guid.NewGuid(), Time = DateTime.Now, Duration = TimeSpan.FromSeconds(99999D) }; FireEvent(eventMessage); }
public void Create(ProductCreatedMessage message) { this.bus.Send(message); }