xunit Questions

4

So, I created a .net core middleware that adds a header to a response. I am not finding a way to unit test this middleware, as it uses the OnStarting callback and I can't imagine how to mock or for...
Coalfield asked 3/1, 2020 at 18:15

2

When running test from command line (dotnet test) in a .net 5.0 project using xunit all tests seems to pass but the process crashes with the following message from the detailed verbosity of dotnet ...
Freewill asked 9/8, 2021 at 13:17

4

I want to mock QueueMessage for unit test,but I can not find any lib to mock public async Task<QueueMessage[]> ReceiveMessagesAsync(QueueClient queue) { QueueProperties properties = queu...
Eldest asked 7/8, 2020 at 9:12

8

I have a test class with a constructor that needs an IService. public class ConsumerTests { private readonly IService _service; public ConsumerTests(IService servie) { _service = service; } ...
Alenealenson asked 24/8, 2016 at 19:5

2

Solved

I use serilog in my projects with the static logger approach - it's nice and easy to be able to call Log.X on my class libraries rather than injecting a logger class everywhere. However when it co...
Jasik asked 18/11, 2019 at 11:38

2

Solved

I have this example test using xUnit: [Fact] public void SomeTest() { Assert.All(itemList, async item=> { var i = await Something(item); Assert.Equal(item,i); }); } Is there a good s...
Ina asked 26/7, 2016 at 17:32

4

Solved

The latest xunit framework does not allow test runners in library code when compiled with .Net Core framework (this is allowed for normal Visual Studio code). The solution is to create a separate t...
Sidhu asked 4/1, 2017 at 11:14

1

I have a Azure blob container which I am accessing using below code - var blobContainerClient = GetBlobContainer(containerName); if (blobContainerClient != null) { // List all blobs in the cont...
Emoryemote asked 6/6, 2022 at 13:10

8

Solved

I have in my test suite a test that goes something like this: [Fact] public void VerifySomeStuff() { var stuffCollection = GetSomeStuff(); Assert.Equal(1, stuffCollection.Count()); } This tes...
Cheroot asked 9/10, 2017 at 19:19

7

Solved

I am using XUnit framework to test my C# code. Is there any assert method available in this framework which does the object comparison? My intention is to check for equality of each of the object'...
Isabelisabelita asked 21/6, 2012 at 9:31

2

xUnit offers the concept of (shared) class fixtures as explained in Shared Context between Tests. What I didn't figure out so far is if there is a way of parametrizing such class fixtures. For exam...
Corneliacornelian asked 12/11, 2020 at 8:15

2

I am using .NET Core 3.1 in my project (web api, VS2019) and XUnit 2.4.1. Recently I was thinking about adding some performance tests and I came accross this library - BenchmarkDotNet. Since I've a...
Chameleon asked 24/3, 2020 at 10:4

4

I don't understand why my test returns : System.InvalidOperationException : The test method expected 1 parameter value, but 0 parameter values were provided. Exception doesn't have a stacktrace...
Concomitance asked 21/2, 2018 at 11:39

3

Solved

Background: I am trying to run a C# unit test (test is using Xunit Framework), and my requirement is to run a single unit test and not all the tests in the whole dll. Things I tried: I have tried f...
Ouzel asked 15/7, 2020 at 18:26

2

I've got a class that I'm trying to unit test but it uses a DaprClient object (from the SDK), which doesn't work in my unit test envioronment. I would like to create a mock and use that instead but...
Snead asked 13/7, 2021 at 12:29

4

Solved

Context in XUnit github I found this: Add Assert.Equal(expected, actual, message) overload #350 (so a developer ask for a non existing overload see below) Quote from the answer: We are a belie...
Patrology asked 13/2, 2017 at 11:39

3

I am writing unit tests and I have something that looks like this: [Fact] public void GetFoos_only_gets_foo1() { _foo1.included = true; //Foo object _foo2.included = false; //Foo object _sut.Get...
Footed asked 20/7, 2015 at 20:8

1

I'm trying to validate a GoogleTest (gtest) XML output file, and for that I need the schema/XSD for the gtest format. I've searched online, and could not find anything. A lot seems to point at the...
Pattani asked 12/5, 2015 at 13:39

3

I've downloaded the latest VS2022 v17.1 Community Edition and it doesn't come with Code Coverage in-built. I'm accustomed to the Enterprise Edition and all I can find is paid options for the Commun...
Flitting asked 12/12, 2021 at 6:36

11

Solved

I'm learning xUnit and so far, have found it to be a most useful tool. It's making me rethink some of my coding tactics to TDD instead. However, I've come across an interesting problem. My test ca...
Urethritis asked 26/6, 2012 at 10:45

2

I want to run my tests sequentially as they change the same database and may affect one another. I have tried many solutions on the internet but none of them works for me. These solutions are descr...
Sacrosanct asked 13/5, 2020 at 15:26

1

In .net core 6, startup.cs has been removed, the integration testing I used before doesn't work anymore as is. I need to do an update. In my API (program.cs), I added: [assembly: InternalsVisibleTo...
Weirick asked 11/8, 2022 at 9:15

3

Solved

I want to test GetMoviesAsync of my Controller. I don't know where I am doing wrong in my Moq setup. I am getting 0 item from GetMoviesAsync. What am I doing wrong? // Api-Controller: public inter...
Halflife asked 2/1, 2019 at 13:48

2

Solved

I am using xUnit and Moq for writing test cases. I am using the code below to create a Mock but am getting the highlighted issue. CloudBlockBlob source = null; AccessCondition sourceAccessConditio...
Tensor asked 12/7, 2019 at 6:49

7

Solved

.NET Core configuration allows so many options to add values (environment variables, json files, command line args). I just can't figure out and find an answer how to populate it via code. I am wri...

© 2022 - 2024 — McMap. All rights reserved.