コード例 #1
0
    public void TestBoolHasProperValue()
    {
      DownloadMediaOptions options = new DownloadMediaOptions();
      options.SetDisplayAsThumbnail(true);
      options.SetDisableMediaCache(true);
      options.SetDisableMediaCache(false);

      Assert.AreEqual("1", options.DisplayAsThumbnail);
      Assert.AreEqual("0", options.DisableMediaCache);
    }
コード例 #2
0
    public void TestCopyWithOptions()
    {
      DownloadMediaOptions options = new DownloadMediaOptions();
      options.SetWidth(100);
      options.SetScale(1.5f);

      DownloadMediaOptions copy = (DownloadMediaOptions)options.DeepCopyMediaDownloadOptions();
      Assert.AreEqual("100", copy.Width);
      Assert.AreEqual("1.5", copy.Scale);
    }
    public void TestHashedUrlBuilderAddsShellSiteIfSpecified()
    {
      var options = new DownloadMediaOptions();
      options.SetDisplayAsThumbnail(true);

      const string imagePath = "/images/green_mineraly1";
      string original = this.builderWithShellSite.BuildUrlStringForPath(imagePath, options);
      Assert.AreEqual("http://localhost/~/media/images/green_mineraly1.ashx?thn=1&db=master&la=fr", original);

      string result = this.builderWithShellSite.BuildUrlToRequestHashForPath(imagePath, options);
      string expected = "http://localhost/-/item/v1%2fsitecore%2fshell/-/actions/getsignedmediaurl?url=http%3a%2f%2flocalhost%2f~%2fmedia%2fimages%2fgreen_mineraly1.ashx%3fthn%3d1%26db%3dmaster%26la%3dfr";
      Assert.AreEqual(expected, result);
    }
コード例 #4
0
        public virtual IDownloadMediaOptions DeepCopyMutableMediaDownloadOptions()
        {
            DownloadMediaOptions result = new DownloadMediaOptions();

            result.width              = this.width;
            result.height             = this.height;
            result.maxWidth           = this.maxWidth;
            result.maxHeight          = this.maxHeight;
            result.backgroundColor    = this.backgroundColor;
            result.disableMediaCache  = this.disableMediaCache;
            result.allowStrech        = this.allowStrech;
            result.scale              = this.scale;
            result.displayAsThumbnail = this.displayAsThumbnail;

            return(result);
        }
コード例 #5
0
    public virtual IDownloadMediaOptions DeepCopyMutableMediaDownloadOptions()
    {
      DownloadMediaOptions result = new DownloadMediaOptions();

      result.width = this.width;
      result.height = this.height;
      result.maxWidth = this.maxWidth;
      result.maxHeight = this.maxHeight;
      result.backgroundColor = this.backgroundColor;
      result.disableMediaCache = this.disableMediaCache;
      result.allowStrech = this.allowStrech;
      result.scale = this.scale;
      result.displayAsThumbnail = this.displayAsThumbnail;

      return result;
    }
コード例 #6
0
    public void DownloadOptionsWithInvalidScaleTest()
    {
      var options = new DownloadMediaOptions();

      TestDelegate action = () => options.SetScale(-0.00f);
      var exception = Assert.Throws<ArgumentException>(action);
      Assert.True(exception.Message.Contains("scale must be > 0"));
    }
コード例 #7
0
    public void DownloadOptionsWithZeroMaxWidthTest()
    {
      var options = new DownloadMediaOptions();

      TestDelegate action = () => options.SetMaxWidth(0);
      var exception = Assert.Throws<ArgumentException>(action);
      Assert.True(exception.Message.Contains("maxWidth must be > 0"));
    }
コード例 #8
0
    public void DownloadOptionsWithNegativeHeightTest()
    {
      var options = new DownloadMediaOptions();

      TestDelegate action = () => options.SetHeight(-4);
      var exception = Assert.Throws<ArgumentException>(action);
      Assert.True(exception.Message.Contains("height must be > 0"));
    }
コード例 #9
0
    public void CorrectDownloadOptionsWithScaleAndMaxWidthTest()
    {
      var options = new DownloadMediaOptions();
      options.SetScale(3.0005f);
      options.SetMaxWidth(10);


      string result = this.builder.BuildUrlStringForPath("~/media/1", options);
      const string Expected = "http://test.host/~/media/1.ashx?mw=10&sc=3.0005&db=web&la=en";

      Assert.AreEqual(Expected, result);
    }
コード例 #10
0
    public void CorrectDownloadOptionsWithAllParamsTest()
    {
      var options = new DownloadMediaOptions();
      options.SetWidth(10);
      options.SetHeight(10);
      options.SetBackgroundColor("3F0000");
      options.SetAllowStrech(false);
      options.SetDisableMediaCache(false);
      options.SetDisplayAsThumbnail(true);
      options.SetMaxHeight(10);
      options.SetMaxWidth(10);
      options.SetScale(2.5f);

      string result = this.builder.BuildUrlStringForPath("~/media/1.png", options);
      const string expected = "http://test.host/~/media/1.png?w=10&h=10&mw=10&mh=10&bc=3f0000&dmc=0&as=0&sc=2.5&thn=1&db=web&la=en";

      Assert.AreEqual(expected, result);
    }
コード例 #11
0
    public void CorrectDownloadOptionsWithNullValuesTest()
    {
      var options = new DownloadMediaOptions();
      options.SetWidth(100);
      options.SetBackgroundColor("white");
      options.SetBackgroundColor(null);

      options.SetDisplayAsThumbnail(true);
      options.SetDisplayAsThumbnail(false);

      string result = this.builder.BuildUrlStringForPath("~/media/1", options);
      const string expected = "http://test.host/~/media/1.ashx?w=100&thn=0&db=web&la=en";

      Assert.AreEqual(expected, result);
    }
コード例 #12
0
    public void EmptyDownloadOptionsTest()
    {
      var options = new DownloadMediaOptions();

      string result = this.builder.BuildUrlStringForPath("~/media/1", options);
      const string Expected = "http://test.host/~/media/1.ashx?db=web&la=en";

      Assert.AreEqual(Expected, result);
    }
コード例 #13
0
 public void TestCopyEmptyOptions()
 {
   DownloadMediaOptions options = new DownloadMediaOptions();
   DownloadMediaOptions copy = (DownloadMediaOptions)options.DeepCopyMediaDownloadOptions();
   Assert.True (copy.IsEmpty);
 }