예제 #1
0
        public async Task TestExportRelationalHTMLSqlServer()
        {
            #region arrange
            string folderName = AppContext.BaseDirectory;
            //CreateExportFilesSqlServer(Path.Combine(folderName,"Views"));
            var connectionString = GetSqlServerConnectionString();

            using (var conn = new SqlConnection(connectionString))
            {
                await conn.OpenAsync();

                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = @"
IF OBJECT_ID('dbo.TestAndrei', 'U') IS NOT NULL
 DROP TABLE dbo.TestAndrei;";
                    await cmd.ExecuteNonQueryAsync();

                    cmd.CommandText = @"create table TestAndrei(
        ID int,
        FirstName varchar(64) not null
             )";
                    await cmd.ExecuteNonQueryAsync();
                }
            }

            var rr = new ReceiverRelationalSqlServer();
            rr.ConnectionString = connectionString;
            string OutputFileName = SimpleJobConditionalTransformersTest.DeleteFileIfExists(Path.Combine(folderName, "relationalSqlServer.html"));
            var    sender         = new Sender_HTMLRazor("Views/sqlserver.cshtml", OutputFileName);

            var senderViz = new Sender_HTMLRelationViz("Name", OutputFileName);
            var filter    = new FilterExcludeRelation("columns", "tables");
            var job       = new SimpleJobConditionalTransformers();
            job.Receivers.Add(0, rr);
            job.AddSender(sender);
            job.Add(filter);
            job.Add(filter, senderViz);
            #endregion
            #region act
            await job.Execute();

            #endregion
            #region assert
            Assert.IsTrue(File.Exists(OutputFileName), $"{OutputFileName} must exists");
            //Process.Start("explorer.exe", OutputFileName);
            var text = File.ReadAllText(OutputFileName);
            Assert.IsTrue(text.Contains("TestAndrei"), "must contain table testandrei");
            Assert.IsTrue(text.Contains("FirstName"), "must contain column FirstName ");

            #endregion
        }
예제 #2
0
        static string DocumentSqlServer()
        {
            var rr = new ReceiverRelationalSqlServer();

            rr.ConnectionString = "#file:SqlServerConnectionString#";
            string OutputFileName = "relationalSqlServer.html";
            var    sender         = new Sender_HTMLRazor("Views/sqlserver.cshtml", OutputFileName);

            sender.FileMode = FileMode.Create;
            var filter    = new FilterExcludeRelation(new string[] { "columns", "tables", "views" });
            var senderViz = new Sender_HTMLRelationViz("Name", OutputFileName);


            var si = new SimpleJobConditionalTransformers();

            si.Receivers.Add(0, rr);
            si.AddSender(sender);
            si.Add(filter);
            si.Add(filter, senderViz);
            return(si.SerializeMe());
        }