public void SetUp()
    {
      SessionConfigPOD mockConfig = new SessionConfigPOD();
      mockConfig.InstanceUrl = "localhost";
      mockConfig.ItemWebApiVersion = "v1";
      mockConfig.Site = null;

      var itemSource = new ItemSourcePOD("master", "fr");

      var mediaSettings = new MutableMediaLibrarySettings();

      this.builder = new MediaItemUrlBuilder(
        RestServiceGrammar.ItemWebApiV2Grammar(),
        WebApiUrlParameters.ItemWebApiV2UrlParameters(),
        mockConfig,
        mediaSettings,
        itemSource);


      SessionConfigPOD mockConfigWithShell = new SessionConfigPOD();
      mockConfigWithShell.InstanceUrl = "localhost";
      mockConfigWithShell.ItemWebApiVersion = "v1";
      mockConfigWithShell.Site = "/sitecore/shell";
      this.builderWithShellSite = new MediaItemUrlBuilder(
        RestServiceGrammar.ItemWebApiV2Grammar(),
        WebApiUrlParameters.ItemWebApiV2UrlParameters(),
        mockConfigWithShell,
        mediaSettings,
        itemSource);
    }
    public void TestItemSourceMergerCopiesInputStruct()
    {
      IItemSource source = new ItemSourcePOD("master", "da", 100500 );
      var merger = new ItemSourceFieldMerger(source);

      Assert.AreNotSame(source, merger.DefaultSource);
      Assert.AreEqual(source, merger.DefaultSource);
    }
    public void TestUserFieldsHaveHigherPriority()
    {
      var defaultSource = new ItemSourcePOD ("master", "en", 1);
      var userSource = new ItemSourcePOD ("web", "ua", 42);

      var merger = new ItemSourceFieldMerger (defaultSource);
      IItemSource result = merger.FillItemSourceGaps (userSource);

      Assert.AreEqual (userSource, result);
      Assert.AreNotSame (userSource, result);
    }
    public void TestDatabaseAndLanguageAreOptionalForDefaultSource()
    {
      IItemSource noDatabase = new ItemSourcePOD(null    , "en", 1 );
      IItemSource noLanguage = new ItemSourcePOD("master", null, 1 );
      IItemSource noVersion  = new ItemSourcePOD("master", "en", null);


      Assert.DoesNotThrow( () => new ItemSourceFieldMerger(noDatabase) );
      Assert.DoesNotThrow( () => new ItemSourceFieldMerger(noLanguage) );
      Assert.DoesNotThrow( () => new ItemSourceFieldMerger(noVersion ) );
    }
Exemple #5
0
        public override bool Equals(object obj)
        {
            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            ItemSourcePOD other = (ItemSourcePOD)obj;

            if (null == other)
            {
                return(false);
            }

            bool isDbEqual      = object.Equals(this.Database, other.Database);
            bool isLangEqual    = object.Equals(this.Language, other.Language);
            bool isVersionEqual = object.Equals(this.VersionNumber, other.VersionNumber);

            return(isDbEqual && isLangEqual && isVersionEqual);
        }
    public void TestNullUserFieldsAreAutocompleted()
    {
      var defaultSource = new ItemSourcePOD ("master", "en", 1);
      var userSource = new ItemSourcePOD (null, null, null);

      var merger = new ItemSourceFieldMerger (defaultSource);
      IItemSource result = merger.FillItemSourceGaps (userSource);

      Assert.AreEqual (defaultSource, result);
      Assert.AreNotSame (defaultSource, result);
    }