Skip to content

Instantly share code, notes, and snippets.

Ed Mays CopperStarSystems

Block or report user

Report or block CopperStarSystems

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View FileReaderTests.cs
using System.Collections.Generic;
using System.IO;
using Moq;
using NUnit.Framework;
using Tdd.FrameworkWrappers.Lib.FrameworkWrappers;
namespace Tdd.FrameworkWrappers.Lib.Tests
{
[TestFixture]
public class FileReaderTests
View FileImpl.cs
using System.IO;
namespace Tdd.FrameworkWrappers.Lib.FrameworkWrappers
{
public class FileImpl : IFile
{
public string ReadAllText(string filePath)
{
return File.ReadAllText(filePath);
}
View IFile.cs
namespace Tdd.FrameworkWrappers.Lib.FrameworkWrappers
{
public interface IFile
{
string ReadAllText(string filePath);
}
}
@CopperStarSystems
CopperStarSystems / FileReader.cs
Created Oct 7, 2019
FileReader.cs with Framework Wrapper
View FileReader.cs
using System;
using Tdd.FrameworkWrappers.Lib.FrameworkWrappers;
namespace Tdd.FrameworkWrappers.Lib
{
public class FileReader
{
private readonly IFile file;
private readonly ILogger logger;
View FileReaderTests.cs
using System.IO;
using NUnit.Framework;
namespace Tdd.FrameworkWrappers.Lib.Tests
{
[TestFixture]
public class FileReaderTests
{
[SetUp]
public void SetUp()
View FileReader.cs
using System.IO;
using System.Net;
namespace Tdd.FrameworkWrappers.Lib
{
public class FileReader
{
public string ReadText(string filePath)
{
return File.ReadAllText(filePath);
@CopperStarSystems
CopperStarSystems / SimpleRecursionExample.cs
Created Mar 2, 2018
A basic example of tree traversal using recursion in C#
View SimpleRecursionExample.cs
// Tree traversal using recursion in C#
//
// We want to traverse the following tree, which may be arbitrarily
// deep/wide. These parameters are not known until runtime.
//
// root
// - branch1
// - leaf1
// - leaf2
// - branch2
@CopperStarSystems
CopperStarSystems / program.cs
Created May 20, 2017
A simple implementation of Insertion Sort in C#
View program.cs
bool showDebugOutput = true;
void Main()
{
var data = new string[] { "A", "R", "L", "S", "T", "N", "E" };
// Tell the user what's going on
Console.WriteLine("Unsorted Data:");
DumpData(data);
Console.WriteLine("Sorting Data...");
@CopperStarSystems
CopperStarSystems / PathWrapper.cs
Created Sep 27, 2016
C# class after refactoring to improve testability
View PathWrapper.cs
// This code implements a wrapper around the static Path class.
// The interface allows us to inject a mock IPath instance at
// test time (for example when testing the MuchEasierToTest class).
public interface IPath{
string GetFileName(string fileName);
}
public class PathImpl : IPath {
public string GetFileName(string fileName){
You can’t perform that action at this time.