Cannot use dotcover with VS2017 (tests are inconclusive) - unit-testing

I am able to run and debug my unit tests using ReSharper but when I try to use dotcover all tests show as inconclusive.
I'm using Visual Studio Enterprise 2017 (v15.9.4) with ReSharper Ultimate 2018.3, and sll the projects in my solution use .NET Framework 4.7.2.
My unit test project uses NUnit and has the following nuget packages installed:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Faker.Net" version="1.1.1" targetFramework="net472" />
<package id="FluentAssertions" version="5.5.3" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.CodeCoverage" version="15.9.0" targetFramework="net472" />
<package id="Microsoft.NET.Test.Sdk" version="15.9.0" targetFramework="net472" />
<package id="NBuilder" version="6.0.0" targetFramework="net472" />
<package id="NUnit" version="3.11.0" targetFramework="net472" />
<package id="NUnit3TestAdapter" version="3.12.0" targetFramework="net472" />
<package id="RazorEngine" version="3.10.0" targetFramework="net472" />
</packages>
These are some of my settings related to tests:
Unit Testing (General)
Unit Testing (Test Runner)
Dotcover (General)
What I am missing here?

Related

NullArgumentException when eager-loading collection from web service after updating to use PackageReferences

The application I am working on has several projects, including an "Infrastructure" (.Net Standard) where the dbContext is defined, a WinForms project (.Net Framework), and a ASP.Net web project (.Net Framework). The web project is only used for Web Services (asmx).
The issue I am experiencing is that whenever I call .Include() on a IQueryable in order to include a collection navigation property from within the web project, I receive an ArgumentNullException thrown by EntityFrameworkCore.
For example:
context.Reports.Include(e => e.ReportParamters).ToList();
Value cannot be null. Parameter name: frameworkName
at Microsoft.EntityFrameworkCore.Metadata.Internal.ClrCollectionAccessorFactory.Create(INavigation navigation)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Navigation.<>c.<get_CollectionAccessor>b__21_0(Navigation n)
at Microsoft.EntityFrameworkCore.Internal.NonCapturingLazyInitializer.EnsureInitialized[TParam,TValue](TValue& target, TParam param, Func`2 valueFactory)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Navigation.get_CollectionAccessor()
at Microsoft.EntityFrameworkCore.NavigationExtensions.GetCollectionAccessor(INavigation navigation)
at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.CustomShaperCompilingExpressionVisitor.VisitExtension(Expression extensionExpression)
at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBlock(BlockExpression node)
at System.Linq.Expressions.BlockExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitConditional(ConditionalExpression node)
at System.Linq.Expressions.ConditionalExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBlock(BlockExpression node)
at System.Linq.Expressions.BlockExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression`1 node)
at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.VisitShapedQueryExpression(ShapedQueryExpression shapedQueryExpression)
at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.VisitExtension(Expression extensionExpression)
at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TRYADWebService.TRYADWebService.ItemWithNoLocationReport(String parameters) in C:\VisualStudioProjects\TRYAD\TRYADWebService\TRYADWebService.asmx.cs:line 435
I only get this error when the WinForms project calls a WebService method (which in turn calls code that includes the query). For development purposes the WinForms project references the web service using "localhost". The exact same EF query works when called directly from the WinForms project, and any query that does not use eager-loading works from the web project.
Not sure if this is relevant, but I recently converted the Infrastructure project from .Net Framework to .Net Standard and updated all the projects in the solution to use PackageReferences instead of package.config files. Unfortunately, it seems that ASP.Net web projects do not support PackageReferences, so I had to add all of the packages used in the other projects (including transitive dependencies) to the web project's package.config file. Here is the package.config file from the web project:
Web project's package.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.4.0" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.1" targetFramework="net48" />
<package id="Microsoft.Bcl.HashCode" version="1.1.1" targetFramework="net48" />
<package id="Microsoft.Data.SqlClient" version="1.1.3" targetFramework="net48" />
<package id="Microsoft.Data.SqlClient.SNI" version="1.1.0" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.Analyzers" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.Proxies" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.Relational" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.SqlServer" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Caching.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Caching.Memory" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration.Binder" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Options" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Primitives" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Identity.Client" version="3.0.8" targetFramework="net48" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Logging" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Tokens" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.Linq.Translations" version="2.0.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Collections.Immutable" version="1.7.1" targetFramework="net48" />
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net48" />
<package id="System.Data.Common" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.DiagnosticSource" version="4.7.1" targetFramework="net48" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.5.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
</packages>
update
If the DbContext is configured to allow lazy-loading and I don't use eager-loading, I don't get an exception, but the collection is empty. In the following example, the reports variable is not empty, but the reportWithParams variable is null. This is despite the EF query explicitly filtering to only reports with parameters, and lazy-loading being enabled.
var reports = context.Reports.Where(e => e.ReportParameters.Any()).ToList();
var reportWithParams = reports.FirstOrDefault(e => e.ReportParameters.Any());

c++ nuget packages for opengl

I try to include opengl via nuget.
This is my packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="boost" version="1.64.0.0" targetFramework="Native" />
<package id="boost_atomic-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_chrono-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_date_time-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_filesystem-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_log_setup-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_log-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_system-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_thread-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_unit_test_framework-vc140" version="1.64.0.0" targetFramework="native" />
<package id="glew.v140" version="1.12.0" targetFramework="native" />
<package id="glfw" version="3.2.1" targetFramework="native" />
<package id="glfw.redist" version="3.2.1" targetFramework="native" />
<package id="GLMathematics" version="0.9.5.4" targetFramework="native" />
<package id="lua" version="5.3.3" targetFramework="native" />
<package id="lua.redist" version="5.3.3" targetFramework="native" />
<package id="nupengl.core" version="0.1.0.1" targetFramework="native" />
<package id="nupengl.core.redist" version="0.1.0.1" targetFramework="native" />
<package id="sdl2" version="2.0.5" targetFramework="native" />
<package id="sdl2.redist" version="2.0.5" targetFramework="native" />
<package id="turtle" version="1.2.6" targetFramework="native" />
<package id="unofficial.flayan.glm" version="0.9.8.4" targetFramework="Native" />
</packages>
It should contain all I need however i am getting an error:
LNK2019: unresolved external symbol __imp__glDrawElements#16
I can "fix" that by including opengl32.lib.
#pragma comment(lib, "opengl32.lib")
But I wonder if I am missing something in my packages. I was under the impression that one just adds the packages and they include the libraries into the build.
Am I misusing nuget, is there something else I should have done?
Am I misusing nuget, is there something else I should have done?
No, do not need to do anything else but just including the opengl32.lib.
glDrawElements is a "core" OpenGL feature. This function resides in opengl32.dll, which you unfortunately forgot to include in your linking libs.
Besides, Some libraries support auto-linking mechanism (for example, freeglut), that is, the header file contains a line like #prgama comment(lib, "lib1_name.lib").
To resolve that LNK error, just include the opengl32.lib by the syntax:
#pragma comment(lib, "opengl32.lib")

XUnit and AutoFixture Exception No Data found for (test name)

I have a very simple test as shown below.
I try to freeze my two dependencies using the AutoDataAttribute + AutoMoqCustomization.
class AutoMoqDataAttribute : AutoDataAttribute
{
public AutoMoqDataAttribute()
: base(new Fixture().Customize(new AutoMoqCustomization()))
{ }
}
public class PrBatchEndorseBrokerTest
{
[Theory, AutoMoqData]
public void Process_ValidContext_CallsK2Workflows(
[Frozen]Mock<IK2Datasource> k2,
[Frozen]Mock<IAppConfiguration> config,
PrBatchEndorseBroker sut)
{
// Arrange
var data = new Dictionary<string, object>
{
["Workflow"] = #"KLPurchaseRequest\PR",
["Activity"] = "Endorser",
["ViewFormURL"] = "/Form/KLPurchaseRequestApproval.Form",
["PositiveOutcome"] = "Endorse",
["NegativeOutcome"] = "Reject"
};
// Act
sut.Process();
// Assert
k2.Verify(x =>
x.StartInstance(It.IsAny<string>(),
It.Is<Dictionary<string, object>>(d =>
data.Keys.All(k => d[k] == data[k])))
, Times.Once());
}
}
For some reasons, when i run this test, i'm getting the following error:
System.InvalidOperationException: No data found for BlackBox.Stakhanov.Broker.Test.PrBatchEndorseBrokerTest.Process_ValidContext_CallsK2Workflows
I tried many things and i can't make it work! I think i'm missing something big and probably obvious!
Packages I'm using:
<package id="AutoFixture" version="3.47.8" targetFramework="net452" />
<package id="AutoFixture.AutoMoq" version="3.47.8" targetFramework="net452" />
<package id="AutoFixture.Xunit" version="3.47.8" targetFramework="net461" />
<package id="Castle.Core" version="3.3.3" targetFramework="net461" />
<package id="Moq" version="4.5.10" targetFramework="net461" />
<package id="xunit" version="2.1.0" targetFramework="net461" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
<package id="xunit.assert" version="2.1.0" targetFramework="net461" />
<package id="xunit.core" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensions" version="1.9.0.1566" targetFramework="net461" />
When using xUnit.net 2, you should use AutoFixture.Xunit2, not AutoFixture.Xunit.
You'll notice in your package list that you have xunit.extensions version 1.9.0.1566, which isn't compatible with xUnit.net 2.

Error running XUnit tests in VS2013 / ReSharper 8 - xunit.dll not found

I've upgraded all the xUnit NuGet packages in my solution to XUnit 2.1 in the hope of fixing some problems I had running my xUnit tests, but I'm getting the same problem as before, which is:
[Window Title]
Unit Test Runner
[Main Instruction]
Unit Test Runner failed to run tests
[Content]
System.ArgumentException: Could not find file: C:\Users\myuser\mysolution\myproject\bin\Debug\ xunit.dll
[Expanded Information]
at Xunit.ExecutorWrapper..ctor(String assemblyFilename, String configFilename, Boolean shadowCopy)
at XunitContrib.Runner.ReSharper.RemoteRunner.TestRunner.Run(XunitTestAssemblyTask assemblyTask, TaskProvider taskProvider)
at XunitContrib.Runner.ReSharper.RemoteRunner.XunitTaskRunner.ExecuteRecursive(TaskExecutionNode node)
at JetBrains.ReSharper.TaskRunnerFramework.StartupTaskRunnerHost.Execute(TaskExecutionNode node)
I've tried un-installing, re-installing, cleaning and rebuilding, etc. etc. for hours and got nowhere.
I'm using Visual Studio 2013 update 5, ReSharper 8.2.1, and have installed the following NuGet packages:
<package id="xunit" version="2.1.0" targetFramework="net451" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net451" />
<package id="xunit.assert" version="2.1.0" targetFramework="net451" />
<package id="xunit.core" version="2.1.0" targetFramework="net451" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net451" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net451" />
<package id="xunit.MSBuild" version="2.0.0.0" targetFramework="net451" developmentDependency="true" />
<package id="xunit.runner.msbuild" version="2.1.0" targetFramework="net451" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net451" />
To be fair, there is no file called xunit.dll in the bin folder, but... I've installed everything I can find, and I'm at a loss as to what else I can do.
Suggestions very welcome.
You will need to update Resharper extensions for XUnit, I had the same error and I had to do Resharper > Extension Manager > Updates you will see that you have one XUnit update after updating restart visual studio and it should run your tests.

NuGet Boost include not working

I have a problem with NuGet and boost. I have installed boost library and boost_thread library and used them before without any problems in my project.
After installing boost_serialization and pulling changes from my git master repo my project broke.
Here is the git diff from the packages.config file:
1 <?xml version="1.0" encoding="utf-8"?>
2 <packages>
- <package id="boost" version="1.54.0.157" targetFramework="Native" />
- <package id="boost_chrono-vc110" version="1.54.0.157" targetFramework="Native" />
- <package id="boost_date_time-vc110" version="1.54.0.157" targetFramework="Native" />
- <package id="boost_system-vc110" version="1.54.0.157" targetFramework="Native" />
- <package id="boost_thread-vc110" version="1.54.0.157" targetFramework="Native" />
3 + <package id="boost" version="1.55.0.10" targetFramework="Native" />
4 + <package id="boost_chrono-vc110" version="1.55.0.10" targetFramework="Native" />
5 + <package id="boost_date_time-vc110" version="1.55.0.10" targetFramework="Native" />
6 + <package id="boost_serialization-vc110" version="1.55.0.10" targetFramework="Native" />
7 + <package id="boost_system-vc110" version="1.55.0.10" targetFramework="Native" />
8 + <package id="boost_thread-vc110" version="1.55.0.10" targetFramework="Native" />
9 </packages>
Relevant section of git diff from the vcxproj file:
<ImportGroup Label="ExtensionTargets">
- <Import Project="packages\boost.1.54.0.157\build\native\boost.targets" Condition="Exists('packages\boost.1.54.0.157\build\native\boost.targets')" />
- <Import Project="packages\boost_thread-vc110.1.54.0.157\build\native\boost_thread-vc110.targets" Condition="Exists('packages\boost_thread-vc110.1.54.0.157\build\native\boost_thread-vc110.targets')" />
- <Import Project="packages\boost_system-vc110.1.54.0.157\build\native\boost_system-vc110.targets" Condition="Exists('packages\boost_system-vc110.1.54.0.157\build\native\boost_system-vc110.targets')" />
- <Import Project="packages\boost_date_time-vc110.1.54.0.157\build\native\boost_date_time-vc110.targets" Condition="Exists('packages\boost_date_time-vc110.1.54.0.157\build\native\boost_date_time-vc110.targets')" />
- <Import Project="packages\boost_chrono-vc110.1.54.0.157\build\native\boost_chrono-vc110.targets" Condition="Exists('packages\boost_chrono-vc110.1.54.0.157\build\native\boost_chrono-vc110.targets')" />
+ <Import Project="packages\boost_chrono-vc110.1.55.0.10\build\native\boost_chrono-vc110.targets" Condition="Exists('packages\boost_chrono-vc110.1.55.0.10\build\native\boost_chrono-vc110.targets')" />
+ <Import Project="packages\boost_date_time-vc110.1.55.0.10\build\native\boost_date_time-vc110.targets" Condition="Exists('packages\boost_date_time-vc110.1.55.0.10\build\native\boost_date_time-vc110.targets')" />
+ <Import Project="packages\boost_system-vc110.1.55.0.10\build\native\boost_system-vc110.targets" Condition="Exists('packages\boost_system-vc110.1.55.0.10\build\native\boost_system-vc110.targets')" />
+ <Import Project="packages\boost_thread-vc110.1.55.0.10\build\native\boost_thread-vc110.targets" Condition="Exists('packages\boost_thread-vc110.1.55.0.10\build\native\boost_thread-vc110.targets')" />
+ <Import Project="packages\boost_serialization-vc110.1.55.0.10\build\native\boost_serialization-vc110.targets" Condition="Exists('packages\boost_serialization-vc110.1.55.0.10\build\native\boost_serialization-vc110.targets')" />
+ <Import Project="packages\boost.1.55.0.10\build\native\boost.targets" Condition="Exists('packages\boost.1.55.0.10\build\native\boost.targets')" />
</ImportGroup>
It seems like the version of the dependency was updated too. I tried to change it back to 1.54 but it didn't solve the problem either. I get errors like:
IntelliSense: cannot open source file "boost/archive/text_oarchive.hpp"
I tried including it with both
#include <boost/archive/text_oarchive.hpp>
and
#include "boost/archive/text_oarchive.hpp"
How do I solve this?
EDIT1: Additional info is, that I have started using GitHub instead of TortoiseGit. Don't know if this matters.
The problem got solved by reinstalling the NuGet extension.