public CoveredStatement GetNextStatement() { if (_stringNumber > _xmlEvents.Count || _xmlEvents.Count == 0) { return(null); } var statement = new CoveredStatement(); statement.Offset = GetOffset(); statement.OffsetEnd = GetOffsetEnd(); statement.ObjectId = GetIntValue("object_id"); if (_stringNumber < _xmlEvents.Count) { _doc = XDocument.Parse(_xmlEvents[_stringNumber++]); } else { _stringNumber++; } return(statement); }
public void Statement_Is_Not_Covered_If_Statement_Starts_After_CoveredStatement_Ends() { var statement = new Statement("", 1000, 500, true); var coveredStatement = new CoveredStatement { Offset = 200, OffsetEnd = 212, ObjectId = 999 }; var checker = new StatementChecker(); Assert.IsFalse(checker.Overlaps(statement, coveredStatement)); }
public void Statement_Is_Covered_If_Statement_Is_Starts_And_Stops_Within_CoveredStatement() { var statement = new Statement("", 100, 5, true); var coveredStatement = new CoveredStatement { Offset = 200, OffsetEnd = 212, ObjectId = 999 }; var checker = new StatementChecker(); Assert.IsTrue(checker.Overlaps(statement, coveredStatement)); }
public void Statement_Is_Covered_If_CoveredStatement_Has_No_OffsetEnd_And_Statement_Starts_After_CoveredStatement() { var statement = new Statement("", 100, 10, true); var coveredStatement = new CoveredStatement { Offset = 105, OffsetEnd = -1, ObjectId = 999 }; var checker = new StatementChecker(); Assert.IsTrue(checker.Overlaps(statement, coveredStatement)); }
public bool Overlaps(Statement statement, CoveredStatement coveredStatement) { var coveredOffsetStart = coveredStatement.Offset / 2; var coveredOffsetEnd = coveredStatement.OffsetEnd; if (coveredOffsetEnd == -1) { // Last statement in the batch, so only covered if the 'start' is equal to or less than the statement start return(statement.Offset >= coveredOffsetStart); } var statementStart = statement.Offset; var statementEnd = statementStart + statement.Length; coveredOffsetEnd = coveredStatement.OffsetEnd / 2; return(statementStart >= coveredOffsetStart && statementEnd <= coveredOffsetEnd); }
public void Statement_Is_Not_Covered_If_Statement_Starts_Before_Covered_Statement() { var statement = new Statement { IsCoverable = true, Offset = 10, Length = 500 }; var coveredStatement = new CoveredStatement { Offset = 200, OffsetEnd = 212, ObjectId = 999 }; var checker = new StatementChecker(); Assert.IsFalse(checker.Overlaps(statement, coveredStatement)); }
public bool Overlaps(Statement statement, CoveredStatement coveredStatement) { var coveredOffsetStart = coveredStatement.Offset / 2; var coveredOffsetEnd = coveredStatement.OffsetEnd; if (coveredOffsetEnd == -1) { // Last statement in the batch, so only covered if the 'start' is equal to or less than the statement start return(statement.Offset >= coveredOffsetStart); } var statementStart = statement.Offset; var statementEnd = statementStart + statement.Length; coveredOffsetEnd = coveredStatement.OffsetEnd / 2; if (statementStart >= coveredOffsetStart && statementEnd <= coveredOffsetEnd) { return(true); } //this is a little painful: // https://connect.microsoft.com/SQLServer/feedback/details/3124768 /* * i don't think this is an actual problem because on the offsetEnd is wrong, the offsetStart is right so even if there was something like: * exec a;b; * which would execute proc a and b, we wouldn't mark b as executed when a was executed because the start would be before b */ coveredOffsetEnd = coveredOffsetEnd + 2; if (statementStart >= coveredOffsetStart && statementEnd <= coveredOffsetEnd) { return(true); } return(false); }