Пример #1
0
        private static T AutoFakeFromConstructor <T>(ConstructorInfo constructor)
        {
            var fakedParameters = constructor.GetParameters().Select(p => Fake(p.ParameterType)).ToArray();
            var autoFakedObject = (T)constructor.Invoke(fakedParameters);

            FakeContainer.RegisterFakes(autoFakedObject, fakedParameters);
            return(autoFakedObject);
        }
Пример #2
0
        private static IEnumerable <object> GetFakesUsedBy(object autoFakedObject)
        {
            var fakes = FakeContainer.GetFakesUsedBy(autoFakedObject);

            if (fakes == null)
            {
                var message = String.Format("This object was not auto faked. Expected usage is:\r\n{0}", ExpectedUsage(autoFakedObject));
                throw new FakeRetrievalException(message);
            }
            return(fakes);
        }