Skip to content

Instantly share code, notes, and snippets.

View JakeGinnivan's full-sized avatar
:shipit:

Jake Ginnivan JakeGinnivan

:shipit:
View GitHub Profile
public async void SaveDocument()
{
if (IsWorking) return;
var doc = MDI.ActiveItem as DocumentViewModel;
if (doc != null)
{
using (DoingWork(string.Format("Saving {0}", doc.MarkpadDocument.Title)))
{
await doc.Save();
await TaskEx.Delay(5000);
<Window.InputBindings>
<KeyBinding Modifiers="Ctrl" Key="S" Command="{Binding SaveDocumentCommand}" />
<KeyBinding Modifiers="Ctrl+Shift" Key="S" Command="{Binding SaveAllDocumentsCommand}" />
<KeyBinding Modifiers="Ctrl" Key="N" Command="{Binding NewDocumentCommand}" />
<KeyBinding Modifiers="Ctrl+Shift" Key="P" Command="{Binding PublishDocumentCommand}" />
<KeyBinding Modifiers="Ctrl" Key="O" Command="{Binding OpenDocumentCommand}" />
<KeyBinding Modifiers="Ctrl+Shift" Key="O" Command="{Binding OpenFromWebCommand}" />
<KeyBinding Modifiers="Ctrl" Key="W" Command="{Binding CloseDocumentCommand}" />
<KeyBinding Key="Escape" Command="commands:ShellCommands.Esc" />
public static void ReturnsValueAsTask<T>(this Task<T> value, T returnThis, params T[] returnThese)
{
Returns(MatchArgs.AsSpecifiedInCall, ToCompletedTask(returnThis), returnThese.Select(ToCompletedTask).ToArray());
}
public static void ReturnsValueAsTask<T>(this Task<T> value, Func<CallInfo, T> returnThis)
{
Returns(MatchArgs.AsSpecifiedInCall, c => ToCompletedTask(returnThis(c)));
}
public class SomeScreen
{
public string Text {get;set;} // Will look for a UI element called Text and return it's value
public void Ok() { } // Finds a control called ok, and clicks it
// Other conventions
public string Text2
{
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;
public class Fixture
{
[Fact]
public void Should_FactMethodName()
public abstract class nsw_police_files : IntegrationTestBase
{
protected abstract void RunTests();
[Fact]
public void Automate()
{
RunTest(Setup, Jurisdictions.NSW);
RunTests();
}
@JakeGinnivan
JakeGinnivan / gist:4679496
Last active December 11, 2015 23:48
Linqpad script
void Main()
{
DoShiz();
}
public async void DoShiz()
{
var worker = new Worker();
var ex = await ThrowsExceptionAsync<ArgumentException>(async () => await worker.GetMessage(" "));
var ex2 = await ThrowsExceptionAsync<ArgumentException>(() => worker.GetMessage(" "));
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Windows]
"ErrorMode"="2"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting]
"DontShowUI"="1"
public interface IRaiseCanExecuteChanged
{
void RaiseCanExecuteChanged();
}
// And an extension method to make it easy to raise changed events
public static class CommandExtensions
{
public static void RaiseCanExecuteChanged(this ICommand command)
{
public class DelegateCommand : DelegateCommand<object>
{
public DelegateCommand(Action executeMethod)
: base(o => executeMethod())
{
}
public DelegateCommand(Action executeMethod, Func<bool> canExecuteMethod)
: base(o => executeMethod(), o => canExecuteMethod())
{