Skip to content

Instantly share code, notes, and snippets.

View JayBazuzi's full-sized avatar

Jay Bazuzi JayBazuzi

View GitHub Profile
class B
{
A a = new A();
public F()
{
return a.G(...);
}
}
class A
{
ctor(B b)
{
this.b = b;
}
public F()
{
// Something that doesn't use B
// 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();
internal interface IUserSettings
{
Task<bool> GetFlag(string name);
Task SetFlag(string name, bool value);
}
internal abstract class UserSettingsTestsBase
{
protected abstract IUserSettings CreateSubject();
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)");
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)
@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++;
});
class Point
{
override bool Equals(object other)
{
return this.X == ((Point)other).X && this.Y == ((Point)other).Y;
}
}
new Point(...).Equals(new Bar(...))
class Point
{
override bool Equals(object other)
{
if (other.GetType() != this.GetType()) return false;
return this.X == ((Point)other).X && this.Y == ((Point)other).Y;
}
}
class Point
{
public static bool operator==(Point left, Point right)
{
return left.Equals(right);
}
}