예제 #1
0
        public void ExpectThrown4はDパラメタに定義されたオブジェクトを4つの引数として取得ができ例外検証ができる()
        {
            // expect : normal
            FixtureBook.ExpectThrown <FixtureBookTestData, FixtureBookTestData, FixtureBookTestData,
                                      FixtureBookTestData, Exception>((p1, p2, p3, p4) =>
            {
                Assert.AreEqual("abc", p1.Text);
                Assert.AreEqual("def", p2.Text);
                Assert.AreEqual("ghi", p3.Text);
                Assert.AreEqual("jkl", p4.Text);
                throw new Exception("zzz");
            });

            // expect : error
            try
            {
                FixtureBook.ExpectThrown <FixtureBookTestData, FixtureBookTestData, FixtureBookTestData,
                                          FixtureBookTestData, Exception>((p1, p2, p3, p4) =>
                {
                    throw new Exception("zzt");
                });
                throw new Exception("ここにはこない");
            }
            catch (AssertFailedException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(e.Message.IndexOf("<zzz>") > -1);
                Assert.IsTrue(e.Message.IndexOf("<zzt>") > -1);
            }
        }
 public void ExpectThrown__テスト対象クラスとテストメソッドを引数指定したExpectThrownは指定されたメソッドを実行する_正常()
 {
     // setup
     delete1 = false;
     // when
     FixtureBook.ExpectThrown <ApplicationException>(typeof(Wrapper), "Delete", typeof(List <Employee>));
     // then
     Assert.IsTrue(delete1);
 }
예제 #3
0
        public void RegisterDefaultExceptionEditorは設定ファイルからも登録できる()
        {
            // when
            Config.Put(FixtureBook.ExceptionEditorKey, "XPFriend.FixtureTest.ExceptionEditors");
            FixtureBook.InitDefaultExceptionEditors();

            // then
            FixtureBook.ExpectThrown <SystemException>(() => { throw new SystemException("sys"); });
            FixtureBook.ExpectThrown <ApplicationException>(() => { throw new ApplicationException("app"); });
        }
예제 #4
0
 public void ExpectThrown__Setupとテスト対象メソッド呼び出しと例外のValidateとValidateStorageができる_Validateエラー()
 {
     // when
     try
     {
         FixtureBook.ExpectThrown <Exception>(() => { throw new Exception("aBC"); });
         throw new Exception("ここにはこない");
     }
     catch (AssertFailedException e)
     {
         //then
         Console.WriteLine(e.Message);
         Assert.IsTrue(e.Message.IndexOf("<ABC>") > -1);
         Assert.IsTrue(e.Message.IndexOf("<aBC>") > -1);
     }
 }
예제 #5
0
        public void ExpectThrown__Setupとテスト対象メソッド呼び出しと例外のValidateとValidateStorageができる_正常終了()
        {
            // setup
            bool called = false;

            // when
            FixtureBook.ExpectThrown <Exception>(() =>
            {
                ValidateDatabase(131);
                called = true;
                throw new Exception("ABC");
            });

            //then
            Assert.IsTrue(called);
        }
 public void ExpectThrown__テスト対象クラスとテストメソッドを引数指定したExpectThrownは指定されたメソッドを実行する_エラー()
 {
     // setup
     delete2 = false;
     try
     {
         // when
         FixtureBook.ExpectThrown <ApplicationException>(typeof(Wrapper), "Delete", typeof(List <Employee>), typeof(int));
         throw new Exception("ここにはこない");
     }
     catch (AssertFailedException e)
     {
         // then
         Console.WriteLine(e);
         Assert.IsTrue(delete2);
     }
 }
예제 #7
0
        public void RegisterDefaultExceptionEditorで登録したエディタで例外を編集できる()
        {
            // when
            FixtureBook.RegisterDefaultExceptionEditor((SystemException e) =>
            {
                Console.WriteLine(e);
                Assert.AreEqual("sys", e.Message);
                return(new Dictionary <string, string>()
                {
                    { "Message", "zzz" }
                });
            });

            // then
            FixtureBook.ExpectThrown <SystemException>(() => { throw new SystemException("sys"); });
            FixtureBook.ExpectThrown <SystemException>(typeof(SystemExceptionThrower), "ThrowSystemException");
        }
예제 #8
0
        public void ExpectThrownは指定されたラムダ式の例外が検証できる()
        {
            // expect : normal
            FixtureBook.ExpectThrown <Exception>(() => { throw new Exception("zzz"); });

            // expect : error
            try
            {
                FixtureBook.ExpectThrown <Exception>(() => { throw new Exception("zzp"); });
                throw new Exception("ここにはこない");
            }
            catch (AssertFailedException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(e.Message.IndexOf("<zzz>") > -1);
                Assert.IsTrue(e.Message.IndexOf("<zzp>") > -1);
            }
        }
예제 #9
0
 public void Delete__指定した従業員データのIDがnullならばInvalid_IDというメッセージを持つApplicationExceptionが発生する()
 {
     FixtureBook.ExpectThrown();
 }
예제 #10
0
 public void Delete__引数なしのExpectThrownはテストクラス名とテストカテゴリからテスト対象メソッドを類推して実行する()
 {
     FixtureBook.ExpectThrown();
 }