Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Convert Classic Assert to Constraint Model #1065

Merged
merged 19 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void MyComponent_Validate_ShouldThrowNotSupportedExceptionIfTestingIsNotA
catch (NotSupportedException ex)
{
// Assert
Assert.AreEqual("We can't go on together. It's not me, it's you.", ex.Message);
Assert.That(ex.Message, Is.EqualTo("We can't go on together. It's not me, it's you."));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void Operations_ShouldThrowArgumentNullExceptionIfPathIsNull(Action<IDire

// Assert
var exception = Assert.Throws<ArgumentNullException>(wrapped);
Assert.AreEqual("path", exception.ParamName);
Assert.That(exception.ParamName, Is.EqualTo("path"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void MockDirectoryInfoFactory_Wrap_WithNull_ShouldReturnNull()

var result = fileSystem.DirectoryInfo.Wrap(null);

Assert.IsNull(result);
Assert.That(result, Is.Null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void MockDirectoryInfo_ResolveLinkTarget_ShouldReturnPathOfTargetLink()

var result = fileSystem.DirectoryInfo.New("foo").ResolveLinkTarget(false);

Assert.AreEqual("bar", result.Name);
Assert.That(result.Name, Is.EqualTo("bar"));
}

[Test]
Expand All @@ -36,7 +36,7 @@ public void MockDirectoryInfo_ResolveLinkTarget_WithFinalTarget_ShouldReturnPath

var result = fileSystem.DirectoryInfo.New("foo1").ResolveLinkTarget(true);

Assert.AreEqual("bar", result.Name);
Assert.That(result.Name, Is.EqualTo("bar"));
}

[Test]
Expand All @@ -49,7 +49,7 @@ public void MockDirectoryInfo_ResolveLinkTarget_WithoutFinalTarget_ShouldReturnF

var result = fileSystem.DirectoryInfo.New("foo1").ResolveLinkTarget(false);

Assert.AreEqual("foo", result.Name);
Assert.That(result.Name, Is.EqualTo("foo"));
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
}

[TestCaseSource("MockDirectoryInfo_GetExtension_Cases")]
[TestCaseSource(nameof(MockDirectoryInfo_GetExtension_Cases))]
public void MockDirectoryInfo_GetExtension_ShouldReturnEmptyString(string directoryPath)
{
// Arrange
Expand All @@ -30,7 +30,7 @@
var result = directoryInfo.Extension;

// Assert
Assert.AreEqual(string.Empty, result);
Assert.That(result, Is.Empty);
}

public static IEnumerable<object[]> MockDirectoryInfo_Exists_Cases
Expand All @@ -42,7 +42,7 @@
}
}

[TestCaseSource("MockDirectoryInfo_Exists_Cases")]
[TestCaseSource(nameof(MockDirectoryInfo_Exists_Cases))]
public void MockDirectoryInfo_Exists(string path, bool expected)
{
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
Expand Down Expand Up @@ -106,7 +106,7 @@
var files = directoryInfo.GetFiles();

// Assert
Assert.AreEqual(fileName, files[0].FullName);
Assert.That(files[0].FullName, Is.EqualTo(fileName));
}

[Test]
Expand All @@ -129,7 +129,7 @@
var files = directoryInfo.GetFiles();

// Assert
Assert.AreEqual(fileName, files[0].FullName);
Assert.That(files[0].FullName, Is.EqualTo(fileName));
}

[Test]
Expand Down Expand Up @@ -263,7 +263,7 @@
var result = directoryInfo.Parent;

// Assert
Assert.AreEqual(XFS.Path(@"c:\a\b"), result.FullName);
Assert.That(result.FullName, Is.EqualTo(XFS.Path(@"c:\a\b")));
}

[Test]
Expand All @@ -287,7 +287,7 @@
var directoryInfo = new MockDirectoryInfo(fileSystem, XFS.Path(@"c:\temp\folder"));

// Assert
Assert.AreEqual(new[] { "b.txt", "c.txt" }, directoryInfo.EnumerateFiles().ToList().Select(x => x.Name).ToArray());
Assert.That(directoryInfo.EnumerateFiles().ToList().Select(x => x.Name).ToArray(), Is.EqualTo(new[] { "b.txt", "c.txt" }));
}

[Test]
Expand All @@ -309,7 +309,7 @@
var directories = directoryInfo.EnumerateDirectories().Select(a => a.Name).ToArray();

// Assert
Assert.AreEqual(new[] { "b", "c" }, directories);
Assert.That(directories, Is.EqualTo(new[] { "b", "c" }));
}

[TestCase(@"\\unc\folder", @"\\unc\folder")]
Expand All @@ -327,7 +327,7 @@
var actualFullName = directoryInfo.FullName;

// Assert
Assert.AreEqual(expectedFullName, actualFullName);
Assert.That(actualFullName, Is.EqualTo(expectedFullName));
}

[TestCase(@"c:\temp\\folder", @"c:\temp\folder")]
Expand All @@ -345,7 +345,7 @@
var actualFullName = directoryInfo.FullName;

// Assert
Assert.AreEqual(expectedFullName, actualFullName);
Assert.That(actualFullName, Is.EqualTo(expectedFullName));
}

[TestCase(@"c:\temp\folder ", @"c:\temp\folder")]
Expand All @@ -360,7 +360,7 @@
var actualFullName = directoryInfo.FullName;

// Assert
Assert.AreEqual(expectedFullName, actualFullName);
Assert.That(actualFullName, Is.EqualTo(expectedFullName));
}

[Test]
Expand All @@ -377,7 +377,7 @@
directoryInfo.MoveTo(destination);

// Assert
Assert.AreEqual(destination, directoryInfo.FullName);
Assert.That(directoryInfo.FullName, Is.EqualTo(destination));
}

[TestCase(@"c:\temp\\folder ", @"folder")]
Expand All @@ -392,7 +392,7 @@
var actualName = directoryInfo.Name;

// Assert
Assert.AreEqual(expectedName, actualName);
Assert.That(actualName, Is.EqualTo(expectedName));
}

[TestCase(@"c:\", @"c:\")]
Expand All @@ -407,7 +407,7 @@
var actualName = directoryInfo.Name;

// Assert
Assert.AreEqual(expectedName, actualName);
Assert.That(actualName, Is.EqualTo(expectedName));
}

[Test]
Expand Down Expand Up @@ -462,7 +462,7 @@
var mockDirectoryInfo = new MockDirectoryInfo(new MockFileSystem(), directoryPath);

// Assert
Assert.AreEqual(directoryPath, mockDirectoryInfo.ToString());
Assert.That(mockDirectoryInfo.ToString(), Is.EqualTo(directoryPath));
}

[Test]
Expand All @@ -477,7 +477,7 @@
fileSystem.AddDirectory(path);

// Assert
Assert.IsFalse(directoryInfo.Exists);
Assert.That(directoryInfo.Exists, Is.False);
}

[Test]
Expand All @@ -493,7 +493,7 @@
directoryInfo.Refresh();

// Assert
Assert.IsTrue(directoryInfo.Exists);
Assert.That(directoryInfo.Exists, Is.True);
}

[Test]
Expand All @@ -507,7 +507,7 @@
directoryInfo.Create();

// Assert
Assert.IsTrue(directoryInfo.Exists);
Assert.That(directoryInfo.Exists, Is.True);
}

[Test, WindowsOnly(WindowsSpecifics.AccessControlLists)]
Expand All @@ -518,10 +518,10 @@
var directoryInfo = fileSystem.DirectoryInfo.New(XFS.Path(@"c:\abc"));

// Act
directoryInfo.Create(new DirectorySecurity());

Check warning on line 521 in tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryInfoTests.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

This call site is reachable on all platforms. 'DirectorySecurity' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 521 in tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryInfoTests.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

This call site is reachable on all platforms. 'DirectoryInfoAclExtensions.Create(IDirectoryInfo, DirectorySecurity)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 521 in tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryInfoTests.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

This call site is reachable on all platforms. 'DirectorySecurity' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 521 in tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryInfoTests.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

This call site is reachable on all platforms. 'DirectoryInfoAclExtensions.Create(IDirectoryInfo, DirectorySecurity)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 521 in tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryInfoTests.cs

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

This call site is reachable on all platforms. 'DirectoryInfoAclExtensions.Create(IDirectoryInfo, DirectorySecurity)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 521 in tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryInfoTests.cs

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

This call site is reachable on all platforms. 'DirectorySecurity' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

// Assert
Assert.IsTrue(directoryInfo.Exists);
Assert.That(directoryInfo.Exists, Is.True);
}

[Test]
Expand All @@ -535,7 +535,7 @@
directoryInfo.Delete();

// Assert
Assert.IsFalse(directoryInfo.Exists);
Assert.That(directoryInfo.Exists, Is.False);
}

[Test]
Expand All @@ -549,7 +549,7 @@
directoryInfo.Delete(true);

// Assert
Assert.IsFalse(directoryInfo.Exists);
Assert.That(directoryInfo.Exists, Is.False);
}

[Test]
Expand All @@ -563,7 +563,7 @@
directoryInfo.MoveTo(XFS.Path(@"c:\abc2"));

// Assert
Assert.IsTrue(directoryInfo.Exists);
Assert.That(directoryInfo.Exists, Is.True);
}

[Test]
Expand All @@ -582,7 +582,7 @@
directoryInfo.LastAccessTime = lastAccessTime;

// Assert
Assert.AreEqual(lastAccessTime, directoryInfo.LastAccessTime);
Assert.That(directoryInfo.LastAccessTime, Is.EqualTo(lastAccessTime));
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public void MockDirectory_CreateSymbolicLink_ShouldReturnFileSystemInfo()
IFileSystemInfo fileSystemInfo = fileSystem.Directory.CreateSymbolicLink(path, pathToTarget);

// Assert
Assert.AreEqual(path, fileSystemInfo.FullName);
Assert.AreEqual(pathToTarget, fileSystemInfo.LinkTarget);
Assert.That(fileSystemInfo.FullName, Is.EqualTo(path));
Assert.That(fileSystemInfo.LinkTarget, Is.EqualTo(pathToTarget));
}

[Test]
Expand All @@ -41,8 +41,8 @@ public void MockDirectory_CreateSymbolicLink_ShouldSucceedFromDirectoryInfo()
IDirectoryInfo directoryInfo = fileSystem.DirectoryInfo.New(path);

// Assert
Assert.AreEqual(path, directoryInfo.FullName);
Assert.AreEqual(pathToTarget, directoryInfo.LinkTarget);
Assert.That(directoryInfo.FullName, Is.EqualTo(path));
Assert.That(directoryInfo.LinkTarget, Is.EqualTo(pathToTarget));
}

[Test]
Expand Down Expand Up @@ -195,7 +195,7 @@ public void MockDirectory_CreateSymbolicLink_ShouldNotFailIfTargetDoesNotExist()
var fileSystemInfo = fileSystem.Directory.CreateSymbolicLink(path, pathToTarget);

// Assert
Assert.IsTrue(fileSystemInfo.Exists);
Assert.That(fileSystemInfo.Exists, Is.True);
}

[Test]
Expand All @@ -209,7 +209,7 @@ public void MockDirectory_CreateSymbolicLink_ShouldSetReparsePointAttribute()
fileSystem.Directory.CreateSymbolicLink(path, pathToTarget);

var attributes = fileSystem.DirectoryInfo.New(path).Attributes;
Assert.IsTrue(attributes.HasFlag(FileAttributes.ReparsePoint));
Assert.That(attributes.HasFlag(FileAttributes.ReparsePoint), Is.True);
}

[Test]
Expand All @@ -221,7 +221,7 @@ public void MockDirectory_ResolveLinkTarget_ShouldReturnPathOfTargetLink()

var result = fileSystem.Directory.ResolveLinkTarget("foo", false);

Assert.AreEqual("bar", result.Name);
Assert.That(result.Name, Is.EqualTo("bar"));
}

[Test]
Expand All @@ -242,7 +242,7 @@ public void MockDirectory_ResolveLinkTarget_WithFinalTarget_ShouldReturnPathOfTa

var result = fileSystem.Directory.ResolveLinkTarget(previousPath, true);

Assert.AreEqual("bar", result.Name);
Assert.That(result.Name, Is.EqualTo("bar"));
}

[Test]
Expand Down Expand Up @@ -275,7 +275,7 @@ public void MockDirectory_ResolveLinkTarget_WithoutFinalTarget_ShouldReturnFirst

var result = fileSystem.Directory.ResolveLinkTarget("foo1", false);

Assert.AreEqual("foo", result.Name);
Assert.That(result.Name, Is.EqualTo("foo"));
}

[Test]
Expand Down
Loading