public void ShouldFail_When_InputCountryInValid(string country) { var command = new UpdateMerchantCommand { UniqueId = "62178593-efbc-4ba2-9bbd-d2841c896820", Currency = "AUD", Country = country, WebsiteUrl = "www.test.com", DiscountPercentage = 10 }; var validationResult = _validator.TestValidate(command); validationResult.ShouldHaveValidationErrorFor(nameof(UpdateMerchantCommand.Country)); }
public void ShouldFail_When_InputUniqueIdInValid(string uniqueId) { var command = new UpdateMerchantCommand { UniqueId = uniqueId, Currency = "AUD", Country = "Australia", WebsiteUrl = "www.test.com", DiscountPercentage = 10 }; var validationResult = _validator.TestValidate(command); validationResult.ShouldHaveValidationErrorFor(nameof(UpdateMerchantCommand.UniqueId)); }
public void ShouldPass_When_InputFormatValid( string uniqueId, string currency, string country, string websiteUrl, decimal discountPercentage) { var command = new UpdateMerchantCommand { UniqueId = uniqueId, Currency = currency, Country = country, WebsiteUrl = websiteUrl, DiscountPercentage = discountPercentage }; var validationResult = _validator.TestValidate(command); validationResult.ShouldNotHaveAnyValidationErrors(); }
public async void ShouldUpdateMerchantCorrectly() { var requestBody = new UpdateMerchantCommand { UniqueId = "62178593-efbc-4ba2-9bbd-d2841c896820", IsActive = true, Currency = "AUD", WebsiteUrl = "www.test-04.com", Country = "Australia", DiscountPercentage = 5.0m }; var requestMessage = MockHelper.CreateHttpRequestMessage( URL, HttpMethod.Put, requestBody); var response = await _testFactory.CreateClient().SendAsync(requestMessage); response.StatusCode.Should().Be(HttpStatusCode.OK); }
public async Task <ActionResult> UpdateMerchant([FromBody][Required] UpdateMerchantCommand request) { var response = await Mediator.Send(request); return(response.ToActionResult()); }
public async Task <IActionResult> UpdateMerchant(int id, UpdateMerchantCommand data) { data.DataD.Attributes.Id = id; return(Ok(await _mediatr.Send(data))); }