Created
August 19, 2016 07:11
-
-
Save molnarm/8e7a0555d7e22e6bbbea23596c73f9d4 to your computer and use it in GitHub Desktop.
Sample test for an exception thrown from DynamicData. The test passes but the error is displayed in the output.
This file contains 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 DynamicData; | |
using DynamicData.Binding; | |
using NUnit.Framework; | |
[TestFixture] | |
public class DynamicDataTest | |
{ | |
[Test] | |
public void TransformToNull() | |
{ | |
var data = new Data { Id = 1, State = null }; | |
var cache = new SourceCache<Data, int>(d => d.Id); | |
var items = new ObservableCollectionExtended<string>(); | |
var subscription = cache.Connect() | |
.Transform(d => d.State) | |
.Bind(items) | |
.Subscribe(_ => { }, e => Console.WriteLine($"Error: {e.Message}")); | |
cache.AddOrUpdate(data); | |
data.State = "Changed"; | |
cache.AddOrUpdate(data); | |
subscription.Dispose(); | |
} | |
private class Data | |
{ | |
public int Id { get; set; } | |
public string State { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment