public void RegisterMethod_TypeMethodRegistered()
        {
            MethodInfo info = typeof(TestClass).GetMethod("Method");
            Mock <IEngineConfigurationTypeMember> typeMemberMock = new Mock <IEngineConfigurationTypeMember>();

            MethodInvocationContext context = new MethodInvocationContext();

            context.AddArgumentValue(5);

            int count = 0;

            mTypeMock.Setup(x => x.GetRegisteredMember(It.IsAny <EngineTypeMember>()))
            .Returns(() =>
            {
                if (count == 0)
                {
                    count++; return(null);
                }
                else
                {
                    return(typeMemberMock.Object);
                }
            });
            mContext.RegisterMethod(info, context);
            mTypeMock.Verify(x => x.RegisterMember(It.Is <EngineTypeMember>(y => y.Name == info.Name)), Times.Once());
        }
Exemplo n.º 2
0
        public void NonGeneric_SetupMethodWithParameters_ReturnsConfiguration()
        {
            EngineConfigurationTypeBuilder configuration = new EngineConfigurationTypeBuilder(typeof(SimpleMethodClass));
            var context = new MethodInvocationContext();

            context.AddArgumentValue("Hello");
            IEngineConfigurationTypeBuilder returnValue = configuration.SetupMethod("SetSomething", context);

            Assert.AreEqual(configuration, returnValue);
        }
        public void AddArgumentValue_AddsArgument()
        {
            MethodInvocationContext context = new MethodInvocationContext();

            context.AddArgumentValue(5);

            DatasourceFactory factory = context.GetArguments().First();

            Assert.NotNull(factory);
        }