All Questions
508
questions
3
votes
2
answers
80
views
Can you test whether a function is actually running Asynchronously?
I'm working on a ASP.NET Web Api project to learn the framework and the testing for it and I was wondering if you could test that Asynchronous methods are actually running Asynchronously (or are they ...
1
vote
2
answers
48
views
How can I write a test with Xunit that accepts an enum as parameter?
I try to write a test that looks like this:
private static readonly IEnumerable<MyEnumType> ListOfEnumValues = Enum.GetValues(typeof(MyEnumType)).Cast<DocumentType>();
private static ...
0
votes
1
answer
21
views
Can I use built-in Microsoft DI in unit tests for init objects?
in unit tests for init and create the objects I would like to use buit-in Microsoft DI, is it good practice?
0
votes
0
answers
17
views
Writing a test method for an async service layer method
I have a repository layer that does a few CRUD operations. I want to write unit tests for the methods in this class to make sure they work as expected etc.
Here is my repository layer:
using Microsoft....
3
votes
0
answers
61
views
Problems discovering tests automatically using the TestPlatform in .NET
I am developing a unit testing framework with C#. I am using the official Microsoft.TestPlatform library and I have already implemented ITestDiscoverer and ITestExecutor.
What I am using to determine ...
0
votes
1
answer
124
views
How to mock classes with factory methods in Substitute? (for using ForPartsOf to keep default behaviour while still checking received calls)
I want to mock a Logger using NSubstitute. But instead of using Substitute.For, I want to use Substitute.ForPartsOf to:
both call the real implementation (to continue logging to the console)
and ...
1
vote
1
answer
132
views
List of tests in the project
I am writing a small C# project that will count the coverage of all tests individually in a project with tests C#. To do this, I need to get a list of all the tests in the project in the ...
1
vote
1
answer
55
views
MSTest - What is the difference between writing messages directly to StdOut and using TestContext?
I'm trying to figure out a good way to log messages to the console / test explorer / pipeline execution logs when running my MSTest Test Project.
I've noticed that you can either write the output to ...
2
votes
1
answer
491
views
Capture multiple arguments with NSubstitute
I am using NSubstitute to write a unit test, and am trying to capture multiple method arguments passed in a method call.
I understand that I can capture a single argument using the Arg.Do<T>() ...
1
vote
1
answer
211
views
How to show Console.WriteLine's message in VsCode Testing in C#
I have a MSTest project in my solution like this:
[TestClass]
public class Tests{
[TestMethod]
public void Test1(){
var result = "Hello 1";
Console.WriteLine(result);
...
0
votes
1
answer
89
views
How do I correctly design my classes so that internal logic is unit testable?
I'm struggling to figure out how to correctly design code in a large codebase so that pieces of internal logic can be easily testable. Here's a made up example:
public class SomeService
{
public ...
0
votes
0
answers
47
views
How to make a unit test with SignInManager in .NET 6: Method not found
Here is my test that I try to make it pass:
private ComptesController _comptesController;
private SignInManager<ApplicationUser> _signInManager;
private UserManager<...
0
votes
0
answers
57
views
Problem displaying parameters in the Azure Deovps test report
Problem Description:
I am encountering an issue while running automated Selenium tests in Azure DevOps. The tests are running with various parameters, and they display correctly in Visual Studio. ...
0
votes
1
answer
42
views
How to Convert IEnumerable<T> to Task<IEnumerable<T>>for test mock's result? [duplicate]
I'm testing a repository methods with 'Mock'. To accomplish this goal, I created a IList lists with the T model I'm testing(in this case a subject). However some of the methods return Task<...
-1
votes
1
answer
27
views
How to create Moq for "Update a property of concrete class in a method using injected interface method"
I have this concrete class which implements an interface
internal interface ITableAdapter
{
int CustomFill(Dataset dataset, ...);
}
internal interface IEntityRetriever
{
IEntity RetriveEntity();
}...