public PropertyBehaviorRule(MethodInfo propertyGetterOrSetter, FakeObject fakeObject)
            {
                this.fakeObject = fakeObject;
                var property = GetProperty(propertyGetterOrSetter);

                this.propertySetter = property.GetSetMethod();
                this.propertyGetter = property.GetGetMethod(true);
            }
Beispiel #2
0
            protected override void OnAddInterceptedCall(FakeObject fakeObject, ICompletedFakeObjectCall call)
            {
                List <ICompletedFakeObjectCall> calls;

                if (!this.recordedCalls.TryGetValue(fakeObject, out calls))
                {
                    calls = new List <ICompletedFakeObjectCall>();
                    this.recordedCalls.Add(fakeObject, calls);
                }

                calls.Add(call);
            }
            protected override void OnAddRule(FakeObject fakeObject, CallRuleMetadata rule)
            {
                List <CallRuleMetadata> rules;

                if (!this.rulesField.TryGetValue(fakeObject, out rules))
                {
                    rules = new List <CallRuleMetadata>();
                    this.rulesField.Add(fakeObject, rules);
                }

                rules.Add(rule);
            }
Beispiel #4
0
 public FakeObjectInterceptor(FakeObject fake)
 {
     this.fake = fake;
 }
        private ProxyResult GenerateProxyWithArgumentsForConstructor(Type typeOfFake, IEnumerable <object> argumentsForConstructor, FakeObject fake)
        {
            var result = this.proxyGenerator.GenerateProxy(typeOfFake, fake, argumentsForConstructor);

            if (!result.ProxyWasSuccessfullyCreated)
            {
                ThrowCanNotGenerateFakeException(typeOfFake);
            }

            return(result);
        }
Beispiel #6
0
 protected abstract void OnAddInterceptedCall(FakeObject fakeObject, ICompletedFakeObjectCall call);
Beispiel #7
0
 protected abstract void OnAddRule(FakeObject fakeObject, CallRuleMetadata rule);
Beispiel #8
0
 internal abstract IEnumerable <ICompletedFakeObjectCall> GetCallsWithinScope(FakeObject fakeObject);
Beispiel #9
0
 /// <summary>
 /// Adds a fake object call to the current scope.
 /// </summary>
 /// <param name="fakeObject">The fake object.</param>
 /// <param name="rule">The rule to add.</param>
 internal void AddRule(FakeObject fakeObject, CallRuleMetadata rule)
 {
     fakeObject.AllUserRules.AddFirst(rule);
     this.OnAddRule(fakeObject, rule);
 }
Beispiel #10
0
 /// <summary>
 /// Adds an intercepted call to the current scope.
 /// </summary>
 /// <param name="fakeObject">The fake object.</param>
 /// <param name="call">The call that is intercepted.</param>
 internal void AddInterceptedCall(FakeObject fakeObject, ICompletedFakeObjectCall call)
 {
     fakeObject.AllRecordedCalls.Add(call);
     this.OnAddInterceptedCall(fakeObject, call);
 }
Beispiel #11
0
            internal override IEnumerable <ICompletedFakeObjectCall> GetCallsWithinScope(FakeObject fakeObject)
            {
                List <ICompletedFakeObjectCall> calls;

                if (!this.recordedCalls.TryGetValue(fakeObject, out calls))
                {
                    calls = new List <ICompletedFakeObjectCall>();
                }

                return(calls);
            }
Beispiel #12
0
 protected override void OnAddInterceptedCall(FakeObject fakeObject, ICompletedFakeObjectCall call)
 {
     // Do nothing
 }
Beispiel #13
0
 protected override void OnAddRule(FakeObject fakeObject, CallRuleMetadata rule)
 {
     // Do nothing
 }
Beispiel #14
0
 internal override IEnumerable <ICompletedFakeObjectCall> GetCallsWithinScope(FakeObject fakeObject)
 {
     return(fakeObject.AllRecordedCalls);
 }