public void GalaxyNumeral_GetValue_Normal() { var numeral = new GalaxyNumeral(); numeral.AddDigit("X").AddDigit("X").AddDigit("X").AddDigit("I").AddDigit("V"); Assert.AreEqual(34, numeral.GetValue()); numeral = new GalaxyNumeral(); numeral.AddDigit("M").AddDigit("C").AddDigit("M").AddDigit("I").AddDigit("I").AddDigit("I"); Assert.AreEqual(1903, numeral.GetValue()); numeral = new GalaxyNumeral(); numeral.AddDigit("X").AddDigit("C").AddDigit("I").AddDigit("X"); Assert.AreEqual(99, numeral.GetValue()); numeral = new GalaxyNumeral(); numeral.AddDigit("X").AddDigit("X").AddDigit("X").AddDigit("V"); Assert.AreEqual(35, numeral.GetValue()); numeral = new GalaxyNumeral(); numeral.AddDigit("X").AddDigit("X").AddDigit("X").AddDigit("I").AddDigit("X"); Assert.AreEqual(39, numeral.GetValue()); numeral = new GalaxyNumeral(); numeral.AddDigit("C").AddDigit("X").AddDigit("X").AddDigit("X").AddDigit("V") .AddDigit("I").AddDigit("I").AddDigit("I"); Assert.AreEqual(138, numeral.GetValue()); }
protected override CommodityCondition ParseToCommodityCondition(string content, GroupCollection groups) { if (groups.Count == 3 && groups[1].Captures.Count > 0) { var commodityName = string.Empty; Numeral <GalaxyDigit> numeral = new GalaxyNumeral(); for (var i = 0; i < groups[1].Captures.Count; i++) { if (i < groups[1].Captures.Count - 1) { numeral.AddDigit(groups[1].Captures[i].Value.Trim()); } else { commodityName = groups[1].Captures[i].Value.Trim(); } } return(new CommodityCondition(content, commodityName, numeral.GetValue(), decimal.Parse(groups[2].Value))); } throw new MatchRegexException(); }