public async Task Invoke_Should_ReturnNotFound_When_ThingNotExists() { int code = default; _response.StatusCode = Arg.Do <int>(args => code = args); var thing = _fixture.Create <string>(); _thingActivator.CreateInstance(_service, thing) .Returns(null as Thing); _routeValue.GetValue <string>("thing") .Returns(thing); _routeValue.GetValue <string>("name") .Returns(_fixture.Create <string>()); _routeValue.GetValue <string>("id") .Returns(_fixture.Create <string>()); await DeleteActionById.Invoke(_httpContext); code.Should().Be((int)HttpStatusCode.NotFound); _thingActivator .Received(1) .CreateInstance(_service, thing); }
public async Task Invoke_Should_Return404_When_ActionDoesNotContainsAction() { int code = default; _response.StatusCode = Arg.Do <int>(args => code = args); var thingId = _fixture.Create <string>(); var thing = Substitute.For <Thing>(); _thingActivator.CreateInstance(_service, thingId) .Returns(thing); thing.Actions .Returns(new ActionCollection()); _routeValue.GetValue <string>("thing") .Returns(thingId); _routeValue.GetValue <string>("name") .Returns(_fixture.Create <string>()); _routeValue.GetValue <string>("id") .Returns(_fixture.Create <string>()); await DeleteActionById.Invoke(_httpContext); code.Should().Be((int)HttpStatusCode.NotFound); _thingActivator .Received(1) .CreateInstance(_service, thingId); }
public async Task Invoke_Should_Return204_When_ActionContainsAction() { int code = default; _response.StatusCode = Arg.Do <int>(args => code = args); var thingId = _fixture.Create <string>(); var thing = _fixture.Create <Thing>(); _thingActivator.CreateInstance(_service, thingId) .Returns(thing); var actionName = _fixture.Create <string>(); var action = Substitute.For <Action>(); var actionId = _fixture.Create <string>(); action.Id.Returns(actionId); action.Name.Returns(actionName); thing.Actions.Add(action); _routeValue.GetValue <string>("thing") .Returns(thingId); _routeValue.GetValue <string>("name") .Returns(actionName); _routeValue.GetValue <string>("id") .Returns(actionId); await DeleteActionById.Invoke(_httpContext); code.Should().Be((int)HttpStatusCode.NoContent); _thingActivator .Received(1) .CreateInstance(_service, thingId); }