示例#1
0
        private object Create(AutoParameter autoParameter, bool exists)
        {
            if (autoParameter == null)
            {
                return(null);
            }
            object instance = autoParameter.Create();

            if (!exists)
            {
                dictionary.Add(autoParameter, instance);
            }
            return(instance);
        }
示例#2
0
        public void MethodWithParameters3()
        {
            IParameter parameter = AutoParameter.Create(() =>
            {
                ITestMethods fake = A.Fake <ITestMethods>();
                A.CallTo(() => fake.WithParameters("123", "abc", 5)).Returns(42);
                return(fake);
            });
            TypeDefinition <ITestMethods> typeDefinition =
                new TypeDefinition <ITestMethods>(
                    new DefinitionImport(parameter));
            ITestMethods test = typeDefinition.Create();

            Assert.AreEqual(42, test.WithParameters("123", "abc", 5));
        }