Skip to content

Instantly share code, notes, and snippets.

View GraemeF's full-sized avatar

Graeme Foster GraemeF

View GitHub Profile
[Fact]
public void Initialize_Always_InitializesParserPresenter()
{
LogPresenter test = BuildTestSubject();
test.Initialize();
_parserPresenter.Received().Initialize();
}
[Fact]
public void Offset_WhenLogOffsetChanges_RaisesPropertyChanged()
{
LogPresenter test = BuildTestSubject();
test.Initialize();
test.AssertThatChangeNotificationIsRaisedBy(x => x.Offset).
When(() => Mock.Get(_log).Raise(x => x.PropertyChanged += null,
new PropertyChangedEventArgs("Offset")));
[Fact]
public void Offset_WhenLogOffsetChanges_RaisesPropertyChanged()
{
LogPresenter test = BuildTestSubject();
test.Initialize();
test.AssertThatChangeNotificationIsRaisedBy(x => x.Offset).
When(() => _log.PropertyChanged += Raise.Event<PropertyChangedEventHandler>(this,
new PropertyChangedEventArgs("Offset")));
[Fact]
public void Offset_WhenLogOffsetChanges_RaisesPropertyChanged()
{
LogPresenter test = BuildTestSubject();
test.Initialize();
test.AssertThatChangeNotificationIsRaisedBy(x => x.Offset).
When(() => _log.PropertyChanged += Raise.With(new PropertyChangedEventArgs("Offset")).Now);
}
namespace Stuff
{
#region Using Directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
using Moq;
private static void UpdatePropertyValue<T, TValue>(Expression<Func<T, TValue>> property, T fake, TValue newValue) where T : class
{
property.Compile()(fake).Returns(newValue);
}
System.IndexOutOfRangeException was unhandled
Message=Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.
Source=System.CoreEx
StackTrace:
Server stack trace:
at System.Buffer.InternalBlockCopy(Array src, Int32 srcOffsetBytes, Array dst, Int32 dstOffsetBytes, Int32 byteCount)
at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.IO.TextWriter.WriteLine(String value)
at System.IO.TextWriter.SyncTextWriter.WriteLine(String value)
at System.Console.WriteLine(String value)
Comma and semicolon
Use the comma (,) and semi-colon (;) characters to indicate nonhierarchical portions
of the URI. The semicolon convention is used to identify matrix parameters:
http://www.example.org/co-ordinates;w=39.001409,z=-84.578201
http://www.example.org/axis;x=0,y=9
These characters are valid in the path and query portions of URIs, but not all code
libraries recognize the comma and semicolon as separators and may require custom
@GraemeF
GraemeF / RequestExtensions.cs
Created July 30, 2011 20:02
Request/Response extensions
public static class RequestExtensions
{
public static string AsString(this RequestStream requestStream)
{
return new StreamReader(requestStream).ReadToEnd();
}
public static XDocument AsXml(this RequestStream requestStream)
{
return XDocument.Load(requestStream);
@GraemeF
GraemeF / RestorePackages.ps1
Created July 31, 2011 11:47 — forked from damianh/RestorePackages.ps1
PowerShell script to restore a projects packages and tools. Requires nuget.exe to be in the project root and commited to source control.
# Tools
.\NuGet.exe i DotCover -s \\myserver\Dev\NuGetPackages -o Tools
.\NuGet.exe i StyleCopCmd -s \\myserver\Dev\NuGetPackages -o Tools
# Dependecies
$packageConfigs = Get-ChildItem . -Recurse | where{$_.Name -eq "packages.config"}
foreach($packageConfig in $packageConfigs){
Write-Host "Restoring" $packageConfig.FullName
nuget i $packageConfig.FullName -o Packages
}