public async void Post_GivenProperCommand_ShouldReturnOk(string endpoint) { //ARRANGE string queueName = null; var source = await fixture.SubscribeAndGetAsync <ProductCreated>( //subscribe to rabbitmq onMessageReceived : (@event, @taskcompletion) => { @taskcompletion.SetResult(@event); return(Task.CompletedTask); } , queueName : queueName); //ACT var command = new NewProductCommand { Id = 10, Price = 10, Category = "any", Name = "demo1" }; var stringContent = new StringContent(JsonConvert.SerializeObject(command), Encoding.UTF8, "application/json"); var response = await client.PostAsync(endpoint, stringContent); // post the json commnad to service so it will response.StatusCode.Should().Be(200); // publish to rabbitmq //ASSERT var createdEvent = await source.Task; createdEvent.Id.Should().Be(10); // Verify the rabbitmq createdEvent.Name.Should().Be("demo1"); //YOU CAN ADD validation to command persisted to DB }
public NewProductPageVM() { newProductCommand = new NewProductCommand(this); product = new Product { UserId = App.Data.User.UserId }; }
public async void Post([FromBody] NewProductCommand value) { value.Context = GetContext <NewProductCommand>(null, null); await _dispatcher.SendAsync <NewProductCommand>(value); }
protected async Task AddProduct(NewProductCommand product) { await ExecuteAsync(posState => posState.AddNewProduct(product, HubConnection)); }