Adding a basic unit test for GetCropUrl - more to come

This commit is contained in:
Jeavon Leopold
2014-03-20 12:22:50 +00:00
parent 6077e24685
commit 9b02457f7a
2 changed files with 25 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
using System.Linq;
using NUnit.Framework;
using Newtonsoft.Json.Linq;
using Umbraco.Web.PropertyEditors;
using Umbraco.Web;
namespace Umbraco.Tests.PropertyEditors
{
[TestFixture]
public class ImageCropperTest
{
[Test]
public void GetCropUrl_Test()
{
var cropperJson =
"{\"src\": \"/media/1001/img_0671.jpg\",\"crops\": [{\"alias\": \"Thumb\",\"width\": 100,\"height\": 100,\"coordinates\": {\"x1\": 0.36664230810213955,\"y1\": 0.25767203967761981,\"x2\": 0.48805391012476662,\"y2\": 0.54858958462492169}}],\"focalPoint\": {\"left\": 0.8075,\"top\": 0.8666666666666667}}";
var urlString = "/media/1001/img_0671.jpg".GetCropUrl(imageCropperValue:cropperJson, cropAlias:"Thumb", width:100, height:100);
Assert.AreEqual(urlString, "/media/1001/img_0671.jpg?crop=0.36664230810213955,0.25767203967761981,0.48805391012476662,0.54858958462492169&cropmode=percentage&width=100&height=100");
}
}
}

View File

@@ -280,6 +280,7 @@
<Compile Include="Persistence\Repositories\UserTypeRepositoryTest.cs" />
<Compile Include="Models\Mapping\ContentWebModelMappingTests.cs" />
<Compile Include="Persistence\SyntaxProvider\MySqlSyntaxProviderTests.cs" />
<Compile Include="PropertyEditors\ImageCropperTest.cs" />
<Compile Include="PublishedContent\PublishedContentExtensionTests.cs" />
<Compile Include="PropertyEditors\ColorListValidatorTest.cs" />
<Compile Include="PropertyEditors\DropDownPropertyPreValueEditorTests.cs" />