Beispiel #1
0
        public void T04_Insert()
        {
            ISqlClient sqlClient = getClient();

            sqlClient.ClearTable(testTable);

            // Get column definitions (from data base)
            List <SqlColumn> columns = sqlClient.GetColumns(testTable);

            // Add some information from test meta data definition
            foreach (ColumnMetadata cmd in columnMetadata)
            {
                SqlColumn col = columns.Where(n => n.Name == cmd.Fieldname).First();
                col.ValueString = cmd.TestValue;
                col.IsDocument  = cmd.IsDocument;
            }

            // Remove unsupported columns
            List <SqlColumn> toBeRemoved = columns.Where(n => n.SqlType == null).ToList();

            foreach (SqlColumn col in toBeRemoved)
            {
                columns.Remove(col);
            }

            // Convert strings to objects and insert row
            sqlClient.SetObjectValues(columns);
            sqlClient.Insert(columns);

            // Read back row from data base
            List <SqlColumn> result = new List <SqlColumn>();

            foreach (SqlColumn col in columns)
            {
                result.Add(new SqlColumn()
                {
                    Name = col.Name, SqlType = col.SqlType
                });
            }
            sqlClient.GetOneRow(result);

            // Verify that input values and output values match
            foreach (SqlColumn col in columns)
            {
                compareSqlColumn(col, result.Where(n => n.Name == col.Name).First());
            }

            // Verify that docuoment has been stored properly as blob
            string resultDocument = Path.Combine(Path.GetTempPath(), "Document1.pdf");

            File.WriteAllBytes(resultDocument,
                               columns.Where(n => n.Name == "MyDocument").First().ValueObject as Byte[]);
            Assert.IsTrue(SIEEUtils.CompareFiles(testDocument, resultDocument));
            File.Delete(resultDocument);

            // Clear table
            sqlClient.ClearTable(testTable);
        }
Beispiel #2
0
        public void T05_CultureInfo()
        {
            ISqlClient sqlClient = getClient();

            foreach (SqlColumn col in sqlClient.GetColumns(testTable).Where(n => n.SqlType != null))
            {
                List <SqlColumn> lc = new List <SqlColumn>();
                lc.Add(col);

                switch (col.SqlType.DotNetType.ToString())
                {
                case SqlTypes.DateTime_TypeName:
                    col.ValueString = "03.04.2016";
                    sqlClient.SetCulture(new CultureInfo("de-DE"));
                    sqlClient.SetObjectValues(lc);
                    Assert.AreEqual(4, ((DateTime)col.ValueObject).Month);

                    sqlClient.SetCulture(new CultureInfo("en-US"));
                    sqlClient.SetObjectValues(lc);
                    Assert.AreEqual(3, ((DateTime)col.ValueObject).Month);
                    break;

                case SqlTypes.Decimal_TypeName:
                    col.ValueString = "1.234,56";
                    sqlClient.SetCulture(new CultureInfo("de-DE"));
                    sqlClient.SetObjectValues(lc);
                    Assert.AreEqual((decimal)1234.56, col.ValueObject);

                    col.ValueString = "1,234.56";
                    sqlClient.SetCulture(new CultureInfo("en-US"));
                    sqlClient.SetObjectValues(lc);
                    Assert.AreEqual((decimal)1234.56, col.ValueObject);
                    break;

                case SqlTypes.Double_TypeName:
                    col.ValueString = "1.234,5678";
                    sqlClient.SetCulture(new CultureInfo("de-DE"));
                    sqlClient.SetObjectValues(lc);
                    Assert.AreEqual(1234.5678, col.ValueObject);

                    col.ValueString = "1,234.5678";
                    sqlClient.SetCulture(new CultureInfo("en-US"));
                    sqlClient.SetObjectValues(lc);
                    Assert.AreEqual(1234.5678, col.ValueObject);
                    break;

                default: break;
                }
            }
        }
Beispiel #3
0
        public void T03_GetColumns()
        {
            ISqlClient       sqlClient = getClient();
            List <SqlColumn> columns   = sqlClient.GetColumns(testTable);

            Assert.AreEqual(columnMetadata.Count, columns.Count);
            foreach (SqlColumn cd in columns)
            {
                ColumnMetadata cmd = columnMetadata.Where(n => n.Fieldname == cd.Name).First();
                if (cmd.Implemented)
                {
                    Assert.AreEqual(SqlTypes.GetSqlType(cmd.Typename).SqlDbType, cd.SqlType.SqlDbType);
                }
                else
                {
                    Assert.IsNull(cd.SqlType);
                }
            }
        }