Skip to content

Instantly share code, notes, and snippets.

View JayBazuzi's full-sized avatar

Jay Bazuzi JayBazuzi

View GitHub Profile
class Point
{
override bool Equals(object other)
{
return this.X == ((Point)other).X && this.Y == ((Point)other).Y;
}
}
new Point(...).Equals(new Bar(...))
@JayBazuzi
JayBazuzi / difficult-to-extract-method.cs
Last active May 11, 2016 20:11
This test passes now. Use Extract Method on the indicated block.Then the test fails.
[TestMethod]
public void TestMethod1()
{
var x = 0;
Task.Run(() =>
{
Thread.Sleep(TimeSpan.FromSeconds(1));
x++;
});
interface IFooStatusReportsListener
{
void Notify(string productName, BarStatus[] barStatuses);
}
class BarClient
{
readonly HttpClient _httpClient = new HttpClient {BaseAddress = new Uri("https://bar.example.com/")};
public async void UpdateShippingStatusReports(string product, IFooStatusReportsListener listener)
static class VerifyThatValueEqualityIsImplementedCorrectly
{
public static void ShouldBeEqual<T>(T item, T equalItem)
where T : IEquatable<T>
{
var equatable = (IEquatable<T>) item;
equatable.Equals(equalItem).Should().BeTrue("IEquatable<>.Equals");
equatable.Equals(item).Should().BeTrue("IEquatable<>.Equals(self)");
equatable.Equals(null).Should().BeFalse("IEquatable<>.Equals(null)");
internal interface IUserSettings
{
Task<bool> GetFlag(string name);
Task SetFlag(string name, bool value);
}
internal abstract class UserSettingsTestsBase
{
protected abstract IUserSettings CreateSubject();
// Tests for A
result = new A(fakeB).F();
// Tests for B
result = new B().G();
// Tests that they work together
subject = new A(new B());
result = subject.F();
class A
{
ctor(B b)
{
this.b = b;
}
public F()
{
// Something that doesn't use B
class B
{
A a = new A();
public F()
{
return a.G(...);
}
}
static bool ShouldAcceptConnectionRequest(bool firstUserHasConnections, bool secondUserHasConnections)
{
return !firstUserHasConnections && !secondUserHasConnections;
}
# START http://boxstarter.org/package/url?https://gist.githubusercontent.com/JayBazuzi/7b22dcb5d0ba3d326a99/raw/24fe6d3946337474ea292227a18e4fd529055a92/BoxStarterADM.ps1
Set-ExecutionPolicy RemoteSigned -Force
Set-WindowsExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
cinst chocolatey
cinst vs2013.4
cinst ncrunch-vs2013
cinst vs2013.4