Skip to content

Commit

Permalink
Unite Testing Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dbretty committed Sep 26, 2024
1 parent ab4b4cb commit 92c5efb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
39 changes: 39 additions & 0 deletions PROFiLiX.Common.Tests/File/FilesAndFoldersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ public void DeleteFolderAsync_WithValidData_ShouldSucceed()
Assert.That(response, Is.True);
}

/// <summary>
/// Checks that DeleteFileAsync with with Valid data succeeds.
/// </summary>
[Test]
public void DirectorySizeAsync_WithValidData_ShouldSucceed()
{
// Arrange
var mockILogger = new Mock<ILogger>();
var mockFilesAndFolders = new FilesAndFolders(mockILogger.Object);
string folderName = "C:\\windows\\temp";
Directory.CreateDirectory(folderName);
Thread.Sleep(2000);
DirectoryInfo di = new DirectoryInfo(folderName);

// Act
var response = mockFilesAndFolders.DirectorySizeAsync(di).Result;

// Assert
Assert.That(response, Is.GreaterThan(0));
}

/// <summary>
/// Checks that FormatFileSize Valid data succeeds.
/// </summary>
Expand Down Expand Up @@ -301,6 +322,24 @@ public void CreateDirectory_WithInvalidFolderName_ShouldThrowArgumentNullExcepti
Assert.Throws<ArgumentNullException>(() => mockFilesAndFolders.CreateDirectory(rootFolder));
}

/// <summary>
/// Checks that CheckDirectory with invalid data errors.
/// </summary>
[Test]
public void DirectorySizeAsync_WithInvalidFolderName_ShouldThrowArgumentNullException()
{
// Arrange
var mockILogger = new Mock<ILogger>();
var mockFilesAndFolders = new FilesAndFolders(mockILogger.Object);
DirectoryInfo? directoryInfo = null;

// Act + Assert
Assert.Throws<AggregateException>(() =>
{
long result = mockFilesAndFolders.DirectorySizeAsync(directoryInfo).Result;

Check warning on line 339 in PROFiLiX.Common.Tests/File/FilesAndFoldersTests.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'directory' in 'Task<long> FilesAndFolders.DirectorySizeAsync(DirectoryInfo directory)'.
});
}

/// <summary>
/// Checks that CheckDirectory with invalid data errors.
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions PROFiLiX.Common.Tests/Registry/RegistryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace PROFiLiX.Common.Tests.Registry
using PROFiLiX.Common.Registry;
using PROFiLiX.Common.Registry.Exceptions;
using PROFiLiX.Common.Registry.Model;
using System.IO;

Check warning on line 15 in PROFiLiX.Common.Tests/Registry/RegistryTests.cs

View workflow job for this annotation

GitHub Actions / build

Using directive for 'System.IO' should appear before directive for 'PROFiLiX.Common.Registry.Model' (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1208.md)

/// <summary>
/// Class to do Registry unit tests.
Expand Down Expand Up @@ -654,6 +655,18 @@ public void InvalidKeyException_WithMessageAndInnerException_ShouldThrowExceptio
}
}

/// <summary>
/// Test method to ensure InvalidValueException with message throws correctly.
/// </summary>
[Test]
public void InvalidValueException_WithDefault_ShouldThrowException()
{
var result = new InvalidValueException();
var message = result.Message;

StringAssert.Contains("InvalidValueException", message);
}

/// <summary>
/// Test method to ensure InvalidValueException with message throws correctly.
/// </summary>
Expand Down

0 comments on commit 92c5efb

Please sign in to comment.