Minor changes && Add tests

Made a seperate method for writing the database access time files
Added tests for checkIfDatabasesWereModified
This commit is contained in:
2023-06-18 17:24:56 +02:00
parent 51aca7a2c2
commit 1994e92e9e
2 changed files with 50 additions and 33 deletions

View File

@ -0,0 +1,31 @@
using Pacserver.Utils;
namespace Pacserver.Tests;
public class checkIfDatabasesWereModifiedTest {
[Fact]
public void checkIfDatabasesWereModified_throwsExceptionIfNoValidModeIsGiven() {
// Arrange
PacserverUtils utils = new PacserverUtils();
utils.readPacmanConfig();
// Act
Action act = () => utils.checkIfDatabasesWereModified("test", "/tmp/test.txt");
// Assert
act.Should().Throw<ArgumentException>().WithMessage("No valid mode was given. Valid modes are before and after");
}
[Fact]
public void checkIfDatabasesWereModified_throwsNoExceptionIfValidModeIsGiven() {
// Arrange
PacserverUtils utils = new PacserverUtils();
utils.readPacmanConfig();
// Act
Action act = () => utils.checkIfDatabasesWereModified("before", "/tmp/test.txt");
// Assert
act.Should().NotThrow();
}
}