[seasar-dotnet:877] Re: [S2Unit.NET][要望]テストクラス単位でdiconファイルを指定したい

Hiroaki Fujii [E-MAIL ADDRESS DELETED]
2008年 6月 12日 (木) 01:01:47 JST


上谷さん。

藤井です。

> あと、確認なんですが、IParent がIChildをプロパティに持つとき、
> 下記のIncludeTest、InitTest、RegisterTestが失敗するのは仕様でしょうか?

の件ですが、
・App.diconの中の<component>タグの行を消す。つまり空にする。
・TestクラスにSetUpメソッドを追加し、その中でApp3.diconをIncludeする。
・IncludeTestメソッドのIncludeメソッドの引数をApp3.diconに変更する。
・AutoBindingTestの中のIncludeしている行を削除する。
とすれば、テストが通りました。

いかがでしょうか?


Toru Uetani さんは書きました:
> 藤井さん、おはようございます。上谷です。
> 
>> テストクラスの中で、そのクラス用の別のdiconファイルを指定してあげて、
> すいません、ちょっとこの意味がわかりません。
> テストメソッドの中で、this.Includeを実行するということでしょうか?
> 現状その方法も使っております。
> ただ、1つのテストクラスのメソッドすべてにIncludeを書くことになり、
> あまりスマートじゃないな、ということで今回の要望に至っています。
> 
>> _abc = (string) GetComponent("abc");
>> Assert.AreEqual("hoge", _abc, "abc");
>> こうしてあげると、そのテストクラス用のdiconファイルに記述した値が
>> セットされます。
>> これではだめでしょうか?
> 今のところ、その方法でテストしております。
> が、これだとS2Unitを使ってる意味があるのかな・・・と。
> 
> 
> あと、確認なんですが、IParent がIChildをプロパティに持つとき、
> 下記のIncludeTest、InitTest、RegisterTestが失敗するのは仕様でしょうか?
> 
> --App.dicon
> <components>
>   <component class="Foo.Fuga.Parent"></component>
> </components>
> 
> --App2.dicon
> <components>
>   <component class="Foo.Fuga.Child"></component>
> </components>
> 
> --App3.dicon
> <components>
>   <include path="Foo.Fuga.App2.dicon" />
>   <component class="Foo.Fuga.Parent"></component>
> </components>
> 
> --Test.cs
> namespace Foo.Fuga {
>     [TestFixture]
>     public class Test : S2TestCase {
>         private IParent _parent = null;
>         private IChild _child = null;
> 
>         [S2, Test]
>         public void AutoBindingTest() {
>             this.Include("App2.dicon");
>             Assert.IsNotNull(_parent);
>             Assert.IsNotNull(_child);//ここで失敗
>         }
> 
>         [S2,Test]
>         public void IncludeTest() {
>             this.Include("App2.dicon");
>             IParent parent = (IParent)this.GetComponent(typeof(IParent));
>             IChild child = (IChild)this.GetComponent(typeof(IChild));
>             Assert.IsNotNull(parent);
>             Assert.IsNotNull(child);
>             Assert.IsNotNull(parent.Hoge);//ここで失敗
>         }
> 
>         [S2, Test]
>         public void InitTest() {
>             this.Container.Destroy();
>             this.Container.Path = "Foo.Fuga.App3.dicon";
>             this.Container.Init();
> 
>             IParent parent = (IParent)this.GetComponent(typeof(IParent));
>             IChild child = (IChild)this.GetComponent(typeof(IChild));//ここで失敗
>             Assert.IsNotNull(parent);
>             Assert.IsNotNull(child);
>             Assert.IsNotNull(parent.Hoge);
>         }
> 
>         [S2, Test]
>         public void RegisterTest() {
>             this.Register(new Child());
>             IParent parent = (IParent)this.GetComponent(typeof(IParent));
>             IChild child = (IChild)this.GetComponent(typeof(IChild));
>             Assert.IsNotNull(parent);
>             Assert.IsNotNull(child);
>             Assert.IsNotNull(parent.Hoge);//ここで失敗
>         }
>     }
> }
> 
> --
> ┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏
> 
>  ┏━━━┓ 上谷 徹(Toru Uetani)
>  ┃\_/┃ mail:[E-MAIL ADDRESS DELETED]
>  ┗━━━┛
> ┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> seasar-dotnet mailing list
> [E-MAIL ADDRESS DELETED]
> https://ml.seasar.org/mailman/listinfo/seasar-dotnet



seasar-dotnet メーリングリストの案内