I have Silverligth Unit test Application (.net 4.0) and I've added reference to my WCF service(3.5)
And here are my codes
MyService.svc
<%@ServiceHost Language="VB" Service="MyServiceWS.Service1" %>
MyService.asmx
<System.Web.Services.WebService(Namespace:="http://schemas.mypage.co.uk/MyService")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ServiceContract(Namespace:="http://schemas.mypage.co.uk/MyService")> _
<ServiceKnownType(GetType(Member))> _
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
From reference.cs
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class Service1Client : System.ServiceModel.ClientBase<MyServiceApp.MyServiceService.Service1>, MyServiceApp.MyServiceService.Service1 {
my testclass:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace MyServiceApp.UnitTests
{
[TestClass]
public class ShowroomLogViewModelTests
{
[TestMethod]
public void ReloadShowroomLogs_IsBusyShouldBeFalse()
{
var mockedWebService = Mock<IService1>;
Problem is that:
IService1 cannot be resolved
How can I mock my wcf service?
EDIT: One Step Closer
var mockedWebService =new Mock<MyService.Service1>;
I've changed to this and now is compiling, but... I haven' access to method, e.g.
mockedWebService.GetShowroomLog开发者_高级运维s();
It is a big problem, because, I need change a property ServiceClient at ShowroomLogViewModel to interface, and I can't because then my viewmodel can't use wcf service methods.
You should do this: mockedWebService.Object.GetShowroomLogs();
精彩评论