Skip to content

Instantly share code, notes, and snippets.

@rosalindwills
rosalindwills / 3c.cs
Last active August 29, 2015 14:27
3c -- a unit test for Adder()
using NUnit.Framework;
using Moq;
[TestFixture]
public class AdderTests {
[Test]
public void TestThatAdderCorrectlyAddsTwoNumbers()
{
//arrange
var generator = new Mock<IRandomNumberGenerator>();
@rosalindwills
rosalindwills / 3b.cs
Last active August 29, 2015 14:27
3b -- introducing an interface
public class Adder {
private IRandomNumberGenerator _generator;
public Adder(IRandomNumberGenerator generator) {
_generator = generator;
}
public int AddTwoRandomNumbers() {
var firstInt = _generator.Generate();
var secondInt = _generator.Generate();
@rosalindwills
rosalindwills / 3a.cs
Last active August 29, 2015 14:27
3a -- two coupled C# classes
public class Adder {
public int AddTwoRandomNumbers() {
var generator = new RandomNumberGenerator();
var firstInt = generator.Generate();
var secondInt = generator.Generate();
return firstInt + secondInt;
}
}
public class RandomNumberGenerator {
@rosalindwills
rosalindwills / 001c.html
Last active August 29, 2015 14:26
001C -- A page using two external revealer modules
<!DOCTYPE html>
<html>
<head>
<title>001A</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="./clickIncrementModule.js"></script>
<script src="./clickDecrementModule.js"></script>
</head>
<body>
<input type="button" name="my-button" id="my-button" value="CLICK ME" />
@rosalindwills
rosalindwills / 001b.html
Last active August 29, 2015 14:26
001B - A refactoring with the revealer module pattern
<!DOCTYPE html>
<html>
<head>
<title>001A</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<input type="button" name="my-button" id="my-button" value="CLICK ME" />
<p>You have clicked <span id="click-count"></span> times.</p>
<script>
@rosalindwills
rosalindwills / 001a.html
Last active August 29, 2015 14:26
001A - A plain old HTML/Javascript file without design patterns
<!DOCTYPE html>
<html>
<head>
<title>001A</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<input type="button" name="my-button" id="my-button" value="CLICK ME" />
<p>You have clicked <span id="click-count"></span> times.</p>
<script>
@rosalindwills
rosalindwills / index.js
Created October 30, 2012 03:34 — forked from max-mapper/index.js
twitter bot for #sandyaid retweets
if (tweet.text.match(/^RT/)) return
bot.privmsg('#sandyaid', tweet.id_str + " @" + tweet.user.screen_name + ' ' + tweet.text)
@rosalindwills
rosalindwills / index.js
Created October 30, 2012 03:18 — forked from max-mapper/index.js
twitter bot for #sandyaid retweets
var message = tweet.id_str + " @" + tweet.user.screen_name + ' ' + tweet.text