public void ReturnsEmptyCollectionWhenSourceCollectionIsEmpty() { var sourceValue = new NameValueCollection(); var rc = new ResolutionContext(null, sourceValue, new NameValueCollection(), typeof (NameValueCollection), typeof (NameValueCollection), null, Mapper.Context); var nvcm = new NameValueCollectionMapper(); var result = nvcm.Map(rc) as NameValueCollection; result.ShouldBeEmpty(); }
public void ReturnsMappedObjectWithExpectedValuesWhenSourceCollectionHasOneItem() { var sourceValue = new NameValueCollection() {{"foo", "bar"}}; var rc = new ResolutionContext(null, sourceValue, new NameValueCollection(), typeof (NameValueCollection), typeof (NameValueCollection), null, Mapper.Context); var nvcm = new NameValueCollectionMapper(); var result = nvcm.Map(rc) as NameValueCollection; 1.ShouldEqual(result.Count); "foo".ShouldEqual(result.AllKeys[0]); "bar".ShouldEqual(result["foo"]); }
public void ReturnsNullIfSourceTypeIsNotNameValueCollection() { var rc = new ResolutionContext(null, new object(), new NameValueCollection(), typeof (object), typeof (NameValueCollection), null, Mapper.Context); var nvcm = new NameValueCollectionMapper(); var result = nvcm.Map(rc); result.ShouldBeNull(); }