public void Setup()
        {
            HttpContextHelper.RegisterMockHttpContext();
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", "c:\\");

            simulator.SimulateRequest(new Uri("http://localhost/dnn/Default.aspx"));
        }
        public void Setup()
        {
            HttpContextHelper.RegisterMockHttpContext();
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", "c:\\");
            simulator.SimulateRequest(new Uri("http://localhost/dnn/Default.aspx"));

        }
Ejemplo n.º 3
0
        private void CreateUser(bool isSuperUser, IEnumerable <string> Roles)
        {
            var user = new UserInfo {
                IsSuperUser = isSuperUser, UserID = UserId
            };
            var mockRoleProvider = MockComponentProvider.CreateRoleProvider();
            var userRoles        = new List <UserRoleInfo>();

            foreach (var role in Roles)
            {
                userRoles.Add(new UserRoleInfo()
                {
                    RoleName = role, Status = RoleStatus.Approved
                });
            }

            mockRoleProvider.Setup(rp => rp.GetUserRoles(It.Is <UserInfo>(u => u.UserID == UserId), It.IsAny <bool>())).Returns(userRoles);
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator(this.WebsitePhysicalAppPath);

            simulator.SimulateRequest();
            HttpContextBase httpContextBase = new HttpContextWrapper(HttpContext.Current);

            HttpContextSource.RegisterInstance(httpContextBase);
            HttpContext.Current.Items["UserInfo"] = user;
        }
Ejemplo n.º 4
0
        public DnnWebTest(int portalId)
        {
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", this.WebsitePhysicalAppPath);

            simulator.SimulateRequest(new Uri(this.WebsiteAppPath));

            SetupContainer();
            InstallComponents();

            HttpContextBase httpContextBase = new HttpContextWrapper(HttpContext.Current);

            HttpContextSource.RegisterInstance(httpContextBase);

            LoadDnnProviders("data;logging;caching;authentication;members;roles;profiles;permissions;folder;clientcapability");

            // fix membership
            var providerProp = typeof(Membership).GetField("s_Provider", BindingFlags.Static | BindingFlags.NonPublic);

            providerProp.SetValue(null, Membership.Providers["AspNetSqlMembershipProvider"]);

            var objPortalAliasInfo = new Entities.Portals.PortalAliasInfo {
                PortalID = portalId
            };
            var ps = new Entities.Portals.PortalSettings(59, objPortalAliasInfo);

            HttpContext.Current.Items.Add("PortalSettings", ps);

            this.PortalId = portalId;
        }
Ejemplo n.º 5
0
        private void CreateSimulatedRequest(Uri url)
        {
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator();
            simulator.SimulateRequest(url);

            var browserCaps = new HttpBrowserCapabilities { Capabilities = new Hashtable() };
            HttpContext.Current.Request.Browser = browserCaps;
        }
Ejemplo n.º 6
0
        private void CreateSimulatedRequest(Uri url)
        {
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", this.WebsitePhysicalAppPath);

            simulator.SimulateRequest(url);

            var browserCaps = new HttpBrowserCapabilities {
                Capabilities = new Hashtable()
            };

            HttpContext.Current.Request.Browser = browserCaps;
        }
        private void CreatePresenter()
        {
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", "c:\\");

            simulator.SimulateRequest(new Uri("http://localhost/dnn/Default.aspx"));

            HttpContext.Current.Items.Add("PortalSettings", new PortalSettings());

            _presenter = new RedirectionManagerPresenter(_mockView.Object, _mockController.Object)
            {
                ModuleContext = new ModuleInstanceContext()
            };
        }
Ejemplo n.º 8
0
        public void Setup()
        {
            var serviceCollection         = new ServiceCollection();
            var mockApplicationStatusInfo = new Mock <IApplicationStatusInfo>();

            mockApplicationStatusInfo.Setup(info => info.Status).Returns(UpgradeStatus.Install);
            serviceCollection.AddTransient <IApplicationStatusInfo>(container => mockApplicationStatusInfo.Object);
            serviceCollection.AddTransient <INavigationManager>(container => Mock.Of <INavigationManager>());
            Globals.DependencyProvider = serviceCollection.BuildServiceProvider();

            HttpContextHelper.RegisterMockHttpContext();
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", "c:\\");

            simulator.SimulateRequest(new Uri("http://localhost/dnn/Default.aspx"));
        }
        public void Password_Should_Saved_In_History_During_Create_User()
        {
            var user = CreateNewUser();

            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", AppDomain.CurrentDomain.BaseDirectory);

            simulator.SimulateRequest(new Uri(this.WebsiteAppPath));
            HttpContextBase httpContextBase = new HttpContextWrapper(HttpContext.Current);

            HttpContextSource.RegisterInstance(httpContextBase);

            var isPasswordInHistory = new MembershipPasswordController().IsPasswordInHistory(user.UserID, user.PortalID, user.Membership.Password);

            Assert.AreEqual(true, isPasswordInHistory);
        }
Ejemplo n.º 10
0
        private HttpApplication GenerateApplication()
        {
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", "c:\\");

            simulator.SimulateRequest(new Uri("http://localhost/dnn/Default.aspx"));

            var app = new HttpApplication();

            var requestProp = typeof(NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);

            requestProp.SetValue(HttpContext.Current.Request.QueryString, false, null);

            var stateProp = typeof(HttpApplication).GetField("_context", BindingFlags.Instance | BindingFlags.NonPublic);

            stateProp.SetValue(app, HttpContext.Current);

            return(app);
        }
Ejemplo n.º 11
0
        public DnnWebTest(int portalId)
        {
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", WebsitePhysicalAppPath);

            simulator.SimulateRequest(new Uri(WebsiteAppPath));

            InstallComponents();

            HttpContextBase httpContextBase = new HttpContextWrapper(HttpContext.Current);

            HttpContextSource.RegisterInstance(httpContextBase);

            LoadDnnProviders("data;logging;caching;authentication;members;roles;profiles;permissions;folder;clientcapability");

            //fix Globals.ApplicationMapPath
            var appPath = WebsitePhysicalAppPath;

            if (!string.IsNullOrEmpty(appPath))
            {
                var mappath = typeof(Globals).GetField("_applicationMapPath", BindingFlags.Static | BindingFlags.NonPublic);
                mappath.SetValue(null, appPath);
            }

            //fix Globals.Status
            var status = typeof(Globals).GetField("_status", BindingFlags.Static | BindingFlags.NonPublic);

            status.SetValue(null, Globals.UpgradeStatus.None);

            //fix membership
            var providerProp = typeof(Membership).GetField("s_Provider", BindingFlags.Static | BindingFlags.NonPublic);

            providerProp.SetValue(null, Membership.Providers["AspNetSqlMembershipProvider"]);

            var objPortalAliasInfo = new Entities.Portals.PortalAliasInfo {
                PortalID = portalId
            };
            var ps = new Entities.Portals.PortalSettings(59, objPortalAliasInfo);

            HttpContext.Current.Items.Add("PortalSettings", ps);

            PortalId = portalId;
        }
Ejemplo n.º 12
0
 private void CreateUser(bool isSuperUser, IEnumerable<string> Roles)
 {
     var user = new UserInfo { IsSuperUser = isSuperUser, UserID = UserId };
     var mockRoleProvider = MockComponentProvider.CreateRoleProvider();
     var userRoles = new List<UserRoleInfo>();
     foreach (var role in Roles)
     {
         userRoles.Add(new UserRoleInfo() { RoleName = role, Status = RoleStatus.Approved });
     }
     mockRoleProvider.Setup(rp => rp.GetUserRoles(It.Is<UserInfo>(u => u.UserID == UserId), It.IsAny<bool>())).Returns(userRoles);
     var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator(WebsitePhysicalAppPath);
     simulator.SimulateRequest();
     HttpContextBase httpContextBase = new HttpContextWrapper(HttpContext.Current);
     HttpContextSource.RegisterInstance(httpContextBase);
     HttpContext.Current.Items["UserInfo"] = user;
 }
		private void CreatePresenter()
		{
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", "c:\\");
            simulator.SimulateRequest(new Uri("http://localhost/dnn/Default.aspx"));

			HttpContext.Current.Items.Add("PortalSettings", new PortalSettings());

			_presenter = new RedirectionManagerPresenter(_mockView.Object, _mockController.Object)
			             	{
								ModuleContext = new ModuleInstanceContext()
			             	};
		}
		private HttpApplication GenerateApplication()
		{
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator("/", "c:\\");
            simulator.SimulateRequest(new Uri("http://localhost/dnn/Default.aspx"));

			var app = new HttpApplication();

			var requestProp = typeof(NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
			requestProp.SetValue(HttpContext.Current.Request.QueryString, false, null);

			var stateProp = typeof(HttpApplication).GetField("_context", BindingFlags.Instance | BindingFlags.NonPublic);
			stateProp.SetValue(app, HttpContext.Current);

			return app;
		}