コード例 #1
0
        public void MultiCtors_WithNewInstance_UsesEmptyCtor()
        {
            var sp = new ActivatorServiceProvider();

            var result = Reflect.Type <TwoCtorStub>()
                         .WithNewInstance()
                         .GetMethod(nameof(TwoCtorStub.GetValue))
                         .Invoke(new ParamStub1(), new ParamStub2());

            Assert.Equal("EmptyCtor_ParamStub1Value_ParamStub2Value_", result);
        }
コード例 #2
0
        public void MutiCtors_SpecifiedCtorWithServiceProvider_UsesCorrectCtor()
        {
            var sp = new ActivatorServiceProvider();

            var result = Reflect.Type <TwoCtorStub>()
                         .WithNewInstance()
                         .UsingConstructor <ParamStub1>()
                         .WithArgumentsFromServiceProvider(sp)
                         .GetMethod(nameof(TwoCtorStub.GetValue))
                         .Invoke(new ParamStub1(), new ParamStub2());

            Assert.Equal("ParamCtor_ParamStub1Value_ParamStub2Value_", result);
        }
コード例 #3
0
        public void MultiCtors_WithNewInstanceWithMethodParametersFromProvider_UsesEmptyCtor()
        {
            var sp = new ActivatorServiceProvider();

            var result = Reflect.Type <TwoCtorStub>()
                         .WithNewInstance()
                         .GetMethod(nameof(TwoCtorStub.GetValue))
                         .WithParameters <ParamStub1, ParamStub2>()
                         .FromServiceProvider(sp)
                         .Invoke();

            Assert.Equal("EmptyCtor_ParamStub1Value_ParamStub2Value_", result);
        }