Questions tagged [nunit]
NUnit is an open source unit testing framework for .NET written in C#. It serves the same purpose as JUnit or TestNG does in the Java world, and is one of many in the xUnit family.
nunit
7,513
questions
1
vote
2
answers
31
views
How to mock IConfiguration.GetSection("foo").get<Type>();
I am new to unit testing...
I have a class Settings.cs,
public class Settings
{
public string Format { get; set; }
}
and this is what the appSettings.json contains,
"AppSettings": {
...
0
votes
0
answers
10
views
How can I fix this NUnit testing issue?
I have test data and test like this below:
private static TestDataClass[] _data =
[
new() {Id = 10, ..},
new() {Id = 20, .. },
...
new() {Id = 170, .. }
]
[Test]
[...
0
votes
0
answers
11
views
How to handle modal dialog using C# and VUEJS in selenium webdriver?
DuplicateCancel
In the html below, How to handle the button "Duplicate" in a modal box using C# and Web Driver based on VUEJS?
0
votes
0
answers
13
views
Run MSTest programmatically
I have an existing library containing unit tests. I want to transform that library into a service that periodically runs the unit tests and emit metrics. I solved the bits to create a service and to ...
-1
votes
0
answers
15
views
nnUNet - how can I run a prediction on a test set that was extracted from a different tif file than the training set?
I am doing image segmentation in 2D using nnUNet. I have 3D tif files, images and masks.
in ordrer to train the model and make the data fit to the pipeline of nnUNet I am slicing the tif files so each ...
0
votes
0
answers
18
views
How to use one namespace into an another namespace in same solution?
I'm facing one issue . How to use one namespace into an another namespace in same solution?
I'm attached the code for your reference.
using namespace Dapper
{
namespace DapperTest.Repositories
...
0
votes
0
answers
31
views
How to load env vars from .env before running C# tests through VS Code
I am trying to get rid of the .runsettings file which I have in my project repo and keep all my config variables in a single .env file.
The one place where I am stuck in is in the scenario when ...
0
votes
1
answer
64
views
"Code Coverage Results" Missing in Visual Studio
I'm really new to testing, just starting out. I understood there should be a tab "Code Coverage Results" which can be opened from the Test tab, or by right-clicking on a test, but it doesn't ...
0
votes
0
answers
15
views
Nunit 4 assert text does not have assert statment inside () Eeg.: Assert.That(, )
c# net4.6.2 + nunit 4.1
test code
[Test]
public void DummyMethod()
{
var someVar = false;
Assert.Multiple(() =>
{
...
0
votes
0
answers
43
views
Wrong Appsettings.json picked at build with Unit test project referencing another project with its own appsettings
With Visual Studio 2022 in C#, we are referencing from our Unit tests project another project which is a WebApplication.
The web application is tested using Microsoft's WebApplicationFactory ASP.Net ...
0
votes
1
answer
125
views
How to Mock FunctionContext in Azure Isolated worker Model Function .Net 8
I have an Azure function in Isolated worker model type with .Net 8 version . I want to mock the function context for Unit testing.
Below code of Azure Function is given
using Microsoft.AspNetCore.Http;...
0
votes
0
answers
28
views
C# Testing ClassLibary with Nunit - Mising references
I have a classlibary project which i want to test.
When adding a new (Nunit) test project to the solution I get a list of reference errors:
This is my project structure
Test file is rather simple:
...
0
votes
1
answer
37
views
Mocking created object which then added to dictionary
How can I mock object which is created with the action in the runtime? In the following code I want to mock the Connection class for the unit test.
private readonly Dictionary<IPEndPoint, ...
0
votes
1
answer
33
views
NUnit: Mock setup fails if method is setup with actual argument
I have a setup defined like this
Mock<IDeclarationQuery> _declarationQueryMock = new Mock<IDeclarationQuery>();
_declarationQueryMock.Setup(x => x.FindDeclarationDetailAsync(It.IsAny&...
0
votes
0
answers
68
views
Create a function that takes method name and verify if that method was called
I would like to create a method that can take a method name and verify if method was called. I have implemented the following code block and wanted to investigate if there is a better way to do it
...