Questions tagged [xunit.net]

xUnit.net is a unit testing tool for the .NET Framework. Written by the original inventor of NUnit, xUnit.net is the latest technology for unit testing C#, F#, VB.NET and other .NET languages. It works with ReSharper, CodeRush, and TestDriven.NET.

Written by the original inventor of NUnit v2, xUnit.net is the latest technology for unit testing C#, F#, VB.NET and other .NET languages. xUnit.net works with ReSharper, CodeRush, TestDriven.NET and Xamarin

See more at http://xunit.github.io/

1001 questions
-1
votes
1 answer

Why is my DbContext being disposed? How can I stop it or work around it?

I am getting an ObjectDisposedException on my dbContext object on the last line of this unit test: public class InvoiceRepository_Tests : AppTestBase { [Fact] public async Task Test_InsertAndQuery() { var invoiceRepository =…
Rupert Morrish
  • 785
  • 2
  • 10
  • 18
-1
votes
1 answer

Moq, unit test using xUnit framework and testing a function returning an object

I have a repository public class StudentsPersonalDetailsRepository : IStudentPersonalDetailsRepository { private readonly StudentManagementSystemEntities _studentsDbContext; private readonly ILogger _logger; public…
-1
votes
1 answer

Before Suite initialization in Xunit (C#)

Updated question :: I want to set up data before any Test in the test suite is run using xUnit.net. I tried IUseFixture but its run before any test class is run (not before the test suite) Consider your suite has 2 test classes having 2 tests/class,…
user522170
  • 623
  • 1
  • 6
  • 21
-2
votes
1 answer

how to throw an exception using Assert.Throws in Xunit

i am trying to write a test case using Xunit where i want check if the text i am passing is not expected one throw exception saying the value should be the same only Here is my code [Theory] [InlineData("Goods","Goods")] …
shreyas35
  • 145
  • 9
-2
votes
1 answer

How to write testcases using Xunit test for extension method like Any

Actually this is my service layer. I want to test a create account method by Xunit testing. How can I proceed further? public class UserService :IUserService // service { #region Property private readonly IAppDbContext _appDbContext; …
-2
votes
1 answer

Selenium xUnit not working consistently with IE

I'm creating tests using Visual Studio/Selenium/xUnit and I've just come across a command that doesn't work in IE. I have a screen with a list of items, each with a checkbox to it's left and I need to check that checkbox and then click on Save. I've…
Ben_G
  • 770
  • 2
  • 8
  • 30
-2
votes
1 answer

Azure Function unit test issue

While writing unit tests to Azure Functions how to set Environment variables? Below is a given sample code where the original function gets SQL connection string from the Environment variables using key sqldb_conn. namespace LoanData.API { …
Josh
  • 89
  • 9
-2
votes
1 answer

Should simple classes be mocked in unit-tests or should they be used/tested directly?

I'm unsure of what else can be tested for my method TranslateResponse() . It basically checks the type of translator and calls the translator's associated set() method. public async Task TranslateResponse(Policy response) { foreach (var t in…
Raida Adn
  • 405
  • 1
  • 6
  • 17
-2
votes
1 answer

Mocking up an Interface as more than one types

Why this code doesn't work? var channelsList = new List { Mock.Of(m => m == new ChannelOne()), Mock.Of(m => m == new ChannelTwo()), };
anatol
  • 1,680
  • 2
  • 24
  • 47
-2
votes
2 answers

xUnit Testing says System.NullReferenceException

Good day, I'm begginer in xUnit and I'm facing this error that says, "System.NullReferenceException : Object reference not set to an instance of an object." Here's my code where it tests whether a rulename depending on the season. public class…
jsonGPPD
  • 987
  • 4
  • 16
  • 31
-4
votes
1 answer

C# Trigonometry (HELP!)

Ok so here's the situation... I'm currently working on a project for my Math and Physics for Games class. I finished coding my solution, and ran the xUnit tests that my teacher made for us. 90% of them fail. I have a Calculator.cs file that contains…
Pierre Gravelle
  • 53
  • 2
  • 15
1 2 3
66
67