public void ShouldCollectWithoutChildPlans() { var metadata = new Dictionary <string, object> { { Key, new Dictionary <string, object> { { "operatorType", "opType" }, { "args", new Dictionary <string, object> { { "a", 1L } } }, { "identifiers", new List <object> { "a", "b", "c" } } } } }; var collector = new PlanCollector(); collector.Collect(metadata); collector.Collected.Should().BeEquivalentTo(new Plan("opType", new Dictionary <string, object> { { "a", 1L } }, new List <string> { "a", "b", "c" }, new List <IPlan>())); }
public void ShouldNotCollectIfNoValueIsGiven() { var collector = new PlanCollector(); collector.Collect(new Dictionary <string, object>()); collector.Collected.Should().BeNull(); }
public void ShouldNotCollectIfMetadataIsNull() { var collector = new PlanCollector(); collector.Collect(null); collector.Collected.Should().BeNull(); }
public void ShouldNotCollectIfValueIsEmpty() { var collector = new PlanCollector(); collector.Collect(new Dictionary <string, object> { { Key, new Dictionary <string, object>() } }); collector.Collected.Should().BeNull(); }
public void ShouldThrowIfValueIsOfWrongType() { var metadata = new Dictionary <string, object> { { Key, true } }; var collector = new PlanCollector(); var ex = Record.Exception(() => collector.Collect(metadata)); ex.Should().BeOfType <ProtocolException>().Which .Message.Should() .Contain($"Expected '{Key}' metadata to be of type 'IDictionary<String,Object>', but got 'Boolean'."); }
public void ShouldReturnSameCollected() { var metadata = new Dictionary <string, object> { { Key, new Dictionary <string, object> { { "operatorType", "opType" } } } }; var collector = new PlanCollector(); collector.Collect(metadata); ((IMetadataCollector)collector).Collected.Should().BeSameAs(collector.Collected); }
public void ShouldCollectWithDefaultValues() { var metadata = new Dictionary <string, object> { { Key, new Dictionary <string, object> { { "operatorType", "opType" } } } }; var collector = new PlanCollector(); collector.Collect(metadata); collector.Collected.Should().BeEquivalentTo(new Plan("opType", new Dictionary <string, object>(), new List <string>(), new List <IPlan>())); }
public void ShouldThrowIfOperatorTypeIsMissing() { var metadata = new Dictionary <string, object> { { Key, new Dictionary <string, object> { { "args", new Dictionary <string, object>() } } } }; var collector = new PlanCollector(); var ex = Record.Exception(() => collector.Collect(metadata)); ex.Should().BeOfType <ProtocolException>().Which .Message.Should() .Be("Expected key 'operatorType' to be present in the dictionary, but could not find."); }