Skip to content

Commit

Permalink
Fix test to not rely on order by which System.Reflection returns prop…
Browse files Browse the repository at this point in the history
…erties.
  • Loading branch information
drieseng authored and scott-xu committed Jan 15, 2022
1 parent 7edad9d commit 1405861
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/Ninject.Test/Unit/Selection/SelectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,47 +322,47 @@ public void SelectPropertiesForInjection_InjectNonPublicIsTrueAndInjectParentPri
_settingsMock.InSequence(_sequence)
.Setup(p => p.InjectParentPrivateProperties)
.Returns(false);
_injectionHeuristicMock1.InSequence(_sequence)
.Setup(p => p.ShouldInject(weaponProperty))
_injectionHeuristicMock1.Setup(p => p.ShouldInject(weaponProperty))
.Returns(true);
_injectionHeuristicMock1.InSequence(_sequence)
.Setup(p => p.ShouldInject(idProperty))
_injectionHeuristicMock1.Setup(p => p.ShouldInject(idProperty))
.Returns(false);
_injectionHeuristicMock2.InSequence(_sequence)
.Setup(p => p.ShouldInject(idProperty))
_injectionHeuristicMock2.Setup(p => p.ShouldInject(idProperty))
.Returns(false);
_injectionHeuristicMock1.InSequence(_sequence)
.Setup(p => p.ShouldInject(nameProperty))
_injectionHeuristicMock1.Setup(p => p.ShouldInject(nameProperty))
.Returns(false);
_injectionHeuristicMock2.InSequence(_sequence)
.Setup(p => p.ShouldInject(nameProperty))
_injectionHeuristicMock2.Setup(p => p.ShouldInject(nameProperty))
.Returns(false);
_injectionHeuristicMock1.InSequence(_sequence)
.Setup(p => p.ShouldInject(enabledProperty))
_injectionHeuristicMock1.Setup(p => p.ShouldInject(enabledProperty))
.Returns(false);
_injectionHeuristicMock2.InSequence(_sequence)
.Setup(p => p.ShouldInject(enabledProperty))
_injectionHeuristicMock2.Setup(p => p.ShouldInject(enabledProperty))
.Returns(false);
_injectionHeuristicMock1.InSequence(_sequence)
.Setup(p => p.ShouldInject(stopProperty))
.Returns(true);
_injectionHeuristicMock1.InSequence(_sequence)
.Setup(p => p.ShouldInject(visibleProperty))
_injectionHeuristicMock1.Setup(p => p.ShouldInject(visibleProperty))
.Returns(false);
_injectionHeuristicMock2.InSequence(_sequence)
.Setup(p => p.ShouldInject(visibleProperty))
_injectionHeuristicMock2.Setup(p => p.ShouldInject(visibleProperty))
.Returns(false);
_injectionHeuristicMock1.Setup(p => p.ShouldInject(stopProperty))
.Returns(true);

#endregion Arrange

var actual = _selector.SelectPropertiesForInjection(type);

Assert.Equal(new[]
{
weaponProperty,
stopProperty
},
actual);
var actualList = actual.ToList();

Assert.Equal(2, actualList.Count);
Assert.Contains(weaponProperty, actualList);
Assert.Contains(stopProperty, actualList);

_injectionHeuristicMock1.Verify(p => p.ShouldInject(weaponProperty), Times.Once);
_injectionHeuristicMock1.Verify(p => p.ShouldInject(idProperty), Times.Once);
_injectionHeuristicMock2.Verify(p => p.ShouldInject(idProperty), Times.Once);
_injectionHeuristicMock1.Verify(p => p.ShouldInject(nameProperty), Times.Once);
_injectionHeuristicMock2.Verify(p => p.ShouldInject(nameProperty), Times.Once);
_injectionHeuristicMock1.Verify(p => p.ShouldInject(enabledProperty), Times.Once);
_injectionHeuristicMock2.Verify(p => p.ShouldInject(enabledProperty), Times.Once);
_injectionHeuristicMock1.Verify(p => p.ShouldInject(visibleProperty), Times.Once);
_injectionHeuristicMock2.Verify(p => p.ShouldInject(visibleProperty), Times.Once);
_injectionHeuristicMock1.Verify(p => p.ShouldInject(stopProperty), Times.Once);
}

[Fact]
Expand Down

0 comments on commit 1405861

Please sign in to comment.