コード例 #1
0
ファイル: Example1.cs プロジェクト: josibb/sqlunittesting
        public void FluentTest1()
        {
            var testResults = Setup.Default.CreateTest()
                              .AddAction <SqlScriptAction>(a => a
                                                           .WithName("setupdata")
                                                           .WithConnection("ExampleDb-Test")
                                                           .WithSqlFromResource("XmlFiles.InsertTouAndCosts.sql")
                                                           .AddParameter <InputParameter>(p => p.WithDbType(DbType.DateTime).WithName("@dt").WithValue(new DateTime(2001, 06, 20)))
                                                           .AddParameter <OutputParameter>(p => p.WithDbType(DbType.Int32).WithName("@touid"))
                                                           .AddParameter <OutputParameter>(p => p.WithDbType(DbType.Int32).WithName("@costid"))
                                                           )
                              .AddAction <SqlScriptAction>(a => a
                                                           .WithName("test")
                                                           .WithConnection("ExampleDb-Test")
                                                           .WithSqlFromResource("XmlFiles.ExecP_AvgCost_Monthly.sql")
                                                           .AddParameter <LinkedInputParameter>(p => p.LinkTo("setupdata", "@touid"))
                                                           .AddParameter <LinkedInputParameter>(p => p.LinkTo("setupdata", "@costid"))
                                                           )
                              .Execute();

            SqlAssert.Equals(ActionResult.ReadFromResource("XmlFiles.TimeSerieResult.xml"), testResults["test"]);
            SqlAssert.MaxEllapsedSqlMilliseconds(testResults["test"], 100);
        }