public void ShouldCollectWithoutChildPlans() { var metadata = new Dictionary <string, object> { { Key, new Dictionary <string, object> { { "operatorType", "opType" }, { "dbHits", 5L }, { "rows", 10L }, { "args", new Dictionary <string, object> { { "a", 1L } } }, { "identifiers", new List <object> { "a", "b", "c" } } } } }; var collector = new ProfiledPlanCollector(); collector.Collect(metadata); collector.Collected.Should().BeEquivalentTo(new ProfiledPlan("opType", new Dictionary <string, object> { { "a", 1L } }, new List <string> { "a", "b", "c" }, new List <IProfiledPlan>(), 5, 10, 0, 0, 0, 0)); }
public void ShouldNotCollectIfNoValueIsGiven() { var collector = new ProfiledPlanCollector(); collector.Collect(new Dictionary <string, object>()); collector.Collected.Should().BeNull(); }
public void ShouldNotCollectIfMetadataIsNull() { var collector = new ProfiledPlanCollector(); collector.Collect(null); collector.Collected.Should().BeNull(); }
public void ShouldNotCollectIfValueIsEmpty() { var collector = new ProfiledPlanCollector(); 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 ProfiledPlanCollector(); 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 ShouldThrowIfOperatorTypeIsMissing() { var metadata = new Dictionary <string, object> { { Key, new Dictionary <string, object> { { "args", new Dictionary <string, object>() } } } }; var collector = new ProfiledPlanCollector(); 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."); }
public void ShouldReturnSameCollected() { var metadata = new Dictionary <string, object> { { Key, new Dictionary <string, object> { { "operatorType", "opType" }, { "dbHits", 5L }, { "rows", 10L } } } }; var collector = new ProfiledPlanCollector(); 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" }, { "dbHits", 5L }, { "rows", 10L } } } }; var collector = new ProfiledPlanCollector(); collector.Collect(metadata); collector.Collected.Should().BeEquivalentTo(new ProfiledPlan("opType", new Dictionary <string, object>(), new List <string>(), new List <IProfiledPlan>(), 5, 10, 0, 0, 0, 0)); }
public void ShouldCollectWithSpecifiedValues() { var metadata = new Dictionary <string, object> { { Key, new Dictionary <string, object> { { "operatorType", "opType" }, { "dbHits", 5L }, { "rows", 10L }, { "pageCacheHits", 1L }, { "pageCacheMisses", 2L }, { "pageCacheHitRatio", 3.0 }, { "time", 4L } } } }; var collector = new ProfiledPlanCollector(); collector.Collect(metadata); collector.Collected.Should().BeEquivalentTo(new ProfiledPlan("opType", new Dictionary <string, object>(), new List <string>(), new List <IProfiledPlan>(), 5, 10, 1, 2, 3, 4)); }
public void ShouldCollectWithNestedChildPlans() { var metadata = new Dictionary <string, object> { { Key, new Dictionary <string, object> { { "operatorType", "opType" }, { "dbHits", 5L }, { "rows", 10L }, { "args", new Dictionary <string, object> { { "a", 1L } } }, { "identifiers", new List <object> { "a", "b", "c" } }, { "children", new List <object> { new Dictionary <string, object> { { "operatorType", "childOpType" }, { "dbHits", 15L }, { "rows", 20L }, { "args", new Dictionary <string, object> { { "b", 2L } } }, { "identifiers", new List <object> { "d", "e" } }, { "children", new List <object> { new Dictionary <string, object> { { "operatorType", "childChildOpType" }, { "dbHits", 25L }, { "rows", 30L }, { "args", new Dictionary <string, object> { { "c", 3L } } }, { "identifiers", new List <object> { "f" } } } } } } } } } } }; var collector = new ProfiledPlanCollector(); collector.Collect(metadata); collector.Collected.Should().BeEquivalentTo(new ProfiledPlan("opType", new Dictionary <string, object> { { "a", 1L } }, new List <string> { "a", "b", "c" }, new List <IProfiledPlan> { new ProfiledPlan("childOpType", new Dictionary <string, object> { { "b", 2L } }, new List <string> { "d", "e" }, new List <IProfiledPlan> { new ProfiledPlan("childChildOpType", new Dictionary <string, object> { { "c", 3L } }, new List <string> { "f" }, new List <IProfiledPlan>(), 25, 30) }, 15, 20) }, 5, 10)); }