Skip to content

Instantly share code, notes, and snippets.

@torhovland
torhovland / questionnaire.json
Created October 29, 2020 07:55
Questionnaire schema for survey app.
{
"title": "Blazor day at Clarion",
"surveyElements": [
{
"type": "text",
"question": "What's it like working with Blazor?"
},
{
"type": "choice",
"question": "Which group are you in?",
@torhovland
torhovland / gist:3969180
Created October 28, 2012 17:14
InternalsVisibleTo
[assembly: InternalsVisibleTo("BowlingTests")]
@torhovland
torhovland / gist:3969163
Created October 28, 2012 17:06
StrikeBonusTests
[TestMethod]
public void IsInStrikeBonusMode_HasRolledStrikeAnd0_StillInStrikeBonusMode()
{
var game = new BowlingGame();
game.Roll(10);
game.Roll(0);
var bonus = new StrikeBonus(game);
Assert.IsTrue(bonus.IsInStrikeBonusMode);
@torhovland
torhovland / gist:3969135
Created October 28, 2012 16:54
IsInStrikeBonusMode_HasRolledStrikeAnd0_StillInStrikeBonusMode
[TestMethod]
public void IsInStrikeBonusMode_HasRolledStrikeAnd0_StillInStrikeBonusMode()
{
var game = new BowlingGame();
game.Roll(10);
game.Roll(0);
Assert.IsTrue(game.IsInStrikeBonusMode);
}
@torhovland
torhovland / gist:3969039
Created October 28, 2012 16:16
Score_HasRolledStrikeAnd0And1_BothRollsAfterStrikeContributesToBonusYieldingAScoreOf12
[TestMethod]
public void Score_HasRolledStrikeAnd0And1_BothRollsAfterStrikeContributesToBonusYieldingAScoreOf12()
{
var game = new BowlingGame();
game.Roll(10);
game.Roll(0);
game.Roll(1);
Assert.AreEqual(12, game.Score());
}
public void Roll(int pins)
{
rolls.Add(pins);
if (IsInStrikeBonusMode)
bonus.Add(pins);
}
@torhovland
torhovland / gist:3928261
Created October 21, 2012 19:55
FilLager etter
using ImpromptuInterface;
public class FilLager
{
public bool ArkiverFiler { get; set; }
public void RyddKatalog(string sti)
{
foreach (var fil in new DirectoryInfo(sti).GetFiles())
BehandleFil(fil.ActLike<IFil>());
@torhovland
torhovland / gist:3928246
Created October 21, 2012 19:51
FilLagerTestar etter
public interface IFil
{
void MoveTo(string destinasjon);
}
[TestMethod]
public void BehandleFil_ArkiveringErPå_FlyttaTilArkivKatalogen()
{
// Arrange
var lager = new FilLager {ArkiverFiler = true};
@torhovland
torhovland / gist:3928233
Created October 21, 2012 19:48
FilLagerTestar før
[TestMethod]
public void BehandleFil_ArkiveringErPå_FlyttaTilArkivKatalogen()
{
// Arrange
var lager = new FilLager { ArkiverFiler = true };
var fil = Substitute.For<FileInfo>();
// Act
lager.BehandleFil(fil);
@torhovland
torhovland / gist:3928209
Created October 21, 2012 19:39
FilLager før
public class FilLager
{
public bool ArkiverFiler { get; set; }
public void RyddKatalog(string sti)
{
foreach (var fil in new DirectoryInfo(sti).GetFiles())
BehandleFil(fil);
}