public void when_try_to_remove_thing_with_invalid_name_given_it_should_throw() { var pocket = new ConcurrentPocket(); Action sut = () => pocket.TryRemove(name: null); sut.Should().Throw <ArgumentNullException>().Where( exception => exception.ParamName.Equals("name"), "null is not a valid name"); sut = () => pocket.TryRemove(string.Empty); sut.Should().Throw <ArgumentNullException>().Where( exception => exception.ParamName.Equals("name"), "an empty string is not a valid name"); sut = () => pocket.TryRemove(WhiteSpaceString); sut.Should().Throw <ArgumentNullException>().Where( exception => exception.ParamName.Equals("name"), "a whitespace is not a valid name"); }
public void when_try_to_remove_stored_thing_it_should_remove_it_and_return_success_status() { var sut = new ConcurrentPocket(); const string nameOfThing = "name of the thing"; const string thingItself = "the thing itself"; sut.Put(nameOfThing, thingItself); sut.TryRemove(nameOfThing).Should().BeTrue("thing was removed from the pocket"); sut.GetThings().Count.Should().Be(expected: 0, "the pocket is empty"); }
public void when_try_to_remove_thing_not_stored_in_pocket_it_should_leave_pocket_content_unchanged_and_return_fail_status() { var sut = new ConcurrentPocket(); const string nameOfThing = "name of the thing"; const string thingItself = "the thing itself"; sut.Put(nameOfThing, thingItself); sut.TryRemove("a different name").Should().BeFalse("a thing with such name not stored in the pocket"); sut.GetThings().Count.Should().Be(expected: 1, "number of things should be the same"); sut.GetThings()[nameOfThing].Should().BeSameAs(thingItself, "the pocket content should stay the same"); }