Sprint 5 #28

Merged
csimonapastore merged 28 commits from sprints/5 into main 2025-05-28 00:10:39 +02:00
Showing only changes of commit 58b7e75e77 - Show all commits

View File

@@ -5,60 +5,45 @@ using BasicDotnetTemplate.MainProject.Models.Common;
namespace BasicDotnetTemplate.MainProject.Tests;
[TestClass]
public static class FileUtils_Tests
public class FileUtils_Tests
{
[TestMethod]
public static void ConvertFileToObject_NoFilePath()
public void ConvertFileToObject_NoFilePath()
{
try
{
try
{
PermissionsFile? permissionsFile = FileUtils.ConvertFileToObject<PermissionsFile>(String.Empty);
Assert.Fail($"Expected exception instead of response: {permissionsFile}");
}
catch (ArgumentException argumentException)
{
Assert.IsInstanceOfType(argumentException, typeof(ArgumentException));
}
catch (Exception exception)
{
Assert.Fail($"An exception was thrown: {exception}");
}
PermissionsFile? permissionsFile = FileUtils.ConvertFileToObject<PermissionsFile>(String.Empty);
Assert.Fail($"Expected exception instead of response: {permissionsFile}");
}
catch (Exception ex)
catch (ArgumentException argumentException)
{
Console.WriteLine(ex.InnerException);
Assert.Fail($"An exception was thrown: {ex}");
Assert.IsInstanceOfType(argumentException, typeof(ArgumentException));
}
catch (Exception exception)
{
Assert.Fail($"An exception was thrown: {exception}");
}
}
[TestMethod]
public static void ConvertFileToObject_NoFile()
public void ConvertFileToObject_NoFile()
{
try
{
try
{
PermissionsFile? permissionsFile = FileUtils.ConvertFileToObject<PermissionsFile>(System.AppDomain.CurrentDomain.BaseDirectory + "Config/no-permissions.json");
Assert.Fail($"Expected exception instead of response: {permissionsFile}");
}
catch (FileNotFoundException fileNotFoundException)
{
Assert.IsInstanceOfType(fileNotFoundException, typeof(FileNotFoundException));
}
catch (Exception exception)
{
Assert.Fail($"An exception was thrown: {exception}");
}
PermissionsFile? permissionsFile = FileUtils.ConvertFileToObject<PermissionsFile>(System.AppDomain.CurrentDomain.BaseDirectory + "Config/no-permissions.json");
Assert.Fail($"Expected exception instead of response: {permissionsFile}");
}
catch (Exception ex)
catch (FileNotFoundException fileNotFoundException)
{
Console.WriteLine(ex.InnerException);
Assert.Fail($"An exception was thrown: {ex}");
Assert.IsInstanceOfType(fileNotFoundException, typeof(FileNotFoundException));
}
catch (Exception exception)
{
Assert.Fail($"An exception was thrown: {exception}");
}
}
}