Quintic
C# Notes

UnitTest for StreamWriter

[Test]
public void Method_Writing_To_Output_Stream()
{
    // arrange
    using (var stream = new MemoryStream())
    using (var writer = new StreamWriter(stream))
    {
        // act
        testObject.SomeMethod(writer);

        // assert
        string actual = Encoding.UTF8.GetString(stream.ToArray());
        Assert.AreEqual("some expected output", actual);
    }
}

Argument Null Test Exception

_param = param ?? throw new ArgumentNullException(nameof(param));

Author: Daddy Raccoon