public void Can_deserialize_single() { var deserializer = new CsvDeserializer(); var bindingContext = new BindingContext() { DestinationType = typeof(User), GenericType = null, Configuration = new BindingConfig() }; var result = deserializer.Deserialize("text/csv", new MemoryStream(Encoding.UTF8.GetBytes("Name,Age\r\nJim,45\r\n")), bindingContext); ((User)result).ShouldBeEquivalentTo(_users[0]); }
public void Can_deserialize_collections(Type type) { var deserializer = new CsvDeserializer(); var bindingContext = new BindingContext() { DestinationType = type, GenericType = type.GetGenericArguments()[0], Configuration = new BindingConfig() }; var result = deserializer.Deserialize("text/csv", new MemoryStream(Encoding.UTF8.GetBytes(_usersString)), bindingContext); type.IsInstanceOfType(result).Should().BeTrue(); ((IEnumerable)result).ShouldBeEquivalentTo(_users); }