This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyModule | |
open Xunit | |
open FsUnit.Xunit | |
type Sample = Sample of int | |
with override x.ToString() = sprintf "%A" x | |
[<Fact>] | |
let ``sample to string`` ()= | |
let actual = Sample 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Dependency */ | |
public class AnotherClass { | |
public virtual string DoSomething(string str1) { return str1.ToUpper(); } /* virtual so we can change/mock it. | |
* Alternatively use an interface, or abstract. */ | |
} | |
/* Class we want to test */ | |
public class MyClass { | |
public string str1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Choose> | |
<When Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets')"> | |
<PropertyGroup> | |
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> | |
</PropertyGroup> | |
</When> | |
<When Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')"> | |
<PropertyGroup> | |
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> | |
</PropertyGroup> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Extensions.cs | |
public static IObservable<T> ObservableFunc<T>(this Func<T> f) { | |
return Observable.Create<T>(obs => { | |
try { | |
obs.OnNext(f()); | |
obs.OnCompleted(); | |
} catch (Exception e) { | |
obs.OnError(e); | |
} | |
return () => {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var done = new Subject<Unit>(); | |
var status = Observable | |
.Interval(TimeSpan.FromMilliseconds(450)) | |
.Select(_ => driver.Status()) // driver keep-alive | |
.TakeUntil(done); | |
// On dispose, window close, etc... | |
done.CompletedWith(Unit.Value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using NSubstitute; | |
using NSubstitute.Core; | |
using NUnit.Framework; | |
using Shouldly; | |
//Disclaimer: for illustrative purposes only. Use at your own risk! :) | |
namespace Sample |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KVStoreExamples | |
{ | |
[Fact] | |
public void GetValueForExistingKey() | |
{ | |
var kv = | |
from a in KVStore.add("a", 1) | |
from b in KVStore.add("b", 2) | |
from c in KVStore.add("c", 3) | |
select c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainViewModel : Screen | |
{ | |
private ConnectionService _service; | |
public ObservableCollection<DeviceViewModel> Devices { get; private set; } | |
public MainViewModel() | |
{ | |
Devices = new ObservableCollection<DeviceViewModel>(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ObservableItems<T> : INotifyPropertyChanged | |
{ | |
private IEnumerable<T> _items; | |
public ObservableItems(IObservable<IEnumerable<T>> source, IEnumerable<T> initialValue) | |
{ | |
Items = initialValue; | |
source | |
.ObserveOnDispatcher() | |
.Subscribe(x => Items = x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var x = new Thing(); | |
Action<string> onFoo = s => Console.WriteLine (s); | |
x.OnFoo += onFoo.Invoke; | |
x.RaiseEvent("a"); | |
x.RaiseEvent("b"); | |
x.OnFoo -= onFoo.Invoke; | |
x.RaiseEvent("c"); | |
} |