I need to test piece of code
var watcher = new FakeIFileSystemWatcher();
watcher.FilesToBeImported
.ObserveOnDispatcher()
.Subscribe(list.Add);
so I created this little unit test but I can't make it pass cause list.Count is always 0
[Test]
public void Foo()
{
var list = new List<string>();
var watcher = new FakeIFileSystemWatcher();
watcher.FilesToBeImported
.ObserveOnDispatcher()
.Subscribe(list.Add);
Task task = Task.Factory.StartNew(() =>
{
watcher.AddFile("cc");
watcher.AddFile("cc");
watcher.AddFile("cc");
}, TaskCreationOptions.LongRunning);
Task.WaitAll(task);
Assert.AreEqual(3, list.Count);
}
if I comment out the method
.ObserveOnDispatcher()
it pass but how can I get it working also with ObserveOnDispatcher() ?
list.Count
at failure? – Clarissa