public object Materialize(ElasticResponse response) { if (response.hits.total < 0) throw new ArgumentOutOfRangeException("response", "Contains a negative number of hits."); return Convert.ChangeType(response.hits.total, returnType); } }
public void CountMaterializerThrowsForNegativeCount() { var response = new ElasticResponse { hits = new Hits { hits = new List<Hit>(), total = -1 } }; var materializer = new CountElasticMaterializer(typeof(int)); Assert.Throws<ArgumentOutOfRangeException>(() => materializer.Materialize(response)); }