You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug NSubstitute.Exceptions.UnexpectedArgumentMatcherException should be thrown for a test, however it is only thrown when the test is run in succession after another test.
To Reproduce
Run A() and B() by themselves, both will pass.
Run A() and B() by right clicking in the .cs file and selecting "Run all tests" -> only A() will pass.
using NSubstitute;
using NUnit.Framework;
using System;
namespace Tests
{
[TestFixture]
public class CreditorMapperTests
{
private IAbcContext _AbcContext;
[SetUp]
public void Setup()
{
_AbcContext = Substitute.For<IAbcContext>();
_AbcContext.CompanyInfo.Returns(x => new CompanyInfo(Arg.Any<Guid>()));
}
[Test]
public void A()
{
Creditor publishDocument = new Creditor();
publishDocument.CompanyExternalId = _AbcContext.CompanyInfo.UniqueId;
}
[Test]
public void B()
{
Creditor publishDocument = new Creditor();
publishDocument.CompanyExternalId = _AbcContext.CompanyInfo.UniqueId;
}
}
public interface IAbcContext
{
CompanyInfo CompanyInfo { get; }
}
public class CompanyInfo
{
public CompanyInfo(Guid uniqueId)
{
UniqueId = uniqueId;
}
public readonly Guid UniqueId;
}
public class Creditor
{
public Guid CompanyExternalId { get; set; }
}
}
Expected behaviour
Both tests should throw the Exception, regardless of whether or not they were run individually, or as part of the "Run all tests in file".
Environment:
NSubstitute version: [4.2.1]
NSubstitute.Analyzers version: [CSharp 1.0.1.0]
Platform: [.NET Core 2.2, Windows 10]
The text was updated successfully, but these errors were encountered:
Describe the bug
NSubstitute.Exceptions.UnexpectedArgumentMatcherException
should be thrown for a test, however it is only thrown when the test is run in succession after another test.To Reproduce
Run A() and B() by themselves, both will pass.
Run A() and B() by right clicking in the .cs file and selecting "Run all tests" -> only A() will pass.
Expected behaviour
Both tests should throw the Exception, regardless of whether or not they were run individually, or as part of the "Run all tests in file".
Environment:
The text was updated successfully, but these errors were encountered: