public void SetsContentTypeHeader(HttpActionContext context, TestableJSendAuthorizeAttribute attribute)
 {
     // Exercise system
     attribute.OnAuthorization(context);
     // Verify outcome
     context.Response.Content.Headers.ContentType.MediaType.Should().Be("application/json");
 }
Esempio n. 2
0
 public void SetsContentTypeHeader(HttpActionContext context, TestableJSendAuthorizeAttribute attribute)
 {
     // Exercise system
     attribute.OnAuthorization(context);
     // Verify outcome
     context.Response.Content.Headers.ContentType.MediaType.Should().Be("application/json");
 }
 public void SetsStatusCode(HttpActionContext context, TestableJSendAuthorizeAttribute attribute)
 {
     // Exercise system
     attribute.OnAuthorization(context);
     // Verify outcome
     context.Response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
 }
Esempio n. 4
0
 public void SetsStatusCode(HttpActionContext context, TestableJSendAuthorizeAttribute attribute)
 {
     // Exercise system
     attribute.OnAuthorization(context);
     // Verify outcome
     context.Response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
 }
 public void CreatesResponse(HttpActionContext context, TestableJSendAuthorizeAttribute attribute)
 {
     // Fixture setup
     context.Response = null;
     // Exercise system
     attribute.OnAuthorization(context);
     // Verify outcome
     context.Response.Should().NotBeNull();
 }
Esempio n. 6
0
 public void CreatesResponse(HttpActionContext context, TestableJSendAuthorizeAttribute attribute)
 {
     // Fixture setup
     context.Response = null;
     // Exercise system
     attribute.OnAuthorization(context);
     // Verify outcome
     context.Response.Should().NotBeNull();
 }
 public async Task CreatesFailResponse(HttpActionContext context, TestableJSendAuthorizeAttribute attribute)
 {
     // Fixture setup
     var expectedMessage = JsonConvert.SerializeObject(new FailResponse(StringResources.RequestNotAuthorized));
     // Exercise system
     attribute.OnAuthorization(context);
     // Verify outcome
     var message = await context.Response.Content.ReadAsStringAsync();
     message.Should().Be(expectedMessage);
 }
Esempio n. 8
0
        public async Task CreatesFailResponse(HttpActionContext context, TestableJSendAuthorizeAttribute attribute)
        {
            // Fixture setup
            var expectedMessage = JsonConvert.SerializeObject(new FailResponse(StringResources.RequestNotAuthorized));

            // Exercise system
            attribute.OnAuthorization(context);
            // Verify outcome
            var message = await context.Response.Content.ReadAsStringAsync();

            message.Should().Be(expectedMessage);
        }
 public void ThrowsWhenContextIsNull(TestableJSendAuthorizeAttribute attribute)
 {
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => attribute.OnAuthorization(null));
 }
Esempio n. 10
0
 public void ThrowsWhenContextIsNull(TestableJSendAuthorizeAttribute attribute)
 {
     // Exercise system and verify outcome
     Assert.Throws <ArgumentNullException>(() => attribute.OnAuthorization(null));
 }