public void TestSetNull() { using (var mDoc = new MutableDocument("test")) { var mDict = new MutableDictionaryObject(); mDict.SetValue("obj-null", null); mDict.SetString("string-null", null); mDict.SetArray("array-null", null); mDict.SetDictionary("dict-null", null); mDoc.SetDictionary("dict", mDict); SaveDocument(mDoc, doc => { doc.Count.Should().Be(1); doc.Contains("dict").Should().BeTrue(); var d = doc.GetDictionary("dict"); d.Should().NotBeNull(); d.Count.Should().Be(4); d.Contains("obj-null").Should().BeTrue(); d.Contains("string-null").Should().BeTrue(); d.Contains("array-null").Should().BeTrue(); d.Contains("dict-null").Should().BeTrue(); d.GetValue("obj-null").Should().BeNull();; d.GetValue("string-null").Should().BeNull();; d.GetValue("array-null").Should().BeNull();; d.GetValue("dict-null").Should().BeNull(); }); } }
public void TestQueryPredictionValues() { CreateDocument(1, 2, 3, 4, 5); CreateDocument(6, 7, 8, 9, 10); var aggregateModel = new AggregateModel(); aggregateModel.RegisterModel(); var model = nameof(AggregateModel); var input = AggregateModel.CreateInput("numbers"); var prediction = Function.Prediction(model, input); using (var q = QueryBuilder.Select(SelectResult.Property("numbers"), SelectResult.Expression(prediction.Property("sum")).As("sum"), SelectResult.Expression(prediction.Property("min")).As("min"), SelectResult.Expression(prediction.Property("max")).As("max"), SelectResult.Expression(prediction.Property("avg")).As("avg")) .From(DataSource.Database(Db))) { var rows = VerifyQuery(q, (n, result) => { var numbers = result.GetArray(0); var dict = new MutableDictionaryObject(); dict.SetArray("numbers", numbers); var expected = aggregateModel.Predict(dict); var sum = result.GetInt(1); var min = result.GetInt(2); var max = result.GetInt(3); var avg = result.GetDouble(4); result.GetInt("sum").Should().Be(sum); result.GetInt("min").Should().Be(min); result.GetInt("max").Should().Be(max); result.GetDouble("avg").Should().Be(avg); sum.Should().Be(expected.GetInt("sum")); min.Should().Be(expected.GetInt("min")); max.Should().Be(expected.GetInt("max")); avg.Should().Be(expected.GetDouble("avg")); }); rows.Should().Be(2); } }