Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
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 ...
Harikarthik's user avatar
-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 ...
Harikarthik's user avatar
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, ...
federico D'Armini's user avatar
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>> ...
Harikarthik's user avatar
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 ...
wutangcodeclan's user avatar
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 ...
Parth Kanzariya's user avatar
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 ...
Sascha's user avatar
  • 10.3k
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 ...
Hasan Kanaan's user avatar
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 ...
Hasan Kanaan's user avatar
-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 ...
bitshift's user avatar
  • 6,570
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 ...
Diego Perez's user avatar
  • 2,588
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 { ...
Rayane Hindi's user avatar
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 ...
s.d.90's user avatar
  • 13
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 ...
Hasan Kanaan's user avatar
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 ...
MrMaavin's user avatar
  • 1,719

15 30 50 per page
1
2 3 4 5
138