public void TestLegendList() { NycLegendInfo info = NychanisHelper.GenerateLegendList(_indicatorDao.GetFirst("UID", 201), NycResolutionType.Borough); Assert.AreEqual("percent", info.ValueType, "Wrong type for values."); Assert.IsNotNull(info, "Legend info was null."); Assert.IsNotNull(info.Elements, "Elements list was null."); AssertLegendValueList(new float[] { 2.52f, 4.20f, 5.79f, 7.47f, 9.06f, 10.75f, 12.43f }, info); }
private static void AssertLegendValueList(float[] expected, NycLegendInfo info) { Console.WriteLine("Legend elements: " + StringHelper.Join(info.Elements)); Assert.AreEqual(expected.Length - 1, info.Elements.Count, "Wrong number of legend elements."); for (int x = 0; x < (expected.Length - 1); x++) { float expectedMinVal = expected[x]; float expectedMaxVal = expected[x + 1]; Assert.Greater(info.Elements[x].MinValue, expectedMinVal - 0.1, "Min val " + x + " was too low."); Assert.Less(info.Elements[x].MinValue, expectedMinVal + 0.1, "Min val " + x + " was too high."); Assert.Greater(info.Elements[x].MaxValue, expectedMaxVal - 0.1, "Max val " + x + " was too low."); Assert.Less(info.Elements[x].MaxValue, expectedMaxVal + 0.1, "Max val " + x + " was too high."); } }