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

Simplify HasCorrectTimeout #4042

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SimonCropp
Copy link
Contributor

it was never called with a null value. so move it to a calculated property on the attribute

Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assigning @nohwnd for review

/// <summary>
/// Gets a value indicating whether the instance has the correct test timeout signature.
/// </summary>
internal bool HasCorrectTimeout { get; private set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal preference here is to keep the constructors as they were before and switch this to:

Suggested change
internal bool HasCorrectTimeout { get; private set; }
internal bool HasCorrectTimeout => Timeout > 0;

Comment on lines -255 to -265
public void HasCorrectTimeoutShouldReturnFalseForMethodsWithInvalidTimeoutAttribute()
{
MethodInfo methodInfo = typeof(DummyTestClass).GetMethod("PublicMethodWithInvalidTimeout");
Verify(!methodInfo.HasCorrectTimeout());
}

public void HasCorrectTimeoutShouldReturnTrueForMethodsWithTimeoutAttribute()
{
MethodInfo methodInfo = typeof(DummyTestClass).GetMethod("PublicMethodWithTimeout");
Verify(methodInfo.HasCorrectTimeout());
}
Copy link
Member

@Youssef1313 Youssef1313 Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests should probably be replaced by:

    public void HasCorrectTimeoutShouldReturnFalseForMethodsWithInvalidTimeoutAttribute()
    {
        var timeoutAttribute = new TimeoutAttribute(-11);
        Verify(!timeoutAttribute.HasCorrectTimeout);
    }

    public void HasCorrectTimeoutShouldReturnTrueForMethodsWithTimeoutAttribute()
    {
        var timeoutAttribute = new TimeoutAttribute(11);
        Verify(timeoutAttribute.HasCorrectTimeout);
    }

Also, now PublicMethodWithInvalidTimeout and PublicMethodWithTimeout are unused I think

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

Successfully merging this pull request may close these issues.

3 participants