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

Add UpDownBase tests and related Control tests #2457

Open
wants to merge 2 commits into
base: master
from

Conversation

@hughbe
Copy link
Contributor

hughbe commented Dec 2, 2019

Proposed Changes

  • Add UpDownBase tests and related Control tests
Microsoft Reviewers: Open in CodeFlow
@hughbe hughbe requested a review from dotnet/dotnet-winforms as a code owner Dec 2, 2019
@hughbe hughbe force-pushed the hughbe:UpDownBase-tests branch 2 times, most recently from ddc6bfe to a6bca84 Dec 2, 2019
Copy link
Member

RussKie left a comment

Do you auto-generate the tests? 😀

👍 with few small comments

@hughbe hughbe force-pushed the hughbe:UpDownBase-tests branch from a6bca84 to 668ed9c Dec 3, 2019
Copy link
Member

RussKie left a comment

Happy with tests, but I am not convinced that the removal of the asserts is justified

@@ -501,7 +501,6 @@ public AccessibleObject AccessibilityObject
// ControlAccessibleObject and not some other derived class
if (!(accessibleObject is ControlAccessibleObject))
{
Debug.Fail("Accessible objects for controls must be derived from ControlAccessibleObject.");

This comment has been minimized.

Copy link
@RussKie

RussKie Dec 4, 2019

Member

Why is this being removed?

/cc: @M-Lipin @vladimir-krestov

This comment has been minimized.

Copy link
@hughbe

hughbe Dec 4, 2019

Author Contributor

Can happen in following test

public static IEnumerable<object[]> AccessibilityObject_CustomCreateAccessibilityInstance_TestData()
{
    yield return new object[] { null, null };
    yield return new object[] { new AccessibleObject(), null };

    var controlAccessibleObject = new Control.ControlAccessibleObject(new Control());
    yield return new object[] { controlAccessibleObject, controlAccessibleObject };
}

[WinFormsTheory]
[MemberData(nameof(AccessibilityObject_CustomCreateAccessibilityInstance_TestData))]
public void Control_AccessibilityObject_GetCustomCreateAccessibilityInstance_ReturnsExpected(AccessibleObject result, AccessibleObject expected)
{
    using var control = new CustomCreateAccessibilityInstanceControl
    {
        CreateAccessibilityResult = result
    };
    Assert.Same(expected, control.AccessibilityObject);
    Assert.Same(control.AccessibilityObject, control.AccessibilityObject);
    Assert.False(control.IsHandleCreated);
}

private class CustomCreateAccessibilityInstanceControl : Control
{
    public AccessibleObject CreateAccessibilityResult { get; set; }

    protected override AccessibleObject CreateAccessibilityInstance() => CreateAccessibilityResult;
}
@hughbe hughbe force-pushed the hughbe:UpDownBase-tests branch 2 times, most recently from 2274823 to 4ef992f Dec 4, 2019
@hughbe hughbe force-pushed the hughbe:UpDownBase-tests branch from 4ae351b to 81cd6cc Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.