我必须为Azure Function编写单元测试用例。我想模拟输入值。
这是我的天蓝色功能:
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage httpRequestMessage, TraceWriter traceWriter)
{
var con = httpRequestMessage.Content;//it has image file
string httpreqContent = con.ReadAsStringAsync().Result;
var headers = httpRequestMessage.Headers;
var Returnvalue="";
var ImageHeight = headers.GetValues("height");
var ms = new MemoryStream(Convert.FromBase64String(httpreqContent));
var Obj = new { image = Convertmethod(ms, ImageHeight,traceWriter) };
Returnvalue = JsonConvert.SerializeObject(Obj);
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(Returnvalue, Encoding.UTF8, Constants.JSON)
};
}