chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
This test method was working in 8.8 but isn't in 9.1.2, not sure what changed - or more specifically  what is the correct way? Here is a sample test - it only fails to verify the close was called on the file stream:

[TestMethod]

        public void TestMethod1()

        {

            FileStream fakeFs = Isolate.Fake.AllInstances<FileStream>();

            Isolate.WhenCalled(() => File.Open("", FileMode.Create)).DoInstead((context) =>

            {

                string path = context.Parameters[0] as string;

                return new FileStream(path, FileMode.Create);

            });

            

            Isolate.WhenCalled(() => fakeFs.Close()).DoInstead((context) =>

            {

                Debug.WriteLine("place holder");

            });

            Isolate.WhenCalled(() => File.Delete("")).IgnoreCall();

            string directoryName = Directory.GetCurrentDirectory();

            string testFile = Path.Combine(directoryName, "Testfile808.txt");

            FileStream fs = File.Open(testFile, FileMode.Create);

            fs.Close();

            File.Delete(testFile);

            Isolate.Verify.WasCalledWithAnyArguments(() => File.Open("", FileMode.Create));              

            Isolate.Verify.WasCalledWithAnyArguments(() => File.Delete(""));

            Isolate.Verify.WasCalledWithAnyArguments(() => fakeFs.Close());

        }
closed with the note: Issue was fixed, patch was provided and fix will be implemented in next release.
asked by meansala (2.6k points)
closed by Alon_TypeMock

1 Answer

0 votes

Hi Meansala,

Thank you for the input ,we will invistage it and keep you posted.

Can you please describe your environment?
E.g, IDE, .Net Core or Framework or .NET?

Cheers,
Alon Sapozhnikov.
Support Specialist.

answered by Alon_TypeMock (8.5k points)

I am using .net framework 4.6.1 running in VS2019. 

Hi Meansala,

We were able to reproduce the issue and we are working on fixing it as we speak.

I will keep you posted on any progress we have.

Cheers,
Alon Sapozhnikov.
Support Specialist.

...