private TypedEntity SetupTestStructure(
            out TypedEntity multiGrandChild,
            out TypedEntity firstChild,
            out TypedEntity firstGrandChild,
            out TypedEntity secondChild)
        {
            var domainRoot = CreateNewEntity();
            firstChild = CreateNewEntity();
            secondChild = CreateNewEntity();
            firstGrandChild = CreateNewEntity();
            multiGrandChild = CreateNewEntity();
            using (var writer = GetHive().Create<IContentStore>())
            {
                domainRoot.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "homepage";
                firstChild.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "first-child";
                firstGrandChild.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "first-grandchild";
                multiGrandChild.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "multi-grandchild";
                secondChild.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "second-child";
                writer.Repositories.AddOrUpdate(domainRoot);
                writer.Repositories.AddOrUpdate(firstChild);
                writer.Repositories.AddOrUpdate(firstGrandChild);
                writer.Repositories.AddOrUpdate(multiGrandChild);
                writer.Repositories.AddOrUpdate(secondChild);
                writer.Repositories.AddRelation(
                    FixedHiveIds.ContentVirtualRoot, domainRoot.Id, FixedRelationTypes.DefaultRelationType, 0);
                writer.Repositories.AddRelation(domainRoot, firstChild, FixedRelationTypes.DefaultRelationType, 0);
                writer.Repositories.AddRelation(firstChild, firstGrandChild, FixedRelationTypes.DefaultRelationType, 0);
                writer.Repositories.AddRelation(firstChild, multiGrandChild, FixedRelationTypes.DefaultRelationType, 0);
                writer.Repositories.AddRelation(secondChild, multiGrandChild, FixedRelationTypes.DefaultRelationType, 0);
                writer.Repositories.AddRelation(domainRoot, secondChild, FixedRelationTypes.DefaultRelationType, 0);

                var hostname = new Hostname { Name = "hello.com" };
                writer.Repositories.AddOrUpdate(hostname);
                writer.Repositories.AddRelation(domainRoot.Id, hostname.Id, FixedRelationTypes.HostnameRelationType, 0);

                writer.Complete();
            }
            return domainRoot;
        }
        public void RouteEngine_Get_Domain_Url_With_Hostname_On_Other_Authority()
        {
            //NOTE: We know that the mock http context we've setup is using hello.com as it's Url Authority

            //creates an entity without a domain
            var nonDomain = CreateNewEntity();

            //these will have a domain attached
            var main = CreateNewEntity();
            var sub = CreateNewEntity();

            using (var writer = GetHive().Create<IContentStore>())
            {
                main.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "hello";
                sub.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "world";

                //2 root nodes, one with and one without a domain
                writer.Repositories.AddOrUpdate(nonDomain);
                writer.Repositories.AddRelation(FixedHiveIds.ContentVirtualRoot, nonDomain.Id, FixedRelationTypes.DefaultRelationType, 0);
                writer.Repositories.AddOrUpdate(main);
                writer.Repositories.AddRelation(FixedHiveIds.ContentVirtualRoot, main.Id, FixedRelationTypes.DefaultRelationType, 0);

                writer.Repositories.AddOrUpdate(sub);
                writer.Repositories.AddRelation(main.Id, sub.Id, FixedRelationTypes.DefaultRelationType, 0);

                var hostname = new Hostname { Name = "adifferentauthority.com" };
                writer.Repositories.AddOrUpdate(hostname);
                writer.Repositories.AddRelation(main.Id, hostname.Id, FixedRelationTypes.HostnameRelationType, 0);

                writer.Complete();
            }

            //Act

            var url1 = GetEngine(new Uri("http://hello.com/")).GetUrlForEntity(main);
            var url2 = GetEngine(new Uri("http://hello.com/")).GetUrlForEntity(sub);

            //Assert

            Assert.AreEqual(UrlResolutionStatus.SuccessWithHostname, url1.Status);
            Assert.AreEqual("adifferentauthority.com", url1.Url);
            Assert.AreEqual(UrlResolutionStatus.SuccessWithHostname, url2.Status);
            Assert.AreEqual("adifferentauthority.com/world", url2.Url);
        }