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

Questions tagged [xunit]

xUnit is the collection name for unit-testing compliant frameworks following a specific architecture. Implementation differs from language to language but the framework should consist of a Test Runner, Test Case, Test Fixture (Context), Test Suite, Test Execution, Test Result Formatter and Assertions

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
0 votes
0 answers
12 views

set value for conditional initializer property in class model

given below was my model: public class RelationContentTypeObject { [JsonProperty("$id")] private string IdField { get; set; } [JsonProperty("$ref")] private string ...
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
29 views

How can I write delete test method for delete action in ASP.NET Core?

I want to write test method for delete action, but I don't know how and I would like the delete test method to be similar to Detail test method (code logic and syntax): // GET: ProductController/...
Zahra etehadi's user avatar
0 votes
0 answers
20 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
0 votes
1 answer
19 views

Collection.Count shows zero even though Collection.GetEnumerator.Current contains a reference after MoveNext()

Note: An answer in either VB.NET or C# will be fine. I have no preference for this Q&A. I'm trying to test my networking code and I'm running into a very strange problem: the GatewayAddresses ...
InteXX's user avatar
  • 6,309
0 votes
0 answers
18 views

Refernce to RouteValueDictionary claims it is defined in System.Web but could not be found

I am currently learning to unit test in ASP.NET MVC, and I have encountered an issue while working on my Controller Test class. The error message states, "Reference to RouteValueDictionary claims ...
Stutee Rath'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
33 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

15 30 50 per page
1
2 3 4 5
219