This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// DON'T USE ASYNC | |
[TestMethod] | |
public async Task TestHttp() | |
{ | |
var response = await new HttpClient().GetAsync("http://www.google.com/"); | |
Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); | |
} | |
/// Prefer to use .Result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void TestAsyncExceptions() | |
{ | |
int a = 0; | |
AsyncApprovals.VerifyException(async () => 1/a); | |
} | |
// NOTE: If async is creating inconsient stack traces, consider a scrubber | |
AsyncApprovals.VerifyException(async () => 1/a, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binding myBinding = new Binding(TestViewModel.MyPropertyPropertyName); | |
WpfBindingsAssert.BindsWithoutError(viewModel, () => | |
{ | |
// ... create control and initalize bindings | |
// (This will happen once the reporting and logging has been setup) | |
var textBox = new TextBox(); | |
textBox.SetBinding(TextBox.TextProperty, myBinding); | |
return textBox; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.xp2015.smells; | |
import java.math.BigDecimal; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.Map; | |
import org.apache.commons.lang.StringUtils; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.spun.triangles.test; | |
import static org.junit.Assert.assertEquals; | |
import java.util.Random; | |
import org.junit.Test; | |
/** | |
* Theory based kata |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string result; | |
result = Win(); | |
if (result != null) | |
{ | |
return result; | |
} | |
result = Advantage(); | |
if (result != null) | |
{ | |
return result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string result; | |
result = Win(); | |
result = Advantage(result); | |
result = ScoreNormal(result); | |
result = ScorePerson1(result); | |
result = ScorePerson2(result); | |
result = ScoreTie(result); | |
return result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string Advantage(string previousResult) | |
{ | |
if (previousResult != null) | |
{ | |
return previousResult; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return new Func<string>[] | |
{ | |
Win, | |
Advantage, | |
ScoreNormal, | |
ScorePerson1, | |
ScorePerson2, | |
ScoreTie | |
}.FirstNonNull(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IEnumerable<string> ProcessScores() | |
{ | |
yield return Win(); | |
yield return Advantage(); | |
yield return ScoreNormal(); | |
yield return person2.ScoreOpponentHasntScored(person1); | |
yield return person1.ScoreOpponentHasntScored(person2); | |
yield return ScoreTie(); | |
throw new Exception("Unreachable code was executed"); | |
} |