public void GalaxyNumeral_AddDigit_SymbolText_Normal() { var numeral = new GalaxyNumeral(); numeral.AddDigit("I"); Assert.AreEqual(1, numeral.Length); }
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()); }
public void GalaxyNumeral_AddDigit_Value_Normal() { var numeral = new GalaxyNumeral(); numeral.AddDigit(1); Assert.AreEqual(1, numeral.Length); }
public void GalaxyNumeral_Length_NotZero() { var numeral = new GalaxyNumeral(); numeral.AddDigit("V"); Assert.AreEqual(1, numeral.Length); }
public void GalaxyNumeral_GetSymbolText_Normal() { var numeral = new GalaxyNumeral(); numeral.AddDigit("X").AddDigit("X").AddDigit("X").AddDigit("I").AddDigit("V"); Assert.AreEqual("X X X I V", numeral.GetSymbolText()); }
public void Transaction_GetAmount_Normal() { CommodityFactory.Instance.SetPrice("Gold", 100m); var number = new GalaxyNumeral(); number.AddDigit("I").AddDigit("V"); var transaction = new Transaction <GalaxyDigit>(CommodityFactory.Instance.GetCommodity("Gold"), number); Assert.AreEqual(400, transaction.GetAmount()); }
public void GalaxyNumeral_AddDigit_Value_Failed() { try { var numeral = new GalaxyNumeral(); numeral.AddDigit(8); } catch (Exception ex) { Assert.AreEqual("Can not get digit from value.", ex.Message); } }
public void GalaxyNumeral_AddDigit_SymbolText_Failed() { try { var numeral = new GalaxyNumeral(); numeral.AddDigit("Webber"); } catch (Exception ex) { Assert.AreEqual("Can not get digit from symbol text.", ex.Message); } }
protected override NumeralQuestion <GalaxyDigit> ParseToNumeralQuestion(string content, GroupCollection groups) { if (groups.Count == 2 && groups[1].Captures.Count > 0) { Numeral <GalaxyDigit> numeral = new GalaxyNumeral(); foreach (Capture capture in groups[1].Captures) { numeral.AddDigit(capture.Value.Trim()); } return(new NumeralQuestion <GalaxyDigit>(content, numeral)); } throw new MatchRegexException(); }
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(); }
protected override TransactionQuestion <GalaxyDigit> ParseToTransactionQuestion(string content, GroupCollection groups) { if (groups.Count == 2 && 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(); } } var transaction = new Transaction <GalaxyDigit>(CommodityFactory.Instance.GetCommodity(commodityName), numeral); return(new TransactionQuestion <GalaxyDigit>(content, transaction)); } throw new MatchRegexException(); }
public void GalaxyNumeral_GetValue_Failed() { try { var numeral = new GalaxyNumeral(); numeral.AddDigit("X").AddDigit("I").AddDigit("I").AddDigit("I").AddDigit("I"); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("should not be repeated more than 3 times.")); } try { var numeral = new GalaxyNumeral(); numeral.AddDigit("C").AddDigit("V").AddDigit("V").AddDigit("I").AddDigit("I"); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("should not be repeated.")); } try { var numeral = new GalaxyNumeral(); numeral.AddDigit("C").AddDigit("V").AddDigit("V").AddDigit("I").AddDigit("I"); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("should not be repeated.")); } try { var numeral = new GalaxyNumeral(); numeral.AddDigit("I").AddDigit("C"); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("should not be subtracted between more than one order of magnitude.")); } try { var numeral = new GalaxyNumeral(); numeral.AddDigit("V").AddDigit("X"); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("should not be subtracted.")); } try { var numeral = new GalaxyNumeral(); numeral.AddDigit("X").AddDigit("X").AddDigit("X").AddDigit("C").AddDigit("V") .AddDigit("I").AddDigit("I").AddDigit("I"); } catch (Exception ex) { Assert.IsTrue( ex.Message.Contains("should not greater than the previous digit if the previous digit was repeated.")); } }