public void TearDown() { DataService.ClearInstance(); MockComponentProvider.ResetContainer(); }
public void TearDown() { MockComponentProvider.ResetContainer(); TabController.ClearInstance(); }
public void SetUp() { //Register MockCachingProvider mockCache = MockComponentProvider.CreateNew <CachingProvider>(); }
public void SetUp() { // Register MockCachingProvider this.mockCache = MockComponentProvider.CreateNew <CachingProvider>(); MockComponentProvider.CreateDataProvider().Setup(c => c.GetProviderPath()).Returns(string.Empty); }
public void SetUp() { var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient <IApplicationStatusInfo>(container => Mock.Of <IApplicationStatusInfo>()); serviceCollection.AddTransient <INavigationManager>(container => Mock.Of <INavigationManager>()); serviceCollection.AddTransient <IHostSettingsService, HostController>(); Globals.DependencyProvider = serviceCollection.BuildServiceProvider(); ComponentFactory.Container = new SimpleContainer(); this.dataProvider = MockComponentProvider.CreateDataProvider(); this.dataProvider.Setup(d => d.GetProviderPath()).Returns(string.Empty); MockComponentProvider.CreateDataCacheProvider(); MockComponentProvider.CreateEventLogController(); this.dtProfiles = new DataTable("PreviewProfiles"); var pkCol = this.dtProfiles.Columns.Add("Id", typeof(int)); this.dtProfiles.Columns.Add("PortalId", typeof(int)); this.dtProfiles.Columns.Add("Name", typeof(string)); this.dtProfiles.Columns.Add("Width", typeof(int)); this.dtProfiles.Columns.Add("Height", typeof(int)); this.dtProfiles.Columns.Add("UserAgent", typeof(string)); this.dtProfiles.Columns.Add("SortOrder", typeof(int)); this.dtProfiles.PrimaryKey = new[] { pkCol }; this.dataProvider.Setup(d => d.SavePreviewProfile( It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns <int, int, string, int, int, string, int, int>( (id, portalId, name, width, height, userAgent, sortOrder, userId) => { if (id == -1) { if (this.dtProfiles.Rows.Count == 0) { id = 1; } else { id = Convert.ToInt32(this.dtProfiles.Select(string.Empty, "Id Desc")[0]["Id"]) + 1; } var row = this.dtProfiles.NewRow(); row["Id"] = id; row["PortalId"] = portalId; row["name"] = name; row["width"] = width; row["height"] = height; row["useragent"] = userAgent; row["sortorder"] = sortOrder; this.dtProfiles.Rows.Add(row); } else { var rows = this.dtProfiles.Select("Id = " + id); if (rows.Length == 1) { var row = rows[0]; row["name"] = name; row["width"] = width; row["height"] = height; row["useragent"] = userAgent; row["sortorder"] = sortOrder; } } return(id); }); this.dataProvider.Setup(d => d.GetPreviewProfiles(It.IsAny <int>())).Returns <int>((portalId) => { return(this.GetProfilesCallBack(portalId)); }); this.dataProvider.Setup(d => d.DeletePreviewProfile(It.IsAny <int>())).Callback <int>((id) => { var rows = this.dtProfiles.Select("Id = " + id); if (rows.Length == 1) { this.dtProfiles.Rows.Remove(rows[0]); } }); }
public void SetUp() { MockComponentProvider.ResetContainer(); }
public void TearDown() { DataService.ClearInstance(); SubscriptionSecurityController.ClearInstance(); MockComponentProvider.ResetContainer(); }
public void TearDown() { Globals.DependencyProvider = null; DataService.ClearInstance(); MockComponentProvider.ResetContainer(); }
private void SetupRoleProvider() { var mockRoleProvider = MockComponentProvider.CreateNew <RoleProvider>(); }
public void Setup() { MockComponentProvider.ResetContainer(); this.SetupCBO(); this.SetupHostController(); }
public virtual void TearDown() { MockComponentProvider.ResetContainer(); PortalController.ClearInstance(); ModuleController.ClearInstance(); }
public void SetUp() { ComponentFactory.Container = new SimpleContainer(); _dataProvider = MockComponentProvider.CreateDataProvider(); _dataProvider.Setup(d => d.GetProviderPath()).Returns(""); MockComponentProvider.CreateDataCacheProvider(); MockComponentProvider.CreateEventLogController(); _dtProfiles = new DataTable("PreviewProfiles"); var pkCol = _dtProfiles.Columns.Add("Id", typeof(int)); _dtProfiles.Columns.Add("PortalId", typeof(int)); _dtProfiles.Columns.Add("Name", typeof(string)); _dtProfiles.Columns.Add("Width", typeof(int)); _dtProfiles.Columns.Add("Height", typeof(int)); _dtProfiles.Columns.Add("UserAgent", typeof(string)); _dtProfiles.Columns.Add("SortOrder", typeof(int)); _dtProfiles.PrimaryKey = new[] { pkCol }; _dataProvider.Setup(d => d.SavePreviewProfile(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns <int, int, string, int, int, string, int, int>( (id, portalId, name, width, height, userAgent, sortOrder, userId) => { if (id == -1) { if (_dtProfiles.Rows.Count == 0) { id = 1; } else { id = Convert.ToInt32(_dtProfiles.Select("", "Id Desc")[0]["Id"]) + 1; } var row = _dtProfiles.NewRow(); row["Id"] = id; row["PortalId"] = portalId; row["name"] = name; row["width"] = width; row["height"] = height; row["useragent"] = userAgent; row["sortorder"] = sortOrder; _dtProfiles.Rows.Add(row); } else { var rows = _dtProfiles.Select("Id = " + id); if (rows.Length == 1) { var row = rows[0]; row["name"] = name; row["width"] = width; row["height"] = height; row["useragent"] = userAgent; row["sortorder"] = sortOrder; } } return(id); }); _dataProvider.Setup(d => d.GetPreviewProfiles(It.IsAny <int>())).Returns <int>((portalId) => { return(GetProfilesCallBack(portalId)); }); _dataProvider.Setup(d => d.DeletePreviewProfile(It.IsAny <int>())).Callback <int>((id) => { var rows = _dtProfiles.Select("Id = " + id); if (rows.Length == 1) { _dtProfiles.Rows.Remove(rows[0]); } }); }
public void Setup() { var mockMembership = MockComponentProvider.CreateNew <MembershipProvider>(); mockMembership.Setup(m => m.PasswordRetrievalEnabled).Returns(true); }
public void CheckForRedirects_WithUmlautUrls_DontRedirectInfinitely() { // Arrange const string CheckForRedirectsMethodName = "CheckForRedirects"; const string HostSettingsTableName = "HostSettings"; const string PortalSettingsTableName = "PortalSettings"; const string LanguagesTableName = "Languages"; const string TabsTableName = "Tabs"; const string TabUrlsTableName = "TabUrls"; const string PortalsTableName = "Portals"; const string TabSettingsTableName = "TabSettings"; const string PortalAliasTableName = "PortalAlias"; const string ExtensionUrlProviderTableName = "ExtensionUrlProvider"; const string HttpScheme = "http"; const string HttpsScheme = "https"; const string UriUrl = HttpScheme + "://" + GenericHost + "/über-uns/ctl/module/moduleid/466?returnurl=/über-uns"; const string FullUrl = HttpScheme + "://" + GenericHost + "/%C3%BCber-uns/ctl/module/moduleid/466?returnurl=/%C3%BCber-uns"; const string RewritePath = "Default.aspx?TabId=1&ctl=module&moduleid=466&returnurl=/%C3%BCber-uns&language=en-US"; const string SampleHttpsUrl = HttpsScheme + "://google.com"; const string PortalSettingsControllerRegistrationName = "PortalSettingsController"; const string DNNPlatformText = "DNN Platform"; const string WebsiteText = "Website"; const string ApplicationPath = "/"; const string UrlRewriteItemName = "UrlRewrite:OriginalUrl"; ComponentFactory.Container = null; PortalController.ClearInstance(); Host.PerformanceSetting = Globals.PerformanceSettings.ModerateCaching; var uri = new Uri(Assembly.GetExecutingAssembly().CodeBase); var path = HttpUtility.UrlDecode(Path.GetFullPath(uri.AbsolutePath)); var websiteRootPath = path.Substring(0, path.IndexOf(DNNPlatformText, StringComparison.Ordinal)); var physicalAppPath = Path.Combine(websiteRootPath, WebsiteText); var simulator = new HttpSimulator(ApplicationPath, physicalAppPath); simulator.SimulateRequest(new Uri(SampleHttpsUrl)); HttpContext.Current.Items.Add(UrlRewriteItemName, FullUrl); var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient(container => Mock.Of <IHostSettingsService>()); serviceCollection.AddTransient(container => Mock.Of <IApplicationStatusInfo>()); serviceCollection.AddTransient(container => Mock.Of <INavigationManager>()); serviceCollection.AddTransient(container => Mock.Of <IPortalAliasService>()); MockComponentProvider.CreateNew <CachingProvider>(); MockComponentProvider.CreateNew <DataProvider>(); MockComponentProvider.CreateNew <LoggingProvider>(); MockComponentProvider.CreateNew <PortalSettingsController>(PortalSettingsControllerRegistrationName); var dataProvider = MockComponentProvider.CreateDataProvider(); var hostSettingsTable = new DataTable(HostSettingsTableName); dataProvider .Setup(s => s.GetHostSettings()) .Returns(() => hostSettingsTable.CreateDataReader()); var portalSettingsTable = new DataTable(PortalSettingsTableName); dataProvider .Setup(s => s.GetPortalSettings( It.IsAny <int>(), It.IsAny <string>())) .Returns(() => portalSettingsTable.CreateDataReader()); var languagesTable = new DataTable(LanguagesTableName); dataProvider .Setup(s => s.GetLanguagesByPortal(It.IsAny <int>())) .Returns(() => languagesTable.CreateDataReader()); var tabsTable = new DataTable(TabsTableName); FillTabsTable(tabsTable); dataProvider .Setup(s => s.GetTabs(It.IsAny <int>())) .Returns(() => tabsTable.CreateDataReader()); dataProvider .Setup(s => s.GetTabCustomAliases(It.IsAny <int>())) .Returns(() => tabsTable.CreateDataReader()); var tabUrlsTable = new DataTable(TabUrlsTableName); dataProvider .Setup(s => s.GetTabPaths( It.IsAny <int>(), It.IsAny <string>())) .Returns(() => tabUrlsTable.CreateDataReader()); dataProvider .Setup(s => s.GetTabUrls(It.IsAny <int>())) .Returns(() => tabUrlsTable.CreateDataReader()); var tabSettingsTable = new DataTable(TabSettingsTableName); dataProvider .Setup(s => s.GetTabSettings(It.IsAny <int>())) .Returns(() => tabSettingsTable.CreateDataReader()); var portalsTable = new DataTable(PortalsTableName); FillPortalsTable(portalsTable); dataProvider .Setup(s => s.GetPortals(It.IsAny <string>())) .Returns(() => portalsTable.CreateDataReader()); var extensionUrlProviderTable = new DataTable(ExtensionUrlProviderTableName); dataProvider .Setup(s => s.GetExtensionUrlProviders(It.IsAny <int>())) .Returns(() => extensionUrlProviderTable.CreateDataReader()); var portalAliasTable = new DataTable(PortalAliasTableName); FillPortalAliasTable(portalAliasTable); dataProvider .Setup(s => s.GetPortalAliases()) .Returns(() => portalAliasTable.CreateDataReader()); Globals.DependencyProvider = serviceCollection.BuildServiceProvider(); var urlRewriter = new AdvancedUrlRewriter(); var checkForRedirectsMethod = typeof(AdvancedUrlRewriter) .GetMethod( CheckForRedirectsMethodName, BindingFlags.Static | BindingFlags.NonPublic); var requestUri = new Uri(UriUrl); var queryStringCollection = new NameValueCollection(); var friendlyUrlSettings = new FriendlyUrlSettings(GenericPortalId); var urlAction = new UrlAction( HttpScheme, string.Empty, string.Empty) { TabId = GenericTabId, Action = ActionType.CheckFor301, PortalId = GenericPortalId, IsSSLOffloaded = true, PortalAlias = new PortalAliasInfo { HTTPAlias = GenericHost, }, DoRewrite = true, RewritePath = RewritePath }; urlAction.SetRedirectAllowed(string.Empty, friendlyUrlSettings); var requestType = string.Empty; var portalHomeTabId = GenericTabId; // Act var isRedirected = checkForRedirectsMethod.Invoke( urlRewriter, new object[] { requestUri, FullUrl, queryStringCollection, urlAction, requestType, friendlyUrlSettings, portalHomeTabId }); // Assert Assert.AreEqual(false, isRedirected); }
public void SetUp() { //Create a Container ComponentFactory.Container = new SimpleContainer(); MockComponentProvider.CreateDataCacheProvider(); }
public void TearDown() { MockComponentProvider.ResetContainer(); TestableGlobals.ClearInstance(); PortalController.ClearInstance(); }
public void TearDown() { Globals.DependencyProvider = null; MockComponentProvider.ResetContainer(); }
public void SetUp() { _mockCache = MockComponentProvider.CreateNew <CachingProvider>(); }
private void SetupDataProvider() { _dataProvider.Setup(d => d.GetProviderPath()).Returns(""); _dtRedirections = new DataTable("Redirections"); var pkCol = _dtRedirections.Columns.Add("Id", typeof(int)); _dtRedirections.Columns.Add("PortalId", typeof(int)); _dtRedirections.Columns.Add("Name", typeof(string)); _dtRedirections.Columns.Add("Type", typeof(int)); _dtRedirections.Columns.Add("SortOrder", typeof(int)); _dtRedirections.Columns.Add("SourceTabId", typeof(int)); _dtRedirections.Columns.Add("IncludeChildTabs", typeof(bool)); _dtRedirections.Columns.Add("TargetType", typeof(int)); _dtRedirections.Columns.Add("TargetValue", typeof(object)); _dtRedirections.Columns.Add("Enabled", typeof(bool)); _dtRedirections.PrimaryKey = new[] { pkCol }; _dtRules = new DataTable("Rules"); var pkCol1 = _dtRules.Columns.Add("Id", typeof(int)); _dtRules.Columns.Add("RedirectionId", typeof(int)); _dtRules.Columns.Add("Capability", typeof(string)); _dtRules.Columns.Add("Expression", typeof(string)); _dtRules.PrimaryKey = new[] { pkCol1 }; _dataProvider.Setup(d => d.SaveRedirection(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <object>(), It.IsAny <bool>(), It.IsAny <int>())).Returns <int, int, string, int, int, int, bool, int, object, bool, int>( (id, portalId, name, type, sortOrder, sourceTabId, includeChildTabs, targetType, targetValue, enabled, userId) => { if (id == -1) { if (_dtRedirections.Rows.Count == 0) { id = 1; } else { id = Convert.ToInt32(_dtRedirections.Select("", "Id Desc")[0]["Id"]) + 1; } var row = _dtRedirections.NewRow(); row["Id"] = id; row["PortalId"] = portalId; row["name"] = name; row["type"] = type; row["sortOrder"] = sortOrder; row["sourceTabId"] = sourceTabId; row["includeChildTabs"] = includeChildTabs; row["targetType"] = targetType; row["targetValue"] = targetValue; row["enabled"] = enabled; _dtRedirections.Rows.Add(row); } else { var rows = _dtRedirections.Select("Id = " + id); if (rows.Length == 1) { var row = rows[0]; row["name"] = name; row["type"] = type; row["sortOrder"] = sortOrder; row["sourceTabId"] = sourceTabId; row["includeChildTabs"] = includeChildTabs; row["targetType"] = targetType; row["targetValue"] = targetValue; row["enabled"] = enabled; } } return(id); }); _dataProvider.Setup(d => d.GetRedirections(It.IsAny <int>())).Returns <int>(GetRedirectionsCallBack); _dataProvider.Setup(d => d.DeleteRedirection(It.IsAny <int>())).Callback <int>((id) => { var rows = _dtRedirections.Select("Id = " + id); if (rows.Length == 1) { _dtRedirections.Rows.Remove(rows[0]); } }); _dataProvider.Setup(d => d.SaveRedirectionRule(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>())).Callback <int, int, string, string>((id, rid, capbility, expression) => { if (id == -1) { if (_dtRules.Rows.Count == 0) { id = 1; } else { id = Convert.ToInt32(_dtRules.Select("", "Id Desc")[0]["Id"]) + 1; } var row = _dtRules.NewRow(); row["Id"] = id; row["RedirectionId"] = rid; row["capability"] = capbility; row["expression"] = expression; _dtRules.Rows.Add(row); } else { var rows = _dtRules.Select("Id = " + id); if (rows.Length == 1) { var row = rows[0]; row["capability"] = capbility; row["expression"] = expression; } } }); _dataProvider.Setup(d => d.GetRedirectionRules(It.IsAny <int>())).Returns <int>(GetRedirectionRulesCallBack); _dataProvider.Setup(d => d.DeleteRedirectionRule(It.IsAny <int>())).Callback <int>((id) => { var rows = _dtRules.Select("Id = " + id); if (rows.Length == 1) { _dtRules.Rows.Remove(rows[0]); } }); _dataProvider.Setup(d => d.GetPortals(It.IsAny <string>())).Returns <string>(GetPortalsCallBack); _dataProvider.Setup(d => d.GetTabs(It.IsAny <int>())).Returns <int>(GetTabsCallBack); _dataProvider.Setup(d => d.GetTab(It.IsAny <int>())).Returns <int>(GetTabCallBack); _dataProvider.Setup(d => d.GetTabModules(It.IsAny <int>())).Returns <int>(GetTabModulesCallBack); _dataProvider.Setup(d => d.GetPortalSettings(It.IsAny <int>(), It.IsAny <string>())).Returns <int, string>(GetPortalSettingsCallBack); _dataProvider.Setup(d => d.GetAllRedirections()).Returns(GetAllRedirectionsCallBack); var portalDataService = MockComponentProvider.CreateNew <DotNetNuke.Entities.Portals.Data.IDataService>(); portalDataService.Setup(p => p.GetPortalGroups()).Returns(GetPortalGroupsCallBack); }
public void SetUp() { MockComponentProvider.CreateDataProvider().Setup(c => c.GetProviderPath()).Returns(string.Empty); }
public void TearDown() { UserSecurityController.ClearInstance(); MockComponentProvider.ResetContainer(); }
public void SetUp() { MockComponentProvider.CreateDataProvider(); }
public void TearDown() { MockComponentProvider.ResetContainer(); }
public void TearDown() { FileLockingController.ClearInstance(); MockComponentProvider.ResetContainer(); }