コード例 #1
0
        public BODataField(Accountant acc, DataField _obj, BOContext state)
            : base(acc, state)
        {
            mObjectID = BOType.BODataField;

            mDataSource = _obj;
            mDataProxy  = _obj.Clone() as DataField;
        }
コード例 #2
0
        public virtual void DataFieldClone()
        {
            DataField original = new DataField("Test", 17345);

            object copy = original.Clone();

            Assert.NotNull(copy);
            Assert.True(copy is DataField);
            DataField field = (DataField)copy;

            Assert.True("Test".Equals(field.Name));
            Assert.True(field.Type == 8);
            object obj = field.ObjectValue;

            Assert.NotNull(obj);
            Assert.True(obj is int);
            Assert.True(((int)obj) == 17345);
        }
コード例 #3
0
        public void CloneTest()
        {
            string          tag       = "100";
            List <Subfield> subfields = new List <Subfield>();
            Subfield        subfield  = new Subfield('a', "It's a book!");

            subfields.Add(subfield);
            subfield = new Subfield('b', "Anne Author");
            subfields.Add(subfield);
            Field target = new DataField(tag, subfields);
            Field actual = target.Clone();

            Assert.AreNotEqual(target, actual);

            target.Tag = "200";

            string expectedString = tag;
            string actualString   = actual.Tag;

            Assert.AreEqual(expectedString, actualString);

            ((DataField)target).Indicator1 = '1';
            ((DataField)target).Indicator2 = '2';

            expectedString = "  ";
            actualString   = ((DataField)actual).Indicator1.ToString() + ((DataField)actual).Indicator2.ToString();
            Assert.AreEqual(expectedString, actualString);

            ((DataField)target)['a'].Code = 'c';
            ((DataField)target)['c'].Data = "It's a NEW book!";

            expectedString = "aIt's a book!";
            actualString   = ((DataField)actual)['a'].Code.ToString() + ((DataField)actual)['a'].Data;
            Assert.AreEqual(expectedString, actualString);

            //This next line will fail as there's no subfield c!
            ((DataField)actual)['c'].Code = 'a';
        }