public void HasCorrectNumberOfItems() { ApplicationDataPath path = new ApplicationDataPath(); path.Append("Foo", 42); path.Append("Bar", 16); Assert.AreEqual(2, path.Count); }
public void AppendsToEnd() { ApplicationDataPath path = new ApplicationDataPath(); path.Append("Foo", 42); path.Append("Bar", 16); Assert.AreEqual(16, path.Last().Index); }
public void TestRepeaterCalculation() { ExpressionEvaluator evaluator = new ExpressionEvaluator(new Application(this.postedData)); ApplicationDataPath path = new ApplicationDataPath(); path.Append("key4"); path.First().Index = 0; Assert.AreEqual(50, evaluator.Evaluate<int>("{%child1%} - {%child2%}", path)); path.First().Index = 1; Assert.AreEqual(150, evaluator.Evaluate<int>("{%child1%} - {%child2%}", path)); }
public void ReturnsFirstItem() { ApplicationDataPath path = new ApplicationDataPath(); path.Append("Foo", 42); path.Append("Bar", 16); ApplicationDataPathSegment segment = path.TraverseUp(); Assert.AreEqual(16, segment.Index); }
public void LeavesObjectInCorrectState() { ApplicationDataPath path = new ApplicationDataPath(); path.Append("Foo", 42); path.Append("Bar", 16); path.TraverseUp(); Assert.AreEqual(42, path.First().Index); }
public void LocalRepeaterValueUsingIndex() { Application application = new Application(); Dictionary<string, object>[] repeaterValue = new Dictionary<string, object>[2]; repeaterValue[0] = new Dictionary<string, object> { { "child1", "row 1 item 1" }, { "child2", "row 1 item 2" } }; repeaterValue[1] = new Dictionary<string, object> { { "child1", "row 2 item 1" }, { "child2", "row 2 item 2" } }; application.ApplicationData.Add("repeater1", repeaterValue); ApplicationDataPath path = new ApplicationDataPath(); path.Append("repeater1", 1); string replacedAppValue1 = this.formatterNullDefault.Format(@"{%child2%}", application, new ControlList(), string.Empty, string.Empty, string.Empty, path); Assert.AreEqual("row 2 item 2", replacedAppValue1); }
/// <summary> /// Converts a string in format <code>RepeaterName-Index-FieldName</code> to a string based /// repeater path in the format <code>RepeaterName[Index].FieldName</code> which is used to /// pre-populate application data. /// </summary> /// <param name="paramKey">The parameter key.</param> /// <param name="repeaterRegex">The repeater regex.</param> /// <returns>A string based repeater path in the format <code>RepeaterName[Index].FieldName</code></returns> private string DetermineRepeaterPath(string paramKey, Regex repeaterRegex) { Match match = repeaterRegex.Match(paramKey); ApplicationDataPath path = new ApplicationDataPath(); path.Append(match.Groups["RepeaterName"].Value, int.Parse(match.Groups["Index"].Value)); return path.ToString(match.Groups["FieldName"].Value); }