private void InitializeOutChart() { OutCalculator outCalculator = new OutCalculator(InOutRule.Double); List <string> allOutsList = new List <string>(); Dictionary <int, List <Dart> > allOuts = outCalculator.GetAllOuts(); // iterate through the dictionary to get all the outs foreach (KeyValuePair <int, List <Dart> > entry in allOuts) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(entry.Key.ToString()); stringBuilder.Append(": "); for (int j = 0; j < entry.Value.Count; j++) { stringBuilder.Append(entry.Value[j].Abbreviation); if (j != entry.Value.Count - 1) { stringBuilder.Append(", "); } } string outItemText = stringBuilder.ToString(); allOutsList.Add(outItemText); } Android.Widget.ListView lstMyList = (Android.Widget.ListView)FindViewById <Android.Widget.ListView>(Resource.Id.MyList); lstMyList.Adapter = new OutChartAdapter(this, allOutsList); }
public void GetAllOuts_WithDoubleOutRule_GetsTheExpectedOuts() { // Arrange OutCalculator calculator = new OutCalculator(InOutRule.Double); // Act var subject = calculator.GetAllOuts(); // Assert Assert.AreEqual("DoubleOutSplitBullOuts", subject.GetType().Name, "Not expected class"); }
public void GetAllOuts_WithDoubleOutRule_MathOfExpectedOutsWorks() { // Arrange OutCalculator calculator = new OutCalculator(InOutRule.Double); // Act var subject = calculator.GetAllOuts(); // Assert foreach (var keyValue in subject) { int total = 0; foreach (Dart dart in keyValue.Value) { total += dart.Value; } Assert.AreEqual(keyValue.Key, total, string.Format("Total did not match for {0}", keyValue.Key)); Assert.AreEqual(SegmentMultiplier.Double, keyValue.Value.LastOrDefault().Multiplier, "Last dart multiplier was not Double"); } }