Discussion:
How do I do write the code in C# that can be used in VS unit test
(too old to reply)
Tony Johansson
2016-03-08 19:48:34 UTC
Permalink
Background: I have a node.js API that use json to send and receive message
from client. I want to use the built in unit test that exist in visual
studio to test the API. I know I can use for exampel postman to test the API
but I need a a quich and reliable way to test 6 different rest API. If I get
some help with this one I can manage the other five myself.

$.ajax({
type: 'GET',
url: 'http://diseserver.net/api/v1/users/1',
dataType: 'json',
async: false,
headers: {
'Authorization': 'Basic ' + btoa('DEFAULT/user:password')
},
success: function(response) {
//your success code
console.log(response);
},
error: function (err) {
//your error code
console.log(err);
}
});

//Tony
Registered User
2016-03-08 23:37:02 UTC
Permalink
check out

<http://www.asp.net/web-api/overview/testing-and-debugging/unit-testing-controllers-in-web-api>

regards
A.G.

On Tue, 8 Mar 2016 20:48:34 +0100, "Tony Johansson"
Post by Tony Johansson
Background: I have a node.js API that use json to send and receive message
from client. I want to use the built in unit test that exist in visual
studio to test the API. I know I can use for exampel postman to test the API
but I need a a quich and reliable way to test 6 different rest API. If I get
some help with this one I can manage the other five myself.
$.ajax({
type: 'GET',
url: 'http://diseserver.net/api/v1/users/1',
dataType: 'json',
async: false,
headers: {
'Authorization': 'Basic ' + btoa('DEFAULT/user:password')
},
success: function(response) {
//your success code
console.log(response);
},
error: function (err) {
//your error code
console.log(err);
}
});
//Tony
Arne Vajhøj
2016-03-14 01:33:39 UTC
Permalink
Post by Tony Johansson
Background: I have a node.js API that use json to send and receive
message from client. I want to use the built in unit test that exist in
visual studio to test the API. I know I can use for exampel postman to
test the API but I need a a quich and reliable way to test 6 different
rest API. If I get some help with this one I can manage the other five
myself.
$.ajax({
type: 'GET',
url: 'http://diseserver.net/api/v1/users/1',
dataType: 'json',
async: false,
headers: {
'Authorization': 'Basic ' + btoa('DEFAULT/user:password')
},
success: function(response) {
//your success code
console.log(response);
},
error: function (err) {
//your error code
console.log(err);
}
});
What about the low-tech solution:
* normal unit test
* WebClient
* manual JSON encode and decode
?

Arne

Continue reading on narkive:
Loading...