Skip to content

Instantly share code, notes, and snippets.

View isidore's full-sized avatar

Llewellyn Falco isidore

View GitHub Profile
@isidore
isidore / RestCallTests.cs
Last active August 29, 2015 14:02
Executable Query Test of a Rest call
using System;
using System.Net.Http;
using System.Threading.Tasks;
using ApprovalTests;
using ApprovalTests.Reporters;
using ApprovalUtilities.Persistence;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ObjectApproval;
/**
@isidore
isidore / Maintenance.cs
Created June 18, 2014 08:22
Maintenance
[Test]
public void EnsureNoAbandonedFiles()
{
ApprovalMaintenance.VerifyNoAbandonedFiles();
}
[Test]
public void TestInternationalization()
{
AspApprovals.VerifyUrl("http://localhost:1359/OrderForm", ScrubAspViewstate);
}
public static string ScrubAspViewstate(string input)
{
string AspViewState = "<input type=\"hidden\" name=\"__VIEWSTATE\".+/>";
@isidore
isidore / gist:f69cd4bb4d883d98ef62
Created June 18, 2014 08:46
Logger.MarkEntryPoints
public void MyMethod()
{
using (Logger.MarkEntryPoints())
{
if (guardClauss){return ;}
// other logic
}
}
Will produce
public void TestVerifyCircleReferences()
{
StatePrinterApprovals.Verify(anyObject);
}
Can produce output like
Root = <Turtle>, ref: 0
{
Name = "jim"
@isidore
isidore / gist:0463b01cdf92ea38fcf9
Created June 18, 2014 08:57
Executable Query Rest Call Test
[Test]
public void TestGoogleQuery()
{
Approvals.Verify(new GoogleQuery("lolcats"));
}
// Make sure your RestCall extends RestQuery<T> where T is what is returned from the call
class GoogleQuery : RestQuery<GoogleQueryResults>
Approvals.VerifyJson(jsonText);
///Produces
{
"GivenNames": "John",
"FamilyName": "Smith",
"Spouse": "Jill",
"Address": {
"Street": "1 Puddle Lane",
@isidore
isidore / gist:d3bfe729a73f5dd29e6c
Created June 18, 2014 09:04
SerializableTests
SerializableTheory.Verify(anyObject, Assert.AreEqual);
WindowsRegistryAssert.HasDword(keyName: "Console", valueName:"TrimLeadingZeros", expectedValue:0,failureMessage: "You should probably Have This");
[Test]
[TestCase("foo", "bar")]
[TestCase("jack", "jill")]
public void Transformer(string a, string b)
{
using (ApprovalResults.ForScenario(a,b))
{
Approvals.Verify(Transform(a,b));
}
}