Skip to content

Instantly share code, notes, and snippets.

View ShawnMcCool's full-sized avatar
💭
reinventing the wheel

Shawn McCool ShawnMcCool

💭
reinventing the wheel
View GitHub Profile
@ShawnMcCool
ShawnMcCool / 0---Overview.md
Last active October 7, 2022 07:37
Testing at Boundaries with Test Doubles and Fixtures: A Vertical Slice

Overview

In this gist, I attempt to communicate techniques for defining explicit boundaries over naturally occuring boundaries (in this case, the boundary between domain and service/data layers) to empower both testing and to improve comprehensibility of the system.

In my view, testing and application code are one-and-the-same and should evolve together. Testing code should not be an after-thought. I believe that haphazardly designing application code and test code leads to lead-time penalities.

If you'd like to reply, consider replying to this twitter thread. Additionally, I am available on Twitter @ShawnMcCool.

Note: I acknowledge that no techniques are right for everyone. But I have a long history with these techniques and I found them quite adequate for large and small-scale systems.

@ShawnMcCool
ShawnMcCool / new-test-framework-requirements.md
Last active June 30, 2022 09:07
New Test Framework Requirements

Core Principles:

  • tests are an executable story
    • most production similar implementation possible
    • communicate story along with implementation
  • no inheritance
  • no unnecessary features like data providers
  • give full control over error and success reporting
    • assertions can have both success and error messages
  • assertions can arbitrarily have added context such as 'array diff'
@ShawnMcCool
ShawnMcCool / 0-readme.md
Last active April 23, 2021 12:07
Are named parameters a risk to all that we hold near and dear? News at 11.

This tests behavior on the process "CreateConferenceTicketsForWebinarCustomers".

It's possible to create a working test that looks like the "minimum possible" example. But the "actual" example has additional information that supplements the test. The null parameter with default values pattern is not new.

In this case, the named parameters improve the comprehensibility of the tests.

This is one of hundreds of tests that I've used this technique for. When testing various paths through the same process, being able to swap values in then given/when/then steps can be really beautiful.

@ShawnMcCool
ShawnMcCool / KalmanFilter.cs
Created September 10, 2018 12:13 — forked from daniellemccool/KalmanFilter.cs
KalmanFilter
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Tabi.DataObjects;
namespace Tabi.Logic
{
public class KalmanLatLong : PositionEntry // Implementation taken from: https://stackoverflow.com/questions/1134579/smooth-gps-data/15657798#15657798
{
@ShawnMcCool
ShawnMcCool / .zshrc
Last active July 19, 2017 13:58
Moves the most recently modified file from the source directory to the destination directory.
alias mvltr="~/scripts/mvltr.sh"
alias ltr="ls -ltr"
@ShawnMcCool
ShawnMcCool / A Simple PHP Postmark Library.md
Last active February 21, 2017 12:18
Simple postmark email send / batching.

Examples:

public function sendSingleExample() {
    (new SendMailViaAPI('<postmark-server-token>'))->single(
        new Mail('sender name', 'sender email', 'recipient email', 'hello from exampletown', '<strong>this is bold</strong> this is not.')
    );
}

public function sendBatchExample() {
@ShawnMcCool
ShawnMcCool / lowresvga.sh
Last active June 23, 2016 10:46
XRANDR Scripts for Dutch PHP Conference for 16:9 laptops
#!/bin/bash
# "./lowresvga.sh" to enable 1024x768
# "./lowresvga.sh off" to return
# This was made for a Thinkpad T450s, substitute your devices.
if [ "$1" = "off" ] ; then
echo "disabling"
xrandr --output DP2 --off
xrandr --output eDP1 --mode 1920x1080
<?php
# Discussion about idiomatic ActiveRecord usage
## Please help me to determine the idiomatic approach for creating a member and attaching an invoice ONLY IF the member doesn't already have 5 invoices.
class Member extends Eloquent {
}
$member = Member::create([
@ShawnMcCool
ShawnMcCool / gist:16cac102e06d02365403
Created June 17, 2015 07:52
A Sequence Collecton for C#
using System.Collections.Generic;
using Infrastructure;
using NUnit.Framework;
namespace Collections {
[TestFixture] public class SeqTests {
[Test]
public void can_access_the_head() {
var seq = new Seq<DomainEvent>();
var first = new TestEvent();
@ShawnMcCool
ShawnMcCool / php-visibility
Last active August 29, 2015 14:17
PHP Visibility by Example
<?php
namespace PrivateExample {
class Animal {
private $innermostFeelings = "HUNGER";
public function __construct() {
echo "Animal feels $this->innermostFeelings\n";
}
public function empathy(Animal $other) {