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

VerifyClearAsync string,string overload does not update output variable #286

Open
skimlik opened this issue Apr 12, 2024 · 2 comments
Open

Comments

@skimlik
Copy link

skimlik commented Apr 12, 2024

Method below

        public async Task<bool> VerifyClearAsync(string input, string output)
        {
            using (Stream inputStream = await input.GetStreamAsync())
            using (Stream outputStream = new MemoryStream())
            {
                bool verified = await VerifyClearAsync(inputStream, outputStream);

                outputStream.Seek(0, SeekOrigin.Begin);
                output = await outputStream.GetStringAsync();
                return verified;
            }
        }
        

should be declared as as

Task<bool> VerifyClearAsync(string input, ref string output)

ref keyword is mandatory, in order to get the output back.
string is an immutable class

STR:

        string actual = string.Empty;
        var verified = await _pgp.VerifyCleanAsync(signed, actual);
        verified.Should().BeTrue(); // pass
        actual.Should().NotBeEmpty(); // fail
        actual.Should().BeEquivalentTo(expected); // fail: Expected actual to be equivalent to "this is a secret text" with a length of 21, but "" has a length of 0, differs near "" (index 0).
@skimlik
Copy link
Author

skimlik commented Apr 12, 2024

I missed, this is async method, you can't use ref keyword in this case.
But it isn't working as expected anyway

@mattosaurus
Copy link
Owner

I've updated the string based VerifyClearAsync method so that it no longer appears to return the message value. I'm not sure if this is the best solution but I don't really want to return a result object containing a bollean a dn string either. I'm open to suggestions if you've got a better way of doing this.

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

2 participants