
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Tools to support Verbose Assertion in C-Sharp. see: https://github.com/fwhaslam/VerboseCSharp
Complete documentation can be found at: https://github.com/fwhaslam/VerboseCSharp#readme
This package offers some common assertions for tests, and verbose assertions for assertion coverage.
This package contains the following common assertions:
StringAsserts:
CollectionAsserts
GenericCollectionAsserts :: same as CollectionAsserts, but the objects are typed.
The what and why for verbose assertion are explained on the project page in github.
The how is to use this method:
VerboseAsserts.StringsAreEqual( expect, actual );
Let's pretend we have SomeClass with three fields, and a YamlParser to produce a Yaml representation. For our first round, we create the following placeholder test:
[TestMethod]
public void BuildOne_Test() {
// invocation
var result = SomeClass.BuildOne();
// assertion
StringsAreEqual( "", YamlParser.ToYamlString(result) );
}
We run the test. It fails and produces three things: an exception with summary information, a console dump with a detailed report on what is wrong, and a string that can be copied back into the test. Below is the console output.
Message:
Test method VerboseCSharpTests.TestingFramework.SomeObjectAsYamlTest.BuildOne_static threw exception:
VerboseCSharp.Asserts.VerboseAssertionException: Lines Different (added=4) see report for details.
Stack Trace:
VerboseAsserts.StringsAreEqual(String expect, String actual) line 52
SomeObjectWithToDisplayAsYamlTest.BuildOne_Test() line 29
Standard Output:
Actual Value For Copy and Paste [["SomeInt: 4\n"+
"SomeFloat: 0.123\n"+
"SomeString: hi\n"+
""]]
:::: Detailed Line Difference Report ::::
+>>: SomeInt: 4
+>>: SomeFloat: 0.123
+>>: SomeString: hi
+>>:
:::: End of Report ::::
The output starts with the summary: "Lines Different (added=4)" There is an 'Actual Value For Copy', which we can cut and paste back into the test. There is a detailed report showing new lines added with "+>>" symbol.
This looks right, so we copy the 'Actual Value' back into the test for this:
[TestMethod]
public void BuildOne_Test() {
// invocation
var result = SomeClass.BuildOne();
// assertion
StringsAreEqual(
"SomeInt: 4\n"+
"SomeFloat: 0.123\n"+
"SomeString: hi\n"+
"", YamlParser.ToYamlString(result) );
}
Now the test passes.
Any future changes may end up adding, deleting or modifying fields. The changes will be explained in the report. If the changes look good, then copy + paste the 'Actual Value' again. Updating is always this single operation.
Here are some things you may see in the future. Lines removed, added, or modified.
:::: Detailed Line Difference Report ::::
: SomeInt: 4
<<-: SomeFloat: 0.123
+>>: SomeBool: false
old: SomeString: hi
new: SomeString: hiya
:::: End of Report ::::
FAQs
Tools to support Verbose Assertion in C-Sharp. see: https://github.com/fwhaslam/VerboseCSharp
We found that verbosecsharp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.