public void ShouldStoreParameterTypeOfMethod()
        {
            var @class      = new Class(typeof(TestServiceForServiceCallTest));
            var serviceCall = new ServiceCall(new TestServiceForServiceCallTest(), @class.GetMethod("Method").MethodInfo);

            Assert.AreEqual("System.String", serviceCall.ParameterTypes[0]);
        }
        public void InvokingAExistingServiceShouldReturnStatus()
        {
            var callInPreviousRun = new ServiceCall(new TestService(), @class.GetMethod("Method").MethodInfo);

            executionHistory.Add(callInPreviousRun);
            callInPreviousRun.ReturnValue = string.Empty;

            LastServiceCallStatus callStatus = serviceExecution.Invoking(new TestService(), @class.GetMethod("Method").MethodInfo);

            Assert.AreEqual(1, executionHistory.ServiceCalls.Count);
            Assert.AreNotEqual(null, callStatus);
            Assert.AreNotEqual(null, callStatus.ReturnValue);
        }
        public virtual LastServiceCallStatus Invoking(Service service, MethodInfo methodInfo)
        {
            currentServiceCall = new ServiceCall(service, methodInfo);
            ServiceCalls matchingHistoryCalls        = executionHistory.FindCalls(currentServiceCall);
            ServiceCalls matchingCurrentServiceCalls = currentServiceCalls.Matching(currentServiceCall);

            if (matchingHistoryCalls.Count > matchingCurrentServiceCalls.Count)
            {
                matchingCurrentServiceCalls.Sort(delegate(ServiceCall x, ServiceCall y) { return(x.CallNumber.CompareTo(y.CallNumber)); });
                int         currentCallNumberForService = matchingHistoryCalls.Last.CallNumber;
                ServiceCall matchingCall =
                    matchingHistoryCalls.Find(delegate(ServiceCall obj) { return(obj.CallNumber.Equals(currentCallNumberForService)); });
                currentServiceCalls.Add(matchingCall);
                return(new LastServiceCallStatus(matchingCall.ReturnValue));
            }
            else
            {
                currentServiceCall.CallNumber = matchingCurrentServiceCalls.Count;
                return(new NullLastServiceCallStatus());
            }
        }
Beispiel #4
0
 public virtual ServiceCalls FindCalls(ServiceCall match)
 {
     return(serviceCalls.Matching(match));
 }
Beispiel #5
0
 public virtual void Add(ServiceCall serviceCall)
 {
     serviceCalls.Add(serviceCall);
 }