Skip to content

Instantly share code, notes, and snippets.

View richashworth's full-sized avatar

Richard Ashworth richashworth

View GitHub Profile
@richashworth
richashworth / LCDFormatterTest.scala
Last active September 19, 2015 11:19
LSUG Dojo September 2015
package lsug
import org.scalatest.FunSuite
/**
* Created by rich on 17/09/15.
*/
class LCDFormatterTest extends FunSuite {
val formatter = new LCDFormatter
@richashworth
richashworth / LCDDigit.scala
Last active September 19, 2015 11:19
LSUG Dojo September 2015
package lsug
/**
* Created by rich on 17/09/15.
*/
class LCDDigit(val firstRow: String, val secondRow: String, val thirdRow: String) {}
object zero extends LCDDigit(
firstRow = "._.",
secondRow = "|.|",
@richashworth
richashworth / LCDFormatter.scala
Last active September 19, 2015 11:19
LSUG Dojo September 2015
package lsug
class LCDFormatter(){
val digitMapping = Map(
0 -> zero,
1 -> one,
2 -> two,
3 -> three,
4 -> four,
5 -> five,
case class LCDDigit(val firstRow: String, val secondRow: String, val thirdRow: String) {
def formatDigit(): Unit = {
productIterator.foreach(i => println(i))
}
}
class LCDDigit(val firstRow: String, val secondRow: String, val thirdRow: String)
@richashworth
richashworth / Footballer.java
Last active September 29, 2015 01:07
Used in Example to Demonstrate Naive Initialisation of Mock Object
package com.richashworth.testingutils.mocking;
public class Footballer {
private String name;
private int age;
private Double salary;
private Integer gamesPlayed;
private Integer goalsScored;
private Boolean isCaptain;
@richashworth
richashworth / DefaultValues.java
Last active September 29, 2015 02:58
Default Values Class
package com.richashworth.testingutils.mocking;
import java.util.HashMap;
import java.util.Map;
public class DefaultValues {
private Map<String, Object> defaultValuesMap;
public DefaultValues() {
@richashworth
richashworth / DataProvider.java
Last active October 1, 2015 19:18
Used as dependency in PowerMock Example
package com.richashworth.powermockexample;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import static com.google.common.io.Files.readLines;
public final class DataProvider {
package com.richashworth.testingutils.mocking;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
public class FootballerTest {
@Test
public void testGetGameGoalsRatio() {
package com.richashworth.testingutils.mocking;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static junit.framework.Assert.assertEquals;
public class FootballerTest2 {