Skip to content

Instantly share code, notes, and snippets.

gregoryyoung / gist:826331
Created Feb 14, 2011
How to make this an ellipse with 2 chars in it?
View gist:826331
var ellipse = new Ellipse
Fill = Brushes.Red,
StrokeThickness = 2,
Stroke = Brushes.Black,
Height = _glyphSize,
Width = _glyphSize
return ellipse; //its as UIElement
gregoryyoung / gist:827744
Created Feb 15, 2011
set tooltip on a wpf grid?
View gist:827744
thought this would work
ToolTip objTooltip = new ToolTip();
//set background color
objTooltip.Background = new LinearGradientBrush(Color.FromRgb(100, 120, 130),
Color.FromRgb(200, 220, 230), 0);
//Set border color
View WTF
for (short i = 1; i <= projectItem.FileCount; i++)
var filename = projectItem.FileNames[i];
if (filename != null && filename.ToLower() == path) //SERIOUSLY WTF YOU TOLD ME YOU HAVE ONE AND RETURN ME NULL?
return projectItem;
gregoryyoung / WTF
Created Mar 15, 2011
Came out of redgate ...
View WTF
C:\Users\ack\src\AutoTestExtensions>"C:\Program Files\Red Gate\SmartAssembly 6\" /build Obfuscation\Aut
SmartAssembly v6.0.0.513
Copyright © Red Gate Software 2005-2011
Because I wanna ask you about your girlfriend. I must know who she is, or you would've told me her name.
System.NullReferenceException : Object reference not set to an instance of an object.
gregoryyoung / ProbabilityKata2
Created Jun 10, 2011
Probability Kata part 2
View ProbabilityKata2
OK so now you have implemented the kata. Your tests should look something like this:
We can say that the tests define the object "in a calculus of itself". They are not state based tests, they define how the behaviours of the object interact with each other.
To see the real value of this let's introduce some change ... I hear real system's do this occasionally. Because this is a high performance system decimal math is too slow. You now need to use floats instead.
Need help on floating point math? Check out:
You will need to use a non-exact equality... How will this change your code?
gregoryyoung / ProbabilityKata
Created Jun 10, 2011
Greg Young's Probability Kata
View ProbabilityKata
Value objects are an important concept in DDD. This kata is made both to learn value objects and to learn better ways of testing.
Write a probability value object. It should contain the following methods:
Probability CombinedWith(Probability)
Probability InverseOf()
Probability Either(Probability)
if you forget your probability math:
Either:P(A) + P(B) - P(A)P(B)
CombinedWith: P(A)P(B)
gregoryyoung / Sample.cs
Created Jul 4, 2011
Sample Test From Simple.Testing
View Sample.cs
//This is a sample specification.
public SutSpecification<Depositor> when_withdrawing_money_from_empty_account = new SutSpecification<Depositor>
On = () => new Depositor(13),
When = depositor => depositor.Withdraw(50.00m),
Expect =
depositor => depositor.Balance > 0.01m,
depositor => depositor.AccountIsOpen
View query spec.cs
* A query specification is intended to be used on a method with a return value. The
* general idea is that the Given() will build the SUT. The when() will call the method
* returning the methods return value. The expectations are then on the returned value.
* You may wonder how you can assert on the sut after the call. You can't using this
* template. This is by design, see CQS by Bertrand Meyer, you should not mutate state
* of the object when querying. If you want to break this rule use a more open template
* and specialize it.
gregoryyoung / dep.cs
Created Jul 4, 2011
depositor specification
View dep.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Simple.Testing.Framework;
namespace Simple.Testing.Example
View fail.cs
* Sometimes the point of a specification is to show that a given scenario fails.
* A failing specification is similar to a SUT specification. It will return the SUT
* from its given method. The SUT will then be passed to the when() method where some
* action will happen. It is expected that this action will throw an exception.
* The exception is then passed to the expectations.
* note: if you are doing more complex operations other templates can be used with
You can’t perform that action at this time.