コード例 #1
0
        public void op_DoGetAllInstances_Type()
        {
            var expected = new Mock<ITest>().Object;

            var container = new Mock<IWindsorContainer>();
            container
                .Setup(x => x.ResolveAll(typeof(ITest)))
                .Returns(new[] { expected })
                .Verifiable();

            var obj = new WindsorServiceLocator(container.Object);

            var actual = obj.GetAllInstances<ITest>().First();

            Assert.Same(expected, actual);

            container.VerifyAll();
        }
コード例 #2
0
        public void op_DoGetInstance_Type_string()
        {
            const string key = "example";
            var expected = new Mock<ITest>().Object;

            var container = new Mock<IWindsorContainer>();
            container
                .Setup(x => x.Resolve(key, typeof(ITest)))
                .Returns(expected)
                .Verifiable();

            var obj = new WindsorServiceLocator(container.Object);

            var actual = obj.GetInstance<ITest>(key);

            Assert.Same(expected, actual);

            container.VerifyAll();
        }