public void TestRouteSuppliersGetPartners()
        {
            const string Url    = "/byCategories/222";
            var          routes = new RouteCollection();

            // Get my AreaRegistration class
            var areaRegistration = new UserAreaRegistration();

            Assert.AreEqual("Private", areaRegistration.AreaName);

            // Get an AreaRegistrationContext for my class. Give it an empty RouteCollection
            var areaRegistrationContext = new AreaRegistrationContext(areaRegistration.AreaName, routes);

            areaRegistration.RegisterArea(areaRegistrationContext);

            // Mock up an HttpContext object with my test path (using Moq)
            var context = new Mock <HttpContextBase>();

            context.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/Private");

            // Get the RouteData based on the HttpContext
            var routeData = routes.GetRouteData(context.Object);

            routes.ShouldMap(Url).To <SuppliersController>(c => c.GetPartners(222));
        }
Exemple #2
0
        public void HaveAreaNameProperty_WithTheCorrectName()
        {
            // Arrange
            string correctAreaName = "User";

            UserAreaRegistration registration = new UserAreaRegistration();

            // Act, Assert
            Assert.AreSame(registration.AreaName, correctAreaName);
        }
Exemple #3
0
        public void SetLowercaseUrlsToTrue_WhenRegistrationContextIsProvided()
        {
            // Arrange
            UserAreaRegistration    registration = new UserAreaRegistration();
            AreaRegistrationContext context      = new AreaRegistrationContext(
                registration.AreaName,
                new RouteCollection());

            // Act
            registration.RegisterArea(context);

            // Assert
            Assert.That(context.Routes.LowercaseUrls, Is.EqualTo(true));
        }