Skip to content
Snippets Groups Projects
Commit bf0ac462 authored by Jakub Konvička's avatar Jakub Konvička
Browse files

feat: Add test cases

parent 10cfab91
1 merge request!15merge: develop into main
Pipeline #912 passed with stages
in 6 minutes and 27 seconds
......@@ -144,8 +144,8 @@ public class CppClassDiagramVisitor : CPP14ParserBaseVisitor<object>
string compositionPattern = @"^(?:std::)?(?:vector<)?(\w+)>?$";
// Check if the property type matches aggregation or composition
Match aggregationMatch = Regex.Match(atribute.Type, aggregationPattern, RegexOptions.NonBacktracking);
Match compositionMatch = Regex.Match(atribute.Type, compositionPattern, RegexOptions.NonBacktracking);
Match aggregationMatch = Regex.Match(atribute.Type, aggregationPattern, RegexOptions.Compiled);
Match compositionMatch = Regex.Match(atribute.Type, compositionPattern, RegexOptions.Compiled);
int groupMatch = 1;
if (aggregationMatch.Success && !string.IsNullOrEmpty(aggregationMatch.Groups[groupMatch].Value))
{
......
......@@ -11,13 +11,48 @@ namespace MyNamespace {
std::cout << "Name: " << name << ", Age: " << age << std::endl;
}
};
class Student : public Person
{
private:
std::string login;
void changeLogin(std::string newLogin) {
login = newLogin;
return;
}
};
class Teacher : public Person
{
public:
//vector of students
std::vector<Student> students;
};
}
int main() {
MyNamespace::Person person1;
MyNamespace::Student person1;
person1.name = "John";
person1.age = 25;
person1.displayInfo();
if(person1.age > 18) {
std::cout << "Student is an adult" << std::endl;
int i = 0;
while(i < 10) {
std::cout << "i = " << i << std::endl;
i++;
}
} else {
std::cout << "Student is not an adult" << std::endl;
if(person1.age < 10) {
std::cout << "Student is a child" << std::endl;
} else {
std::cout << "Student is not a child" << std::endl;
}
}
return 0;
}
\ No newline at end of file
using System.Text;
using Database;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NUnit.Framework.Constraints;
using WebAPI.Controllers;
using WebAPI.DTO;
using WebAPI.DTO.External;
......@@ -257,7 +255,7 @@ public class WebApiTests
[TestCase(true)]
[TestCase(false)]
public void UploadCodeAndTransform(bool getValidToken)
public void UploadCodeListTransformRemoveList(bool getValidToken)
{
string token = string.Empty;
if (getValidToken)
......@@ -293,6 +291,9 @@ public class WebApiTests
ListOne(true, 1, true);
ConvertToActivityDiagram(true, 1, true);
ConvertToClassDiagram(true, 1, true);
RemoveCode(true, 1, true);
ListAll(true, 0);
ListOne(true, 1, false);
}
else
{
......@@ -445,7 +446,57 @@ public class WebApiTests
}
#endregion
#region Remove Code Tests
[TestCase(true, -1, false)]
[TestCase(false, -1, false)]
public void RemoveCode(bool getValidToken, int id, bool codeExists)
{
string token = string.Empty;
if (getValidToken)
{
token = GetToken(TestUserAuthenticationProcedure());
}
else
{
token = "WrongToken";
}
var path = Path.Join(Directory.GetCurrentDirectory(), "users.json");
ApiController apiController = new ApiController(null, null, path);
var model = new RemoveCodeModel()
{
Id = id,
Token = token
};
var result = apiController.RemoveCode(model);
if (getValidToken)
{
if (codeExists)
{
Assert.IsTrue(result is OkObjectResult);
var okResult = result as OkObjectResult;
Assert.IsTrue(okResult.Value is string);
Assert.IsTrue(okResult.Value as string == "Code removed");
}
else
{
Assert.IsTrue(result is NotFoundObjectResult);
var okResult = result as NotFoundObjectResult;
Assert.IsTrue(okResult.Value is string);
Assert.IsTrue(okResult.Value as string == "Code does not exist");
}
}
else
{
Assert.IsTrue(result is BadRequestObjectResult);
var okResult = result as BadRequestObjectResult;
Assert.IsTrue(okResult.Value is string);
Assert.IsTrue(okResult.Value as string == "Invalid token");
}
}
#endregion
private string GetToken(string authResult)
{
//parse guid from authResult
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment