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