cleaned up tests

This commit is contained in:
QkoSad
2024-12-09 19:36:12 +02:00
parent 1054889c65
commit 98e689bfc5
5 changed files with 144 additions and 241 deletions
+70 -122
View File
@@ -9,202 +9,150 @@ public class UnitTest1
[TestMethod]
public async Task TestMethodReset()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync("http://localhost:5000/api/reset");
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync("http://localhost:5000/api/reset");
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 200);
}
Assert.AreEqual((int)response.StatusCode, 200);
}
[TestMethod]
public async Task TestMethodGetall1()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/getall?offset=10"
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/getall?offset=10"
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 200);
}
Assert.AreEqual((int)response.StatusCode, 200);
}
[TestMethod]
public async Task TestMethodGetall2()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/getall?offset="
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/getall?offset="
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 400);
}
Assert.AreEqual((int)response.StatusCode, 400);
}
[TestMethod]
public async Task TestMethodGetall3()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/getall?offset=10&from=2020-01-01&to=2024-01-01&orderby=time&order=true"
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/getall?offset=10&from=2020-01-01&to=2024-01-01&orderby=time&order=true"
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 200);
}
Assert.AreEqual((int)response.StatusCode, 200);
}
[TestMethod]
public async Task TestMethodGettopten1()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?from=2000-01-01&to=2024-01-01&filterby=project"
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?from=2000-01-01&to=2024-01-01&filterby=project"
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 200);
}
Assert.AreEqual((int)response.StatusCode, 200);
}
[TestMethod]
public async Task TestMethodGettopten2()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?from=2000-01-01&to=2024-01-01&filterby=user"
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?from=2000-01-01&to=2024-01-01&filterby=user"
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 200);
}
Assert.AreEqual((int)response.StatusCode, 200);
}
[TestMethod]
public async Task TestMethodGettopten3()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?to=2024-01-01&filterby=project"
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?to=2024-01-01&filterby=project"
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 400);
}
Assert.AreEqual((int)response.StatusCode, 400);
}
[TestMethod]
public async Task TestMethodGettopten4()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?from=2000-01-01&filterby=project"
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?from=2000-01-01&filterby=project"
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 400);
}
Assert.AreEqual((int)response.StatusCode, 400);
}
[TestMethod]
public async Task TestMethodGettopten5()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?from=2000-01-01&to=2024-01-01"
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/gettopten?from=2000-01-01&to=2024-01-01"
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 400);
}
Assert.AreEqual((int)response.StatusCode, 400);
}
[TestMethod]
public async Task TestMethodGetuser1()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/getuser?userid=1"
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/getuser?userid=1"
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 200);
}
Assert.AreEqual((int)response.StatusCode, 200);
}
[TestMethod]
public async Task TestMethodGetuser2()
{
using (HttpClient client = new HttpClient())
{
// Make a GET request to a URL
HttpResponseMessage response = await client.GetAsync(
"http://localhost:5000/api/getuser"
);
using HttpClient client = new();
HttpResponseMessage response = await client.GetAsync("http://localhost:5000/api/getuser");
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 400);
}
Assert.AreEqual((int)response.StatusCode, 400);
}
[TestMethod]
public async Task TestMethodRegister1()
{
using (HttpClient client = new())
{
// Make a GET request to a URL
var jsonData =
"{ \"f_name\": \"donna\", \"l_name\": \"cow\", \"mail\": \"tombo@mail.com\", \"password\": \"1234567890\" }";
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
using HttpClient client = new();
// Make a GET request to a URL
var jsonData =
"{ \"f_name\": \"donna\", \"l_name\": \"cow\", \"mail\": \"tombo@mail.com\", \"password\": \"1234567890\" }";
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(
"http://localhost:5000/api/register",
content
);
HttpResponseMessage response = await client.PostAsync(
"http://localhost:5000/api/register",
content
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 200);
}
Assert.AreEqual((int)response.StatusCode, 200);
}
[TestMethod]
public async Task TestMethodLogin()
{
using (HttpClient client = new())
{
// Make a GET request to a URL
var jsonData = "{ \"mail\": \"tombo@mail.com\", \"password\": \"1234567890\" }";
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
using HttpClient client = new();
// Make a GET request to a URL
var jsonData = "{ \"mail\": \"tombo@mail.com\", \"password\": \"1234567890\" }";
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(
"http://localhost:5000/api/login",
content
);
HttpResponseMessage response = await client.PostAsync(
"http://localhost:5000/api/login",
content
);
// Ensure we have a successful response
Assert.AreEqual<Int32>((int)response.StatusCode, 200);
}
Assert.AreEqual((int)response.StatusCode, 200);
}
}