Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with .Net static methods like File.Exists #70

Open
sberthu opened this issue Jan 17, 2022 · 0 comments
Open

Issue with .Net static methods like File.Exists #70

sberthu opened this issue Jan 17, 2022 · 0 comments

Comments

@sberthu
Copy link

sberthu commented Jan 17, 2022

Hello,
In .Net5 Framework, I have a Xunit Test class like this:

using Pose;
using System.IO;
using Xunit;
public class MyTest {
	public bool test(string path)
	{
		bool ret = File.Exists(path);
		if (!ret)
		{
			throw new FileNotFoundException("Not Found");
		}
		return ret;
    }
	[Fact]
	public void test_shouldSuccess()
	{
		string path = "anyKindOfPath must success";
		Shim shim = Shim.Replace(() => File.Exists(Is.A<string>())).With((string path) => true);

		var result = false;
		
		PoseContext.Isolate(() =>
		{
			result = test(path);
		}, shim);
		// assert
		Assert.True(result);
	}
}

We are ok that the File.Exists in test method is never call and be replace by the lambda wich is always true.
When I run this simple code, I get the Exception "Not Found". The shim seems to be never called like expected.
I run the 2.1 version of Pose downloaded from Github. The 2.1 version in Nuget crash with a "System.InvalidProgramException".
I think this is the .Net Framework Version wich is incompatible with .net 5.0
Thank for your reply

Miista added a commit to Miista/pose that referenced this issue Jan 25, 2024
Release v2.0 to NuGet

Version 2.0 supports the following targets:
* .NET Standard 2.0
* .NET Core 2.0
* .NET Core 3.0
* .NET Framework 4.8
* .NET 7
* .NET 8

Version 2.0 fixes the following issues:
* tonerdo/pose#17
* tonerdo/pose#37
* tonerdo/pose#38
* tonerdo/pose#41
* tonerdo/pose#47
* tonerdo/pose#49
* tonerdo/pose#60
* tonerdo/pose#67
* tonerdo/pose#68
* tonerdo/pose#70
* tonerdo/pose#71
* tonerdo/pose#72
* tonerdo/pose#75
* tonerdo/pose#79
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant