All Questions
2,063
questions
0
votes
0
answers
35
views
System.NotSupportedException while testing function with Extension methods
when i call function for testing with given below code:
[Fact]
public async Task CreateEntryInDBSuccess()
{
//Arrange
var expectedResult = "Message ...
-1
votes
1
answer
55
views
Assert.Equal() Failure in xunit tesing
given below was my code for xuit tesing
[Fact]
public async Task ProcessRequestTestNotFoundObjectResult()
{
//Arrange
var mockedRequesBody = new ...
0
votes
0
answers
21
views
Write XUnit.net test results on trx file
I want to write XUnit.net test results on trx file everytime that tests are executed, currently on .net 8 using VS 2022.
So, I've red Microsoft docs about runsettings file and, as far as I understood, ...
0
votes
0
answers
36
views
error while use a await for async function call from a xunit testing [closed]
In below code if i add any await im getting error i don't know why
Xunit class:
public class EventTriggerServiceTest
{
private readonly Mock<ILogger<EventTriggerService>> ...
1
vote
0
answers
58
views
How can I add code coverage in a DTO class?
I'm newbie in testing and received a notification from SonarCloud telling me that my DTO do not have any coverage, as it's just a class (a set of classes) I use for deserializing json I'm completely ...
0
votes
0
answers
17
views
Is it possible to debug test case in xunit with option "Run untill failure"
I'm using Visual Studio 2022 & I am using TDD approach in my code with Xunit & Bogus to generate dummy data.
I want to check for unit test cases to ensure it can handle any type of desired ...
0
votes
1
answer
13
views
Verify.Attributes.cs(14,12): Error CS0579 : Duplicate 'VerifyXunit.UseVerifyAttribute' attribute
I recently added Verify for xUnit to my test project. Now it fails to compile:
Verify.Attributes.cs(14,12): Error CS0579 : Duplicate 'VerifyXunit.UseVerifyAttribute' attribute
I tried downgrading to ...
0
votes
0
answers
18
views
Do I need to create a custom authentication handler for my integration tests in .NET if I use KeyCloak in my application?
I'm currently working on a .NET application that uses Keycloak for authentication. For my integration tests, I want to avoid actually connecting to the Keycloak server to keep the tests fast and ...
0
votes
0
answers
22
views
Integration Tests with Custom Authentication in ASP.NET Core Returning 401 Unauthorized
Description:
I'm setting up integration tests for an ASP.NET Core application using the minimal hosting model in .NET 6. I am trying to mock the authentication process using a custom authentication ...
-1
votes
0
answers
34
views
How to Moq and test a class that gets IOptions injected and has method that calls a SQL Server stored procedure
Say I have a basic "service" class that looks something like this. One of the methods uses SqlClient to make a connection to a SQL Server database and make a stored procedure call and ...
0
votes
0
answers
34
views
.Net 8 XUnit: Mocking MySql connection and different service implementation for unit testing
I'm working on a .Net 8 API and I'm currently creating tests, and my concern is about mocking the connection to the MySql database.
We use CQRS (Mediator pattern) and in the queries handler (what I ...
0
votes
2
answers
81
views
Testing concurrency of a collection with XUnit provides different results
I have a concurrent class called ClientManager that uses a hashset and a ReadWriterLock to register my "clients" through their Guid:
internal class ClientManager : IClientManager
{
...
1
vote
0
answers
34
views
Code coverage for Attributes with dotCover and C#
We use dotCover (by Jetbrains). We have some custom attributes on properties of models and dotCover shows they are not covered by tests. I tried a number of ways to make tests for them but dotCover ...
0
votes
0
answers
50
views
How to Use WebApplicationFactory with Testcontainers for SpecFlow Tests?
I'm working on a .NET project where I want to integrate WebApplicationFactory with Testcontainers to use PostgreSQL for my SpecFlow tests. I'm facing some challenges ensuring that the PostgreSQL ...
1
vote
2
answers
54
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 ...