Skip to content

Instantly share code, notes, and snippets.

View GraemeF's full-sized avatar

Graeme Foster GraemeF

View GitHub Profile
@GraemeF
GraemeF / MyFixture.cs
Created February 10, 2011 15:17
Setup with NSubstitute
public class MyFixture
{
private readonly ICloseLogFileCommand _closeCommand = Substitute.For<ICloseLogFileCommand>();
private readonly ILog _log = Substitute.For<ILog>();
public MyFixture()
{
_log.Name.Returns(@"C:\Path\To\File.log");
_log.Count.Returns(42);
@GraemeF
GraemeF / MyFixture.cs
Created February 10, 2011 15:16
Setup with Moq
public class MyFixture
{
private readonly ICloseLogFileCommand _closeCommand = Mock.Of<ICloseLogFileCommand>();
private readonly ILog _log = Mocks.Of<ILog>().
First(x => x.Name == @"C:\Path\To\File.log" &&
x.Count == 42 &&
x.Offset == TimeSpan.FromSeconds(69));
...
}
@GraemeF
GraemeF / gist:820437
Created February 10, 2011 12:25
How can I check that "_log.Offset = newOffset" happened?
Fake.GetCalls(_log).
Single(call => call.Method.Name == "set_Offset").
GetArgument<TimeSpan>(0).
Should().Equal(newOffset);
@GraemeF
GraemeF / Player.cs
Created January 27, 2011 11:50
Runner up hangman player - done in a hurry so UNCLEAN! :P
namespace Graeme
{
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using CodeFest2PlayerRef;
[Export(typeof(ICanPlayCodeFest2))]
public class Player : ICanPlayCodeFest2
@GraemeF
GraemeF / gist:793212
Created January 24, 2011 13:30
ReplaceSpacesWithUnderscores
Sub ReplaceSpacesWithUnderscores()
Dim textSelection As EnvDTE.TextSelection
textSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection)
textSelection.Text = textSelection.Text.Replace(" ", "_")
End Sub
@GraemeF
GraemeF / readable.cs
Created January 14, 2011 21:45 — forked from johnnonolan/readable.cs
Now more readable :P
namespace iDoc.specs.When
{
[Subject("AccountManagement")]
public class CreatingAUserAccount : BaseContext<AccountController>
{
const string EmailAddress = @"[email protected]";
Establish context = () =>
{
model = new RegistrationModel {
@GraemeF
GraemeF / gist:771591
Created January 9, 2011 10:36
Failing test for JsonFx deserializing a List<T>
namespace Tests
{
using System.Collections.Generic;
using System.Linq;
using JsonFx.Json;
using Should.Fluent;
using Xunit;
System.ArgumentException: System.ArgumentException : You must declare a backing field for this property named: _MyProperty
at ReactiveXaml.RxApp.getFieldInfoForProperty[TObj](String prop_name)
at ReactiveXaml.ReactiveNotifyPropertyChangedMixin.ObservableForProperty[TSender,TValue](TSender This, Expression`1 Property, Boolean BeforeChange)
@GraemeF
GraemeF / gist:762627
Created January 2, 2011 16:28
SimpleValue
public abstract class SimpleValue<TValue>
{
private TValue _value;
protected SimpleValue(TValue value)
{
Value = value;
}
private TValue Value
@GraemeF
GraemeF / gist:761145
Created December 31, 2010 16:51
NuGet error
---------------------------
Microsoft Visual Studio
---------------------------
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) The element 'metadata' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd' has invalid child element 'created' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'. List of possible elements expected: 'iconUrl, dependencies, licenseUrl, projectUrl, title, tags, summary, owners' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'.