Skip to content

Commit

Permalink
0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GoEddie committed Oct 15, 2019
1 parent 88b34e2 commit d671071
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 23 deletions.
89 changes: 81 additions & 8 deletions src/SQLCover/SQLCover/CoverageResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,92 @@ public string Html()
transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
}
</style>
</head>
<body id=""top"">");
builder.Append(
"<table><thead><td>object name</td><td>statement count</td><td>covered statement count</td><td>coverage %</td></thead>");

.covered-statement{
background-color: greenyellow;
builder.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3:0.00}</td></tr>", "<b>Total</b>",
statements, coveredStatements, (float)coveredStatements / (float)statements * 100.0);

foreach (
var batch in
_batches.Where(p => !p.ObjectName.Contains("tSQLt"))
.OrderByDescending(p => (float)p.CoveredStatementCount / (float)p.StatementCount))
{
builder.AppendFormat(
"<tr><td><a href=\"#{0}\">{0}</a></td><td>{1}</td><td>{2}</td><td>{3:0.00}</td></tr>",
batch.ObjectName, batch.StatementCount, batch.CoveredStatementCount,
(float)batch.CoveredStatementCount / (float)batch.StatementCount * 100.0);
}

builder.Append("</table>");

foreach (var b in _batches)
{
builder.AppendFormat("<pre><a name=\"{0}\"><div class=\"batch\">", b.ObjectName);

var tempBuffer = b.Text;
foreach (var statement in b.Statements.OrderByDescending(p => p.Offset))
{
if (statement.HitCount > 0)
{
var start = tempBuffer.Substring(0, statement.Offset + statement.Length);
var end = tempBuffer.Substring(statement.Offset + statement.Length);
tempBuffer = start + "</span>" + end;

start = tempBuffer.Substring(0, statement.Offset);
end = tempBuffer.Substring(statement.Offset);
tempBuffer = start + "<span style=\"background-color: greenyellow\">" + end;
}
}

builder.Append(tempBuffer + "</div></a></pre><a href=\"#top\"><i class=\"up\"></i></a>");
}


builder.AppendFormat("</body></html>");

return builder.ToString();
}
table{
background-color: lightgrey;

public string Html2()
{
var statements = _batches.Sum(p => p.StatementCount);
var coveredStatements = _batches.Sum(p => p.CoveredStatementCount);

var builder = new StringBuilder();

builder.Append(@"<html>
<head>
<title>SQLCover Code Coverage Results</title>
<style>
html{
font-family: ""Roboto"",""Helvetica Neue"",Arial,Sans-serif;
font-size: 100%;
line-height: 26px;
word-break: break-word;
}
i{
border: solid black;
border-width: 0 3px 3px 0;
display: inline-block;
padding: 3px;
}
thead{
background-color: gray;
color: whitesmoke;
.up {
transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
}
.covered-statement{
background-color: greenyellow;
}
</style>
<link media=""all"" rel=""stylesheet"" type=""text/css"" href=""sqlcover.css"" />
Expand Down
12 changes: 6 additions & 6 deletions src/SQLCover/SQLCover/SQLCover.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Data.Tools.Schema.Sql, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Tools.Utilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.Data.Tools.Utilities.dll</HintPath>
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.Data.Tools.Utilities.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.Dac, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.SqlServer.Dac.dll</HintPath>
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.SqlServer.Dac.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.Dac.Extensions, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.SqlServer.Dac.Extensions.dll</HintPath>
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.SqlServer.Dac.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.TransactSql.ScriptDom, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll</HintPath>
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.Types, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.SqlServer.Types.dll</HintPath>
<HintPath>..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.SqlServer.Types.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion src/SQLCover/SQLCover/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.SqlServer.DacFx.x64" version="150.4200.1" targetFramework="net462" />
<package id="Microsoft.SqlServer.DacFx.x64" version="150.4538.1" targetFramework="net461" />
</packages>
10 changes: 10 additions & 0 deletions src/SQLCover/releases/template/SQLCover.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ function Export-Html{
$result.SaveSourceFiles($outputPath)
}

function Export-Html2{
param(
[SQLCover.CoverageResult] $result
,[string]$outputPath
)

$xmlPath = Join-Path -Path $outputPath -ChildPath "Coverage2.html"
$result.Html2() | Out-File $xmlPath
$result.SaveSourceFiles($outputPath)
}

#EXAMPLE:
<#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public static string GetIntegration()
else
{
// var connectionString = $"Server=np:{GetPipeName()};integrated security=sspi;initial catalog=DatabaseProject";
var connectionString = $"Server=tcp:{GetContainerIP()};uid=sa;pwd=Psgsgsfsfs!!!!!;initial catalog=DatabaseProject";
//var connectionString = $"Server=tcp:{GetContainerIP()};uid=sa;pwd=Psgsgsfsfs!!!!!;initial catalog=DatabaseProject";
var connectionString = "Server=(localdb)\\SQLCover;integrated security=SSPI;initial catalog=DatabaseProject";
return connectionString;
}
}
Expand Down
18 changes: 12 additions & 6 deletions src/SQLCover/test/SQLCover.UnitTests/SQLCover.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,28 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Data.Tools.Schema.Sql, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Tools.Utilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.Data.Tools.Utilities.dll</HintPath>
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.Data.Tools.Utilities.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.SqlServer.Dac, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.SqlServer.Dac.dll</HintPath>
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.SqlServer.Dac.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.SqlServer.Dac.Extensions, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.SqlServer.Dac.Extensions.dll</HintPath>
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.SqlServer.Dac.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.SqlServer.TransactSql.ScriptDom, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll</HintPath>
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.SqlServer.TransactSql.ScriptDom.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.SqlServer.Types, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4200.1\lib\net46\Microsoft.SqlServer.Types.dll</HintPath>
<HintPath>..\..\packages\Microsoft.SqlServer.DacFx.x64.150.4538.1\lib\net46\Microsoft.SqlServer.Types.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion src/SQLCover/test/SQLCover.UnitTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.SqlServer.DacFx.x64" version="150.4200.1" targetFramework="net462" />
<package id="Microsoft.SqlServer.DacFx.x64" version="150.4538.1" targetFramework="net461" />
<package id="Moq" version="4.2.1510.2205" targetFramework="net452" />
<package id="NUnit" version="3.11.0" targetFramework="net452" />
<package id="NUnit3TestAdapter" version="3.11.2" targetFramework="net452" />
Expand Down

0 comments on commit d671071

Please sign in to comment.