public void CanCreateASubListOfInterpolatablesWithAnExpression() { const string src = "Sum of #{NumA + NumB} is stored in C"; var nums = new Numbers { Num = new[] { "1", "2" }, NumA = 1, NumB = 2 }; var interpolatables = nums.InterpolatablesOf(src); Assert.IsNotNull(interpolatables); Assert.AreEqual(1, interpolatables.Count); var interpolatable = interpolatables.First(); var subList = interpolatable.InterpolatablesOfExpr(nums, src); Assert.IsNotNull(subList); Assert.AreEqual(2, subList.Count); }
public void CanCreateAListOfInterpolatablesWithAnExpression() { const string src = "Sum of #{NumA + NumB} is stored in C"; var nums = new Numbers { Num = new[] { "1", "2" }, NumA = 1, NumB = 2 }; var interpolatables = nums.InterpolatablesOf(src); Assert.IsNotNull(interpolatables); Assert.AreEqual(1, interpolatables.Count); var interpolatable = interpolatables.First(); Assert.AreEqual("NumA + NumB", interpolatable.Item); Assert.AreEqual(nums, interpolatable.Instance); Assert.AreEqual(InterpolatableType.Expression, interpolatable.Type); Assert.AreEqual("3", interpolatable.Value); }
public void CanCreateAListOfInterpolatablesWithAnArray() { const string src = "This is the first number #{Num[0]}"; var nums = new Numbers { Num = new string[] { "1", "2", "3" } }; var interpolatables = nums.InterpolatablesOf(src); Assert.IsNotNull(interpolatables); Assert.AreEqual(1, interpolatables.Count); var interpolatable = interpolatables.First(); Assert.AreEqual("Num[0]", interpolatable.Item); Assert.AreEqual(nums, interpolatable.Instance); Assert.AreEqual(InterpolatableType.Array, interpolatable.Type); Assert.AreEqual("1", interpolatable.Value); }
public void ThrowsAnExceptionForUnsupportedInterpolatableTypes() { const string src = "This is the first number #{Num[0]}"; var nums = new Numbers { Num = new string[] { "1", "2", "3" } }; var interpolatables = nums.InterpolatablesOf(src); Assert.IsNotNull(interpolatables); Assert.AreEqual(1, interpolatables.Count); var interpolatable = interpolatables.First(); var subList = interpolatable.InterpolatablesOfExpr(nums, src); }