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

Toru Uetani [E-MAIL ADDRESS DELETED]
2008年 6月 11日 (水) 10:40:59 JST


藤井さん、おはようございます。上谷です。

> テストクラスの中で、そのクラス用の別の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]
 ┗━━━┛
┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏┏
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ClassLibrary1.zip
Type: application/zip
Size: 5143 bytes
Desc: 無し
URL: <http://ml.seasar.org/archives/seasar-dotnet/attachments/20080611/e69c3b4c/attachment.zip>


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