Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用NUnit进行WCF调试_Wcf_Nunit_Visual Studio 2012 - Fatal编程技术网

使用NUnit进行WCF调试

使用NUnit进行WCF调试,wcf,nunit,visual-studio-2012,Wcf,Nunit,Visual Studio 2012,问题:我如何调试WCF服务?我不能在服务中找到断点 使用VS2012和NUnit/TestDriven 我可以很好地运行我的测试,只要我在WcfHostApplication上的eg Ctrl F5之前启动了服务。我在VisualStudio内主持 已尝试将Web.Config放入WCFHostConsole应用程序并将debug设置为true。 此示例应用程序来自 //在我们还没有使用wsdl的情况下开始工作……模仿wsdl中发生的事情 [ServiceContract(命名空间=”http

问题:我如何调试WCF服务?我不能在服务中找到断点

使用VS2012和NUnit/TestDriven

我可以很好地运行我的测试,只要我在WcfHostApplication上的eg Ctrl F5之前启动了服务。我在VisualStudio内主持

已尝试将Web.Config放入WCFHostConsole应用程序并将debug设置为true。

此示例应用程序来自

//在我们还没有使用wsdl的情况下开始工作……模仿wsdl中发生的事情
[ServiceContract(命名空间=”http://www.programgood.net/examples/2012/09/wcf")]
公共接口IHelloWcfService
{
[经营合同]
字符串SayHello(字符串msg);
}
命名空间HelloWcfTests
{
[测试夹具]
公共类HelloWcfServiceLibrary_测试
{
[测试]
公共空间SayHello\u GivenHello\u ShouldReturn()
{
//实际上,使用另一个名为IMeadataExchange的特殊接口添加服务引用
IHelloWcfService proxy=ChannelFactory.CreateChannel(
新的NetTcpBinding(),
新端点地址(“net。tcp://localhost:9000/HelloWcfEndPoint"));
string msg=“你好”;
字符串结果=proxy.SayHello(msg);
StringAssert.StartsWith(“您输入了:hello”,result);
}
}
}

不要使用Ctrl+F5启动服务,因为它将在不进行调试的情况下启动服务

从F5开始


不要使用Ctrl+F5启动服务,因为它将在不进行调试的情况下启动服务

从F5开始


使用F5启动主机服务。然后转到测试代码并在测试中右键单击TestDriven.NET start using debugger。而且它有效!使用F5启动主机服务。然后转到测试代码并在测试中右键单击TestDriven.NET start using debugger。而且它有效!
    //hack to get working as we're not using wsdl yet...mimicking what happens in wsdl
[ServiceContract(Namespace = "http://www.programgood.net/examples/2012/09/wcf")]
public interface IHelloWcfService
{
    [OperationContract]
    string SayHello(string msg);
}

namespace HelloWcfTests
{
    [TestFixture]
    public class HelloWcfServiceLibrary_Tests
    {
        [Test]
        public void SayHello_GivenHello_ShouldReturn()
        {
            //in reality add Service Ref.. using another special interface called IMetaDataExchange
            IHelloWcfService proxy = ChannelFactory<IHelloWcfService>.CreateChannel(
                new NetTcpBinding(),
                new EndpointAddress("net.tcp://localhost:9000/HelloWcfEndPoint"));

            string msg = "hello";
            string result = proxy.SayHello(msg);
            StringAssert.StartsWith("You entered: hello", result);
        }
    }
}