public void MapDomainWithScheme() { SiteDomainHelper.AddSite("site1", "domain1.com", "domain1.net", "domain1.org"); SiteDomainHelper.AddSite("site2", "domain2.com", "domain2.net", "domain2.org"); SiteDomainHelper.AddSite("site3", "domain3.com", "domain3.net", "domain3.org"); SiteDomainHelper.AddSite("site4", "https://domain4.com", "https://domain4.net", "https://domain4.org"); // map methods are not static because we can override them var helper = new SiteDomainHelper(); // this works, but it's purely by chance / arbitrary // don't use the www in tests here! var current = new Uri("https://www.domain1.com/foo/bar"); var domainAndUris = DomainAndUris(current, new [] { new UmbracoDomain("domain2.com"), new UmbracoDomain("domain1.com"), }); var output = helper.MapDomain(current, domainAndUris).Uri.ToString(); Assert.AreEqual("https://domain1.com/", output); // will pick it all right current = new Uri("https://domain1.com/foo/bar"); domainAndUris = DomainAndUris(current, new[] { new UmbracoDomain("https://domain1.com"), new UmbracoDomain("https://domain2.com") }); output = helper.MapDomain(current, domainAndUris).Uri.ToString(); Assert.AreEqual("https://domain1.com/", output); current = new Uri("https://domain1.com/foo/bar"); domainAndUris = DomainAndUris(current, new[] { new UmbracoDomain("https://domain1.com"), new UmbracoDomain("https://domain4.com") }); output = helper.MapDomain(current, domainAndUris).Uri.ToString(); Assert.AreEqual("https://domain1.com/", output); current = new Uri("https://domain4.com/foo/bar"); domainAndUris = DomainAndUris(current, new[] { new UmbracoDomain("https://domain1.com"), new UmbracoDomain("https://domain4.com") }); output = helper.MapDomain(current, domainAndUris).Uri.ToString(); Assert.AreEqual("https://domain4.com/", output); }
public void MapDomain() { SiteDomainHelper.AddSite("site1", "domain1.com", "domain1.net", "domain1.org"); SiteDomainHelper.AddSite("site2", "domain2.com", "domain2.net", "domain2.org"); SiteDomainHelper.AddSite("site3", "domain3.com", "domain3.net", "domain3.org"); SiteDomainHelper.AddSite("site4", "domain4.com", "domain4.net", "domain4.org"); //SiteDomainHelper.BindSites("site1", "site3"); //SiteDomainHelper.BindSites("site2", "site4"); // map methods are not static because we can override them var helper = new SiteDomainHelper(); // current is a site1 uri, domains contain current // so we'll get current // var current = new Uri("http://domain1.com/foo/bar"); var output = helper.MapDomain(current, new[] { new DomainAndUri(new UmbracoDomain("domain1.com"), Uri.UriSchemeHttp), new DomainAndUri(new UmbracoDomain("domain2.com"), Uri.UriSchemeHttp), }).Uri.ToString(); Assert.AreEqual("http://domain1.com/", output); // current is a site1 uri, domains do not contain current // so we'll get the corresponding site1 domain // current = new Uri("http://domain1.com/foo/bar"); output = helper.MapDomain(current, new[] { new DomainAndUri(new UmbracoDomain("domain1.net"), Uri.UriSchemeHttp), new DomainAndUri(new UmbracoDomain("domain2.net"), Uri.UriSchemeHttp) }).Uri.ToString(); Assert.AreEqual("http://domain1.net/", output); // current is a site1 uri, domains do not contain current // so we'll get the corresponding site1 domain // order does not matter // current = new Uri("http://domain1.com/foo/bar"); output = helper.MapDomain(current, new[] { new DomainAndUri(new UmbracoDomain("domain2.net"), Uri.UriSchemeHttp), new DomainAndUri(new UmbracoDomain("domain1.net"), Uri.UriSchemeHttp) }).Uri.ToString(); Assert.AreEqual("http://domain1.net/", output); }