[英]C# Web Service Unit Tests
I have the following Entity: 我有以下实体:
Amount
Currency - String
Value - decimal
I have also a wcf service that uses this entity and I want to make a unit test to this class. 我也有一个使用此实体的wcf服务,我想对该类进行单元测试。
My problem is that I want test invalid values to the Value in the entity and if I try to assign in in the c# 我的问题是我想测试无效值到实体中的值,如果我尝试在c#中分配
Amout m = new Amout{Currency = "EUR", Value = "aaaa"}
gave error. 给了错误。
How can I test this situation? 如何测试这种情况?
For example I can make the following request in soapUI: 例如,我可以在soapUI中发出以下请求:
<itc1:Amount>
<itc2:Currency>EUR</itc2:Currency>
<itc2:Value>aaaaaa</itc2:Value>
</itc1:Amount>
and I get error from the service. 我从服务中得到错误。
I want to make the same with an unit test. 我想对单元测试做同样的事情。
I hope you can help me. 我希望你能帮助我。
Are you looking for something like this : 您是否正在寻找这样的东西:
[TestMethod()]
[ExpectedException(typeof(KnownExceptionType))]
public void Test()
{
//Do something that throws a KnownExceptionType
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.