public void UnitExpressionTest()
        {
            AliasMapper    aliasMap       = new AliasMapper();
            RomanConverter converter      = new RomanConverter();
            CommodityIndex commodityIndex = new CommodityIndex();

            aliasMap.AddAlias("glob", "C");
            aliasMap.AddAlias("pish", "X");
            ExpressionValidationHelper helper     = new ExpressionValidationHelper(aliasMap, commodityIndex);
            UnitExpression             expression = new UnitExpression(commodityIndex, aliasMap, converter, helper);

            expression.Execute("pish glob Iron is 7020 Credits");
            Assert.IsTrue(commodityIndex.Exists("Iron"));
            Assert.AreEqual <double>(commodityIndex.GetPriceByCommodity("Iron"), 78);
            expression.Execute("pish glob Iron is 6300 Credits");
            Assert.AreEqual <double>(commodityIndex.GetPriceByCommodity("Iron"), 70);
        }
        public void Execute(string input)
        {
            string[] parts = input.Split(new string[] { " is " }, StringSplitOptions.RemoveEmptyEntries);

            string roman = parts[1];

            aliasMap.AddAlias(parts[0], parts[1]);
        }
        public void Execute(string input)
        {
            string[] parts = Regex.Split(input, Constant.ExpressionSplitter, RegexOptions.IgnoreCase);

            string roman = parts[1];

            _aliasMap.AddAlias(parts[0], parts[1]);
        }
Beispiel #4
0
        public void UnitExpressionTest()
        {
            AliasMapper    aliasMap  = new AliasMapper();
            RomanConverter converter = new RomanConverter();
            MetalMapper    metalMap  = new MetalMapper();

            aliasMap.AddAlias("glob", "I");
            aliasMap.AddAlias("pish", "X");
            ExpressionValidationHelper helper     = new ExpressionValidationHelper(aliasMap, metalMap);
            UnitExpression             expression = new UnitExpression(aliasMap, metalMap, converter, helper);

            expression.Execute("pish glob Iron is 110 Credits");
            Assert.True(metalMap.Exists("Iron"));
            Assert.Equal <double>(10, metalMap.GetPriceByMetal("Iron"));
            expression.Execute("glob pish Iron is 6300 Credits");
            Assert.Equal <double>(700, metalMap.GetPriceByMetal("Iron"));
        }
        public void UnitExpressionTest()
        {
            AliasMapper    aliasMap       = new AliasMapper();
            RomanConverter converter      = new RomanConverter();
            CommodityIndex commodityIndex = new CommodityIndex();

            aliasMap.AddAlias("glob", "I");
            aliasMap.AddAlias("prok", "V");
            aliasMap.AddAlias("pish", "X");
            aliasMap.AddAlias("tegj", "L");

            ExpressionValidationHelper helper     = new ExpressionValidationHelper(aliasMap, commodityIndex);
            UnitExpression             expression = new UnitExpression(commodityIndex, aliasMap, converter, helper);

            expression.Execute("glob glob silver is 34 Credits");
            Assert.True(commodityIndex.Exists("silver"));
            Assert.Equal <double>(17, commodityIndex.GetPriceByCommodity("silver"));
            expression.Execute("glob prok iron is 400 Credits");
            Assert.Equal <double>(100, commodityIndex.GetPriceByCommodity("iron"));
        }