public void Should_not_create_instance_for_missing_data_type_for_removed() { var data = new DataChangedEventDictionary(DataChangedEvent.Added); var result = _subject.FindRemovedEvent(data); result.Should().BeNull(); }
public void Should_not_add_with_more_then_one_parameter_in_ctor() { var dict = new DataChangedEventDictionary(DataChangedEvent.Removed); Action action = () => dict.Add(typeof(MyClass), typeof(RemovedEventWrongCtor2)); action.Should().ThrowExactly <ArgumentException>().WithMessage("*RemovedEventWrongCtor2*has no*accepts*MyClass*"); }
public void Should_not_add_an_interface_type() { var dict = new DataChangedEventDictionary(DataChangedEvent.Updated); Action action = () => dict.Add(typeof(MyClass), typeof(InterfaceUpdatedEvent1)); action.Should().ThrowExactly <ArgumentException>().WithMessage("*InterfaceUpdatedEvent1*must be*concrete*"); }
public void Should_not_add_with_no_ctor() { var dict = new DataChangedEventDictionary(DataChangedEvent.Removed); Action action = () => dict.Add(typeof(MyClass), typeof(RemovedEventNoCtor)); action.Should().ThrowExactly <ArgumentException>().WithMessage("*RemovedEventNoCtor*has no*accepts*MyClass*"); }
public void Should_containsKey_return_false_when_dataType_is_not_added() { var dict = new DataChangedEventDictionary(DataChangedEvent.Removed); dict.Add(typeof(MyClass2), typeof(RemovedEvent2)); dict.ContainsKey(typeof(MyClass)).Should().BeFalse(); }
public void Should_not_add_an_updated_event_to_an_remvoed_dictionary() { var dict = new DataChangedEventDictionary(DataChangedEvent.Removed); Action action = () => dict.Add(typeof(MyClass), typeof(AddedEvent1)); action.Should().ThrowExactly <ArgumentException>() .WithMessage("*AddedEvent1*does not*IDataRemovedEvent<MyClass>*"); }
public void Should_only_add_eventType_for_one_dataType_with_add() { var dict = new DataChangedEventDictionary(DataChangedEvent.Added); dict.Add(typeof(MyClass), typeof(AddedEvent1)); Action action = () => dict.Add(typeof(MyClass), typeof(AddedEvent2)); action.Should().ThrowExactly <ArgumentException>().WithMessage("*same key*MyClass*"); }
public void Should_add_an_event_with_add() { var dict = new DataChangedEventDictionary(DataChangedEvent.Added); dict.Add(typeof(MyClass), typeof(AddedEvent1)); var result = dict[typeof(MyClass)]; result.Should().Be(typeof(AddedEvent1)); }
public void Should_TryGetValue_return_false_for_non_existing_types() { var dict = new DataChangedEventDictionary(DataChangedEvent.Removed); dict.Add(typeof(MyClass2), typeof(RemovedEvent2)); dict.Add(typeof(MyClass), typeof(RemovedEvent1)); dict.TryGetValue(typeof(MyClass3), out var et1).Should().BeFalse(); }
public void Should_containsKey_return_true_for_all_dataTypes() { var dict = new DataChangedEventDictionary(DataChangedEvent.Removed); dict.Add(typeof(MyClass2), typeof(RemovedEvent2)); dict.Add(typeof(MyClass), typeof(RemovedEvent1)); dict.ContainsKey(typeof(MyClass)).Should().BeTrue(); dict.ContainsKey(typeof(MyClass2)).Should().BeTrue(); }
public void Should_Remove_removes_an_existing_value() { var dict = new DataChangedEventDictionary(DataChangedEvent.Removed); dict.Add(typeof(MyClass2), typeof(RemovedEvent2)); dict.Add(typeof(MyClass), typeof(RemovedEvent1)); dict.Remove(typeof(MyClass)).Should().BeTrue(); dict.ContainsKey(typeof(MyClass)).Should().BeFalse(); }
public DataChangedEventRepositoryTests() { var added = new DataChangedEventDictionary(DataChangedEvent.Added); var updated = new DataChangedEventDictionary(DataChangedEvent.Updated); var removed = new DataChangedEventDictionary(DataChangedEvent.Removed); _subject = new DataChangedEventRepository(added, updated, removed); added.Add(typeof(Data1), typeof(Data1Added)); updated.Add(typeof(Data1), typeof(Data1Updated)); removed.Add(typeof(Data1), typeof(Data1Removed)); removed.Add(typeof(Data2), typeof(Data2Removed)); }