[InlineData("{0xCA761232, 0xED42, 0x11CE, {0xBA, 0xCD, 0x00, 0xAA, 0x00, 0x57, 0xB2, 0x23}")] // missing ending '}' character public void ValidateInvalidGuids(string guid) { MockWebContext ctx = new MockWebContext(); ctx.ActionArguments.Add("id", guid); var actExeContext = ctx.CreateActionExecutingContext(); ValidateIdAttribute attr = new ValidateIdAttribute("id"); attr.OnActionExecuting(actExeContext); actExeContext.HttpContext.Response.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); }
public void ValidateValidGuids(string guid) { MockWebContext ctx = new MockWebContext(); ctx.ActionArguments.Add("id", guid); var actExeContext = ctx.CreateActionExecutingContext(); ValidateIdAttribute attr = new ValidateIdAttribute("id"); attr.OnActionExecuting(actExeContext); // if everything is ok the status is not changed so default 0 value is the expected value and not http 200 actExeContext.HttpContext.Response.StatusCode.Should().Be(0); }
public void ShouldHandleKeyNameNotFound() { // the attribute should handle cases that the key is not found instead of code causing KeyNotFoundException // caller has no idea what key is missing // attribute implementation skips null values so it should also skip validation if the key is not found? MockWebContext ctx = new MockWebContext(); ctx.ActionArguments.Add("id", "{CA761232-ED42-11CE-BACD-00AA0057B223}"); var actExeContext = ctx.CreateActionExecutingContext(); ValidateIdAttribute attr = new ValidateIdAttribute("notfoundkeyname"); attr.OnActionExecuting(actExeContext); // if everything is ok the status is not changed so default 0 value is the expected value and not http 200 actExeContext.HttpContext.Response.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); }