public void Adding_the_same_property_twice_should_cause_exception() { var propertyName = "MyProperty"; var firstValue = 1; var secondValue = 2; var bag = new PropertyBag("testing"); bag.AddPropertyValue(propertyName, firstValue); Action act = () => bag.AddPropertyValue(propertyName, secondValue); act.ShouldThrow <ArgumentException>().WithMessage("An item with the same key has already been added."); }
public void Adding_the_same_property_twice_should_cause_exception() { var propertyName = "MyProperty"; var firstValue = 1; var secondValue = 2; var bag = new PropertyBag("testing"); bag.AddPropertyValue(propertyName, firstValue); Action act = () => bag.AddPropertyValue(propertyName, secondValue); act.ShouldThrow <ArgumentException>(); }
public void Calling_AddPropertyValue_should_add_the_property_info() { var thePropName = "MyProperty"; var thePropValue = "Hello world"; var bag = new PropertyBag("testing"); bag.AddPropertyValue(thePropName, thePropValue); bag.Properties.Should().Contain(p => p.Key == thePropName && (String)p.Value == thePropValue); }
public void The_number_of_properties_should_be_equal_to_the_number_of_calls_to_AddPropertyValue() { var callCount = 5; var bag = new PropertyBag("testing"); for (int i = 0; i < callCount; i++) { var name = "prop" + i; var value = i; bag.AddPropertyValue(name, value); } bag.Properties.Count.Should().Be(callCount); }
public void Restoration_of_an_event_from_a_property_bag_containing_nulls_should_not_fail() { try { var converter = new PropertyBagConverter { TypeResolver = new SimpleEventTypeResolver() }; var bag = new PropertyBag(typeof(TestEvent).AssemblyQualifiedName); bag.AddPropertyValue("SomeString", null); var obj = converter.Convert(bag); obj.Should().NotBeNull(); obj.Should().BeOfType <TestEvent>(); ((TestEvent)obj).SomeString.Should().BeNull(); } catch (Exception e) { Assert.True(false, e.ToString()); } }