private static AccountController GetAccountController() { IFormsAuthentication formsAuth = new MockFormsAuthenticationService(); MembershipProvider membershipProvider = new MockMembershipProvider(); AccountMembershipService membershipService = new AccountMembershipService(membershipProvider); AccountController controller = new AccountController(formsAuth, membershipService); HttpContextBase contextBase = MvcMockHelpers.FakeHttpContext(); // new MockHttpContext(); controller.ControllerContext = new ControllerContext(contextBase, new RouteData(), controller); controller.Url = new UrlHelper(new RequestContext(contextBase, new RouteData()), new RouteCollection()); return controller; }
public void ConstructorSetsProperties() { // Arrange IFormsAuthentication formsAuth = new MockFormsAuthenticationService(); IMembershipService membershipService = new AccountMembershipService(); // Act AccountController controller = new AccountController(formsAuth, membershipService); // Assert Assert.AreEqual(formsAuth, controller.FormsAuth, "FormsAuth property did not match."); Assert.AreEqual(membershipService, controller.MembershipService, "MembershipService property did not match."); }