コード例 #1
0
ファイル: CremaComparer.cs プロジェクト: s2quake/JSSoft.Crema
        public static void CompareColumn(CremaDataColumn column1, CremaDataColumn column2)
        {
            if (column1 == null && column2 == null)
            {
                return;
            }
            if (column1 == null || column2 == null)
            {
                Assert.Fail("컬럼이 같지 않습니다.");
            }

            Assert.AreEqual(column1.AllowDBNull, column2.AllowDBNull, "AllowDBNull");
            Assert.AreEqual(column1.AutoIncrement, column2.AutoIncrement, "AutoIncrement");
            Assert.AreEqual(column1.ColumnName, column2.ColumnName, "ColumnName");
            Assert.AreEqual(column1.DataType, column2.DataType, "DataType");
            CremaComparer.CompareType(column1.CremaType, column2.CremaType);
            Assert.AreEqual(column1.DefaultValue, column2.DefaultValue, "DefaultValue");
            Assert.AreEqual(column1.Expression, column2.Expression, "Expression");
            Assert.AreEqual(column1.Validation, column2.Validation, "Validation");
            Assert.AreEqual(column1.Unique, column2.Unique, "Unique");
            Assert.AreEqual(column1.ReadOnly, column2.ReadOnly, "ReadOnly");
            Assert.AreEqual(column1.Comment, column2.Comment, "Comment");
            Assert.AreEqual(column1.IsKey, column2.IsKey, "IsKey");
            Assert.AreEqual(column1.CreationInfo, column2.CreationInfo, "CreationInfo");
            Assert.AreEqual(column1.ModificationInfo, column2.ModificationInfo, "ModificationInfo");
            Assert.AreEqual(column1.ColumnID, column2.ColumnID, "ColumnID");
            Assert.AreEqual(column1.Tags, column2.Tags, "Tags");
            Assert.AreEqual(column1.ColumnInfo, column2.ColumnInfo, "ColumnInfo");
            Assert.AreEqual(column1.Index, column2.Index, "Ordinal");
        }
コード例 #2
0
        public void Test11()
        {
            var dataSet1  = new CremaDataSet();
            var dataType1 = dataSet1.AddRandomType();
            var dataSet2  = new CremaDataSet();
            var dataType2 = dataSet2.Types.Add(dataType1.TypeInfo);

            CremaComparer.CompareType(dataType1, dataType2);
        }
コード例 #3
0
        public void XmlSerializing()
        {
            var dataSet = CremaDataSetExtensions.CreateRandomSet();

            foreach (var item in dataSet.Types)
            {
                string xml     = XmlSerializerUtility.GetString(item);
                var    newType = XmlSerializerUtility.ReadString <CremaDataType>(xml);

                CremaComparer.CompareType(item, newType);
            }
        }
コード例 #4
0
        public void WriteToString_ReadFromString()
        {
            var dataSet = CremaDataSetExtensions.CreateRandomSet();
            var testSet = new CremaDataSet();

            foreach (var item in dataSet.Types)
            {
                string schema = item.GetXmlSchema();
                testSet.ReadTypeString(schema);
                var newType = testSet.Types[item.TypeName];

                CremaComparer.CompareType(item, newType);
            }
        }
コード例 #5
0
        public void WriteToTextWriter_ReaderFromTextReader()
        {
            var dataSet = CremaDataSetExtensions.CreateRandomSet();
            var testSet = new CremaDataSet();

            foreach (var item in dataSet.Types)
            {
                var sw = new StringWriter();
                item.Write(sw);

                var sr = new StringReader(sw.ToString());
                testSet.ReadType(sr);
                var newType = testSet.Types[item.TypeName];

                CremaComparer.CompareType(item, newType);
            }
        }
コード例 #6
0
        public void WriteToStream_ReadFromStream()
        {
            var dataSet = CremaDataSetExtensions.CreateRandomSet();
            var testSet = new CremaDataSet();

            foreach (var item in dataSet.Types)
            {
                var ms = new MemoryStream();
                item.Write(ms);
                ms.Position = 0;

                testSet.ReadType(ms);
                var newType = testSet.Types[item.TypeName];

                CremaComparer.CompareType(item, newType);
            }
        }
コード例 #7
0
        public void WriteToXmlWriter_ReaderFromXmlReader()
        {
            var dataSet = CremaDataSetExtensions.CreateRandomSet();
            var testSet = new CremaDataSet();

            foreach (var item in dataSet.Types)
            {
                var sb     = new StringBuilder();
                var writer = XmlWriter.Create(sb);
                item.Write(writer);
                writer.Close();

                var sr     = new StringReader(sb.ToString());
                var reader = XmlReader.Create(sr);
                testSet.ReadType(reader);
                var newType = testSet.Types[item.TypeName];

                CremaComparer.CompareType(item, newType);
            }
        }
コード例 #8
0
        public void WriteToFile_ReadFromFile()
        {
            var dataSet = CremaDataSetExtensions.CreateRandomSet();
            var testSet = new CremaDataSet();

            foreach (var item in dataSet.Types)
            {
                string schemaPath = PathUtility.GetTempFileName();
                item.Write(schemaPath);

                try
                {
                    testSet.ReadType(schemaPath);
                }
                finally
                {
                    FileUtility.Delete(schemaPath);
                }

                var newType = testSet.Types[item.TypeName];
                CremaComparer.CompareType(item, newType);
            }
        }
コード例 #9
0
ファイル: CremaComparer.cs プロジェクト: s2quake/JSSoft.Crema
        public static void CompareDataSet(CremaDataSet dataSet1, CremaDataSet dataSet2)
        {
            if (dataSet1 == null && dataSet2 == null)
            {
                return;
            }
            if (dataSet1 == null || dataSet2 == null)
            {
                Assert.Fail("타입이 같지 않습니다.");
            }

            CompareSchema(dataSet1, dataSet2);
            CompareXml(dataSet1, dataSet2);

            Assert.AreEqual(dataSet1.DataSetName, dataSet2.DataSetName, "DataSetName");
            Assert.AreEqual(dataSet1.Namespace, dataSet2.Namespace, "Namespace");
            Assert.AreEqual(dataSet1.TableNamespace, dataSet2.TableNamespace, "TableNamespace");
            Assert.AreEqual(dataSet1.TypeNamespace, dataSet2.TypeNamespace, "TypeNamespace");

            Assert.AreEqual(dataSet1.Tables.Count, dataSet2.Tables.Count, "Tables.Count");

            for (int i = 0; i < dataSet1.Tables.Count; i++)
            {
                var table1 = dataSet1.Tables[i];
                var table2 = dataSet2.Tables[table1.Name, table1.CategoryPath];
                CremaComparer.CompareTable(table1, table2);
            }

            Assert.AreEqual(dataSet1.Types.Count, dataSet2.Types.Count, "Types.Count");

            for (int i = 0; i < dataSet1.Types.Count; i++)
            {
                var type1 = dataSet1.Types[i];
                var type2 = dataSet2.Types[type1.TypeName];
                CremaComparer.CompareType(type1, type2);
            }
        }