Example #1
0
 private static ControllerContext GetControllerContext(Stream stream)
 {
     return(new ControllerContext(
                MockHttpContextBase.Generate("/", stream),
                GetRouteData(),
                MockRepository.GenerateStub <ControllerBase>()));
 }
        /// <summary>
        /// Creates a new instance of the <see cref="RouteTester"/> class.
        /// </summary>
        /// <param name="routeRegistrationMethod">Action that registers routes.</param>
        /// <example>
        /// <code><![CDATA[
        ///     var routeTester = new RouteTester(RouteConfig.RegisterRoutes);
        /// ]]></code>
        /// </example>
        public RouteTester(Action <RouteCollection> routeRegistrationMethod)
        {
            _registerRoutes = routeRegistrationMethod;

            _request  = new MockHttpRequestBase();
            _response = new MockHttpResponseBase();
            _context  = new MockHttpContextBase(_request, _response);
        }
Example #3
0
        public SparkViewEngineFixture()
        {
            var settings = new SparkSettings();

            this.actionContext = new ActionContext(httpContext, "Stub");
            this.engine        = new SparkViewEngine(settings)
            {
                ViewFolder = new FileSystemViewFolder("TestViews")
            };
            this.httpContext = MockHttpContextBase.Generate("/", new StringWriter());
            this.response    = httpContext.Response;
            this.output      = response.Output;
        }
Example #4
0
        public void SetUp()
        {
            var settings = new SparkSettings();

            _factory = new SparkViewFactory(settings)
            {
                ViewFolder = new FileSystemViewFolder("FubuMVC.Tests.Views")
            };

            _httpContext = MockHttpContextBase.Generate("/", new StringWriter());
            _response    = _httpContext.Response;
            _output      = _response.Output;

            _routeData = new RouteData();
            _routeData.Values.Add("action", "Index");
            _actionContext = new ActionContext(new StubController().GetType().Namespace, "Stub");
        }
 private void SetupPostLogOut()
 {
     _accountController = new AccountsController(null);
     var httpContext = new MockHttpContextBase { User = new MockUser { Identity = new MockIdentity("", "", false) } };
     var controllerContext = new ControllerContext(httpContext, new RouteData(), new BaseController(null));
     _accountController = new AccountsController(null) { ControllerContext = controllerContext };
 }
        private void SetupPostLogInSuccess()
        {
            var authenicationService = new Mock<IAuthenticationService>();
            authenicationService.Setup(x => x.ValidateUser(ValidAccountLogInModel.EmailAddress, HashString(ValidAccountLogInModel.Password))).Returns(true);

            var httpContext = new MockHttpContextBase { User = new MockUser { Identity = new MockIdentity("", "", false) } };
            var controllerContext = new ControllerContext(httpContext, new RouteData(), new BaseController(null));
            var accountService = new Mock<IAccountService>();
            accountService.Setup(x => x.GetUserByEmailAddress(It.IsAny<string>())).Returns<User>(null);
            _accountController = new AccountsController(new BaseServiceCollection(accountService.Object, null, authenicationService.Object)) { ControllerContext = controllerContext };
        }
 private void SetupGetLogInForAuthenticatedUser()
 {
     var mockUser = new MockUser { Identity = new MockIdentity("", "", true) };
     var mockHttpContext = new MockHttpContextBase { User = mockUser };
     var controllerContext = new ControllerContext { HttpContext = mockHttpContext };
     var accountService = new Mock<IAccountService>();
     accountService.Setup(x => x.GetUserByEmailAddress(It.IsAny<string>())).Returns(new User());
     var baseServiceCollection = new BaseServiceCollection(accountService.Object, null, null);
     _accountController = new AccountsController(baseServiceCollection) { ControllerContext = controllerContext };
 }
 private void SetupGetEditEvent()
 {
     var eventService = new Mock<IEventService>();
     eventService.Setup(x => x.GetEventById(It.IsAny<long>())).Returns(new Event { Flyer = new Image() });
     var accountService = new Mock<IAccountService>();
     accountService.Setup(x => x.GetUserByEmailAddress(It.IsAny<string>())).Returns(new User { FirstName = "Test", LastName = "Test" });
     var httpContext = new MockHttpContextBase { User = new MockUser { Identity = new MockIdentity("", "", false) } };
     var baseServices = new BaseServiceCollection(accountService.Object, null, null);
     _eventsController = new EventsController(baseServices, eventService.Object)
                             {
                                 ControllerContext = new ControllerContext(httpContext, new RouteData(), new BaseController(baseServices))
                             };
 }
 private void SetupGetCreateEvent()
 {
     var service = new Mock<IAccountService>();
     service.Setup(x => x.GetUserByEmailAddress(It.IsAny<string>())).Returns(new User { FirstName = "Test", LastName = "Test" });
     var httpContext = new MockHttpContextBase { User = new MockUser { Identity = new MockIdentity("", "", false) } };
     var controllerContext = new ControllerContext(httpContext, new RouteData(), new BaseController(new BaseServiceCollection(service.Object, null, null)));
     _eventsController = new EventsController(new BaseServiceCollection(service.Object, null, null), null) { ControllerContext = controllerContext };
 }
 private void SetupCreateEventSuccess()
 {
     var eventService = new Mock<IEventService>();
     eventService.Setup(x => x.SaveEvent(It.IsAny<Event>())).Returns(new Event());
     var accountService = new Mock<IAccountService>();
     accountService.Setup(x => x.GetUserByEmailAddress(It.IsAny<string>())).Returns(new User { FirstName = "Test", LastName = "Test" });
     var httpContext = new MockHttpContextBase { User = new MockUser { Identity = new MockIdentity("", "", false) } };
     var controllerContext = new ControllerContext(httpContext, new RouteData(), new BaseController(new BaseServiceCollection(accountService.Object, null, null)));
     Event.FlyerSizes = new List<ImageSizes>();
     _eventsController = new EventsController(new BaseServiceCollection(accountService.Object, null, null), eventService.Object) { ControllerContext = controllerContext };
 }