private void _TestSerialization
        (
            params SubField[] subFields
        )
        {
            SubFieldCollection collection1 = new SubFieldCollection();

            collection1.AddRange(subFields);

            //collection1.SaveToFile("collection1.bin");
            //collection1.SaveToZipFile("collection1.biz");

            byte[] bytes = collection1.SaveToMemory();

            SubFieldCollection collection2 = bytes
                                             .RestoreObjectFromMemory <SubFieldCollection>();

            Assert.AreEqual(collection1.Count, collection2.Count);

            for (int i = 0; i < collection1.Count; i++)
            {
                Assert.AreEqual
                (
                    0,
                    SubField.Compare
                    (
                        collection1[i],
                        collection2[i]
                    )
                );
            }
        }
예제 #2
0
        public void SubField_Constructor_1()
        {
            SubField subField = new SubField();

            Assert.AreEqual(SubField.NoCode, subField.Code);
            Assert.AreEqual(SubField.NoCodeString, subField.CodeString);
            Assert.AreEqual(null, subField.Value);
            Assert.AreEqual("^\0", subField.ToString());

            subField = new SubField('A', "The value");
            Assert.AreEqual('A', subField.Code);
            Assert.AreEqual("A", subField.CodeString);
            Assert.AreEqual("The value", subField.Value);
            Assert.AreEqual("^aThe value", subField.ToString());

            SubField clone = subField.Clone();

            Assert.AreEqual(subField.Code, clone.Code);
            Assert.AreEqual(subField.CodeString, clone.CodeString);
            Assert.AreEqual(subField.Value, clone.Value);
            Assert.AreEqual("^aThe value", clone.ToString());
            Assert.AreEqual(0, SubField.Compare(subField, clone));

            subField.SetValue("New value");
            Assert.AreEqual("New value", subField.Value);
            subField.SetValue(null);
            Assert.AreEqual(null, subField.Value);
        }
예제 #3
0
        private void _TestSerialization
        (
            params SubField[] subFields
        )
        {
            SubField[] array1 = subFields;
            byte[]     bytes  = array1.SaveToMemory();

            SubField[] array2 = bytes
                                .RestoreArrayFromMemory <SubField>();

            Assert.AreEqual(array1.Length, array2.Length);
            for (int i = 0; i < array1.Length; i++)
            {
                Assert.AreEqual
                (
                    0,
                    SubField.Compare(array1[i], array2[i])
                );
            }
        }
        public void SubFieldCollection_AssignClone1()
        {
            SubFieldCollection source = _GetCollection();
            SubFieldCollection target = new SubFieldCollection();

            target.AssignClone(source);

            Assert.AreEqual(source.Field, target.Field);
            Assert.AreEqual(source.Count, target.Count);
            for (int i = 0; i < source.Count; i++)
            {
                Assert.AreEqual
                (
                    0,
                    SubField.Compare
                    (
                        source[i],
                        target[i]
                    )
                );
            }
        }
예제 #5
0
        public void SubField_Compare_1()
        {
            SubField subField1 = new SubField('a');
            SubField subField2 = new SubField('b');

            Assert.IsTrue
            (
                SubField.Compare(subField1, subField2) < 0
            );

            subField1 = new SubField('a', "Title1");
            subField2 = new SubField('a', "Title2");
            Assert.IsTrue
            (
                SubField.Compare(subField1, subField2) < 0
            );

            subField1 = new SubField('a', "Title");
            subField2 = new SubField('a', "Title");
            Assert.IsTrue
            (
                SubField.Compare(subField1, subField2) == 0
            );
        }