Skip to content

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

Open
@skimlik

Description

@skimlik

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions