Hello Adam, 

I tried without ".Return(string.Empty)" but it was giving me 
'InvalidOperationException' because it needed the return value.

On Tuesday, June 26, 2012 3:39:43 PM UTC-4, Adam wrote:
>
> Doesn't it work if you take away ".Return(string.Empty)" at the end?
>
> On Tuesday, June 26, 2012 3:36:01 PM UTC-4, Tony wrote:
>>
>> Hi,
>>
>> I have question regarding stubbing WCF methods. 
>> This example will show you what I am trying to do.
>>
>> I'm coding in C#, VS 2008, Rhino Mocks
>>
>> //WCF
>>
>> [ServiceContract]
>> public interface IDataService
>>  {
>>        [OperationContract]
>>        string GetData();
>>
>>        [OperationContract]
>>        string CallRealValue();
>>
>>         [OperationContract]
>>        string CallStubValue();
>>
>> }
>>
>> public class DataService : IDataService
>> {
>>        public string GetData()
>>        {
>>             string result = CallRealValue();
>>        }
>>      
>>        public virtual string CallRealValue()
>>        {
>>                //doing something
>>                return "Real";
>>        }
>>
>>        public virtual string CallStubValue()
>>        {
>>                //doing something
>>               return "Stub";
>>        }
>> }
>>
>> //In my console project, I have reference to the WCF so that I can access 
>> their members [ServiceReferenceData]
>>
>> public class Test
>> {
>>     public static void Main()
>>     {
>>            ServiceReferenceData.DataServiceClient dsc = 
>> MockRepository.GeneratePartialMock<ServiceReferenceData.DataServiceClient>();
>>        
>>            dsc.Expect(x => x.CallRealValue())
>>                  .WhenCalled(t => t.ReturnValue = dsc.CallStubValue())
>>                  .Return(string.Empty)
>>
>>
>>            string result = dsc.GetData();
>>
>>            //After above statement 'result' variable should be 'Stub' 
>> instead of null. I could not figured it out whats wrong with my syntex. 
>>            //However, I tried the same thing with the simpler example 
>> that is not WCF service methods and whenever I call GetData() method,
>>            //inside of that method it always goes to CallStubValue() 
>> which was expected and I was getting the correct result back but for WCF 
>>            //service it does not working.
>>
>>      }
>>
>> }
>>
>> Any help would be appreciated. 
>> Thanks,
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rhinomocks/-/CEfL26HazRoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to