[Fact]
public void TestNewGreetingAdd()
{
//准备
var greetingName = "testName";
var greetingMessage = "Hello test";
var fakeRequest = new HttpRequestMessage(HttpMethod.Post,"http://localhost:XXXX/api/greeting");
var greeting = new Greeting { Name = greetingName , Message = greetingMessage };
var service = new GreetingController();
service.Request = fakeRequest;
// 操作
var response = service.PostGreeting(greeting);//这是一个方法,方法提交谓词POST,需要参数greeting。
//断言
Assert.NotNull(response);
Assert.Equal(HttpStatusCode.Created,response.StatusCode);
Assert.Equal(new Uri("Http://localhost:XXXX/api/greeting/newgreeting"),response.Headers.Location);
}
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |