public void Translator_AffectNext_Import_Test()
        {
            // SETUP the SUT
            List<string> val = new List<string> { "First Value,    1  ,N", "Second Value, 16","Third Item, 1" };
            StreamReader testBed = TestHelper.prepareTestDouble(val);
            NormalItemFactory normalItemFactory = new NormalItemFactory(testBed);
            ItemParser itemParser = new ItemParser();
            itemParser.setFactory(normalItemFactory);

            List<Item> expected = new List<Item>();
            var affectorItem = new ItemValueAffectedNextItemLength() { Name = "First Value", Length = 1, Value = "01" };
            var affectedItem = new RegularItem() { Name = "Second Value", Length = 2, Value = "0403" };
            affectorItem.setAffectedItem(affectedItem);
            expected.Add(affectorItem);
            expected.Add(affectedItem);
            expected.Add(new RegularItem() { Name = "Third Item", Length = 1, Value = "02" });

            // Exercise
            StringTranslator ST = new StringTranslator();
            itemParser.setTranslator(ST);
            ST.setValue("02040302");
            ST.Import();

            // Verify
            TestHelper.Compare(expected, itemParser.Items);
        }
        public void Test_AffectNextItem_Normal()
        {
            RegularItem Reg = new RegularItem();
            Reg.Name = "test";
            Reg.Value = "002222";
            Reg.Length = 3;
            ItemValueAffectedNextItemLength affectNext = new ItemValueAffectedNextItemLength();
            affectNext.setAffectedItem(Reg);
            affectNext.Name = "Length";

            Assert.AreEqual("03", affectNext.Value );
        }
        public void Test_NormalItemFactory_AffectedNext()
        {
            List<string> val = new List<string> { "two bytes parameter,1 , N", "three bytes parameter ,    3" };

            StreamReader testBed = TestHelper.prepareTestDouble(val);
            NormalItemFactory normalItemFactory = new NormalItemFactory(testBed);
            List<Item> res = normalItemFactory.GetItems();

            List<Item> expected = new List<Item>();
            RegularItem ri = new RegularItem();
            ri.Name = "three bytes parameter";
            ri.Length = 3;
            ItemValueAffectedNextItemLength prev = new ItemValueAffectedNextItemLength();
            prev.setAffectedItem(ri);
            prev.Name = "two bytes parameter";
            prev.Length = 1;
            expected.Add(prev);
            expected.Add(ri);

            // do the checking
            TestHelper.Compare(expected, res);
        }
        public void Translator_AffectNext_Export_Test()
        {
            List<string> val = new List<string> { "First Value,    1  ,N,02", "Second Value, 2,R,0403", "Third Item, 1,R, 02" };

            StreamReader testBed = TestHelper.prepareTestDouble(val);
            NormalItemFactory normalItemFactory = new NormalItemFactory(testBed);
            ItemParser itemParser = new ItemParser();
            itemParser.setFactory(normalItemFactory);

            List<Item> expected = new List<Item>();
            var affectorItem = new ItemValueAffectedNextItemLength() { Name = "First Value", Length = 1, Value = "02" };
            var affectedItem = new RegularItem() { Name = "Second Value", Length = 2, Value = "0403" };
            affectorItem.setAffectedItem(affectedItem);
            expected.Add(affectorItem);
            expected.Add(affectedItem);
            expected.Add(new RegularItem() { Name = "Third Item", Length = 1, Value = "02" });

            StringTranslator ST = new StringTranslator();
            itemParser.setTranslator(ST);
            ST.Export();
            Assert.AreEqual("02040302", ST.getValue());
            Assert.AreEqual(string.Empty, ST.getValue());
        }