1 // Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
2 
3 using Moq;
4 using Xunit;
5 using Assert = Microsoft.TestCommon.AssertEx;
6 
7 namespace System.Web.Mvc.Test
8 {
9     public class AuthorizationContextTest
10     {
11         [Fact]
ConstructorThrowsIfActionDescriptorIsNull()12         public void ConstructorThrowsIfActionDescriptorIsNull()
13         {
14             // Arrange
15             ControllerContext controllerContext = new Mock<ControllerContext>().Object;
16             ActionDescriptor actionDescriptor = null;
17 
18             // Act & assert
19             Assert.ThrowsArgumentNull(
20                 delegate { new AuthorizationContext(controllerContext, actionDescriptor); }, "actionDescriptor");
21         }
22 
23         [Fact]
PropertiesAreSetByConstructor()24         public void PropertiesAreSetByConstructor()
25         {
26             // Arrange
27             ControllerContext controllerContext = new Mock<ControllerContext>().Object;
28             ActionDescriptor actionDescriptor = new Mock<ActionDescriptor>().Object;
29 
30             // Act
31             AuthorizationContext authorizationContext = new AuthorizationContext(controllerContext, actionDescriptor);
32 
33             // Assert
34             Assert.Equal(actionDescriptor, authorizationContext.ActionDescriptor);
35         }
36     }
37 }
38