diff --git a/src/YmlTransform/Exceptions/IncompleteTransformationException.cs b/src/YmlTransform/Exceptions/IncompleteTransformationException.cs
new file mode 100644
index 0000000..d72fe74
--- /dev/null
+++ b/src/YmlTransform/Exceptions/IncompleteTransformationException.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace YmlTransform.Exceptions
+{
+ public class IncompleteTransformationException : Exception
+ {
+ public IncompleteTransformationException()
+ { }
+
+ public IncompleteTransformationException(string message) : base(message)
+ { }
+ }
+}
diff --git a/src/YmlTransform/Models/TransformItem.cs b/src/YmlTransform/Models/TransformItem.cs
index 29aae94..499a7bb 100644
--- a/src/YmlTransform/Models/TransformItem.cs
+++ b/src/YmlTransform/Models/TransformItem.cs
@@ -4,11 +4,26 @@ namespace YmlTransform.Models
{
class TransformItem
{
+ private string _value;
+ private bool _used;
+
public string Path { get; set; }
public string Type { get; set; }
public string Languages { get; set; }
public Guid FieldId { get; set; }
- public string Value { get; set; }
+
+ public string Value
+ {
+ get
+ {
+ _used = true;
+ return _value;
+ }
+ set { _value = value; }
+ }
+
public string Hint { get; set; }
+
+ public bool Used => _used;
}
}
\ No newline at end of file
diff --git a/src/YmlTransform/YmlTransform.csproj b/src/YmlTransform/YmlTransform.csproj
index 61e0a36..c287969 100644
--- a/src/YmlTransform/YmlTransform.csproj
+++ b/src/YmlTransform/YmlTransform.csproj
@@ -83,6 +83,7 @@
+
diff --git a/src/YmlTransform/YmlTransformer.cs b/src/YmlTransform/YmlTransformer.cs
index 9864aee..7eaba5b 100644
--- a/src/YmlTransform/YmlTransformer.cs
+++ b/src/YmlTransform/YmlTransformer.cs
@@ -5,6 +5,7 @@
using Rainbow.Model;
using Rainbow.Storage.Yaml;
using Rainbow.Storage.Yaml.OutputModel;
+using YmlTransform.Exceptions;
using YmlTransform.Models;
namespace YmlTransform
@@ -93,6 +94,10 @@ private static void TransformSingle(List transformations, string
}
}
+ if (!transformations.All(x => x.Used))
+ {
+ throw new IncompleteTransformationException();
+ }
if (transformed)
{
diff --git a/tests/YmlTransform.Tests/Data/MissingTransformation.yml b/tests/YmlTransform.Tests/Data/MissingTransformation.yml
new file mode 100644
index 0000000..b48f519
--- /dev/null
+++ b/tests/YmlTransform.Tests/Data/MissingTransformation.yml
@@ -0,0 +1,25 @@
+---
+ID: "ab5b233c-111c-4fa8-affe-b0c7315fedf4"
+Parent: "756fff26-90f2-4889-bace-da656e66b9c1"
+Template: "013bc834-c0f6-4377-924e-0de185abfbe7"
+Path: /sitecore/content/Home/Unversioned
+DB: master
+SharedFields:
+- ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
+ Hint: __Sortorder
+ Value: 375
+Languages:
+- Language: en
+ Fields:
+ - ID: "11c0c7c6-673f-432a-b2fa-acfead30b6dd"
+ Hint: Field1
+ Value: "Value1"
+ - ID: "814e27bf-7ae2-433c-affa-aafc0797e0a8"
+ Hint: Field2
+ Value: "Value2"
+Versions:
+ - Version: 1
+ Fields:
+ - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
+ Hint: __Created
+ Value: 20171016T073039Z
\ No newline at end of file
diff --git a/tests/YmlTransform.Tests/Data/MissingTransformation.ymltransform b/tests/YmlTransform.Tests/Data/MissingTransformation.ymltransform
new file mode 100644
index 0000000..020d020
--- /dev/null
+++ b/tests/YmlTransform.Tests/Data/MissingTransformation.ymltransform
@@ -0,0 +1,18 @@
+[
+ {
+ "FieldId": "11c0c7c6-673f-432a-b2fa-acfead30b6dd",
+ "Hint": "Field1",
+ "Languages": "*",
+ "Path": "/sitecore/content/Home/Unversioned",
+ "Type": "Unversioned",
+ "Value": "Value1New"
+ },
+ {
+ "FieldId": "714e27bf-7ae2-433c-affa-aafc0797e0a8",
+ "Hint": "Field3",
+ "Languages": "*",
+ "Path": "/sitecore/content/Home/Unversioned",
+ "Type": "Unversioned",
+ "Value": "Value2New"
+ }
+]
\ No newline at end of file
diff --git a/tests/YmlTransform.Tests/YmlTransform.Tests.csproj b/tests/YmlTransform.Tests/YmlTransform.Tests.csproj
index 8ea5b54..57f3ea0 100644
--- a/tests/YmlTransform.Tests/YmlTransform.Tests.csproj
+++ b/tests/YmlTransform.Tests/YmlTransform.Tests.csproj
@@ -39,6 +39,9 @@
+
+ ..\..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll
+
..\..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll
@@ -80,6 +83,12 @@
+
+ Always
+
+
+ Always
+
Always
diff --git a/tests/YmlTransform.Tests/YmlTransformerTests.cs b/tests/YmlTransform.Tests/YmlTransformerTests.cs
index 0089872..2d19740 100644
--- a/tests/YmlTransform.Tests/YmlTransformerTests.cs
+++ b/tests/YmlTransform.Tests/YmlTransformerTests.cs
@@ -4,6 +4,7 @@
using System.Text;
using System.Threading;
using Xunit;
+using YmlTransform.Exceptions;
namespace YmlTransform.Tests
{
@@ -38,5 +39,13 @@ public void TestUnversionedTransformation()
Assert.Equal(expectedHash, originalHash);
}
+
+ [Fact]
+ public void TestExceptionThrownOnIncompleteTransform()
+ {
+ const string originalFile = @"Data\\MissingTransformation.yml";
+
+ Assert.Throws(() => YmlTransformer.TransformFile(originalFile, "Data\\MissingTransformation.ymltransform"));
+ }
}
}
diff --git a/tests/YmlTransform.Tests/packages.config b/tests/YmlTransform.Tests/packages.config
index 11abced..c33d62c 100644
--- a/tests/YmlTransform.Tests/packages.config
+++ b/tests/YmlTransform.Tests/packages.config
@@ -1,5 +1,6 @@
+