public override async Task WhenAsync() { _payload = new EnableOnRequestHandlingRequest { TargetPattern = ".*" }; _response = await _client.PostAsync( Routes.Anarchy.SetOrCancelOnRequestHandling.Replace("{anarchyType}", "testAction"), new StringContent(JsonConvert.SerializeObject(_payload), Encoding.UTF8, "application/json")); }
public IActionResult SetActionTargetPattern(string anarchyType, [FromBody] EnableOnRequestHandlingRequest request) { _logger.LogInformation("Assigning target pattern: '{targetPattern}' to {anarchyType}", request?.TargetPattern ?? "null", anarchyType); if (request == null) { throw new RequestBodyRequiredException <EnableOnRequestHandlingRequest>(); } _anarchyManager.AssignTargetPattern(anarchyType, request.TargetPattern); return(new OkResult()); }
public void SetActionTargetPatternTests_PassesTargetPatternToManager() { //Arrange var anarchyManager = Substitute.For <IAnarchyManagerNew>(); var logger = Substitute.For <ILogger <Anarchy.Controllers.AnarchyController> >(); var sut = new Anarchy.Controllers.AnarchyController(anarchyManager, logger); var request = new EnableOnRequestHandlingRequest { TargetPattern = "aTargetPattern" }; //Act sut.SetActionTargetPattern(anarchyType, request); //Assert anarchyManager.Received(1).AssignTargetPattern(anarchyType, request.TargetPattern); }