Skip to content

Instantly share code, notes, and snippets.

@stiano
stiano / Extensions.cs
Last active April 3, 2021 12:13
NUnit testing dependencies
public static class TestExtensions
{
private static readonly JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions()
{
WriteIndented = true,
};
public static void ToConsole(this object? o)
{
if (o is null)
@stiano
stiano / Roslyn-CodeGeneration-WithDebugging-Tests.cs
Created August 21, 2018 19:29
Debugging Roslyn Generated Code
public class CodeGenTests
{
[NUnit.Framework.Test]
public void ShouldDebugSources()
{
var code =
@"namespace Debuggable
{
public class HelloWorld
{
@stiano
stiano / ActiveDirectoryService.cs
Created January 16, 2018 11:32
ActiveDirectoryService-GetUserByUserName
public class ActiveDirectoryService
{
private readonly NetworkCredential credentials;
public ActiveDirectoryService(NetworkCredential credentials)
{
this.credentials = credentials;
}
public GetUserByResponse GetUserBy(string username)
@stiano
stiano / excel-based-unit-tests.cs
Last active March 24, 2017 12:13
Simple way of generating test data in an Excel file
// Dependencies: NUnit
// Remember: copy excel file to output directory
public class ExcelBasedTests
{
[Test, TestCaseSource(typeof(TestData), nameof(TestData.GetPeriodStartDateCases))]
public void RegisterUserTest(PeriodStartDateModel input)
{
input.ColumnA.ShouldNotBeNullOrEmpty();
input.ColumnB.ShouldNotBeNullOrEmpty();