Пример #1
0
            public void Should_BeTrueIfEnabled_MultipleTimes()
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(1, 1);
                errorFlag.SetEnabled(10, 1);
                errorFlag.SetEnabled(666, 1);

                errorFlag.IsEnabledAtAnyLevel.Should().BeTrue();
            }
Пример #2
0
            public void Should_ReturnTrue_And_FirstErrorIdWhenEnabled_When_LevelEnabledAndDetected_SameLevelMultipleTimes()
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(10, 1);
                errorFlag.SetEnabled(10, 2);
                errorFlag.SetEnabled(10, 3);
                errorFlag.SetDetected(10);
                errorFlag.SetDetected(10);
                errorFlag.SetDetected(10);

                var tryResult = errorFlag.LeaveLevelAndTryGetError(10, out var errorOnLeaving);

                errorOnLeaving.Should().Be(1);
                tryResult.Should().BeTrue();
            }
Пример #3
0
            public void Should_BeTrueIfEnabled(int level)
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(level, 1);

                errorFlag.IsEnabledAtAnyLevel.Should().BeTrue();
            }
Пример #4
0
            public void Should_BeFalse_WhenEnabled(int level)
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(level, 1);

                errorFlag.IsDetectedAtAnylevel.Should().BeFalse();
            }
Пример #5
0
            public void Should_BeFalse_AfterLeavingLevel()
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(10, 1);
                errorFlag.LeaveLevelAndTryGetError(10, out _);

                errorFlag.IsEnabledAtAnyLevel.Should().BeFalse();
            }
Пример #6
0
            public void Should_BeFalse_IfDetected_OnLowerLevel(int level)
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(level, 1);
                errorFlag.SetDetected(level - 1);

                errorFlag.IsDetectedAtAnylevel.Should().BeFalse();
            }
Пример #7
0
            public void Should_BeTrue_IfDetected_OnHigherLevel(int level)
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(level, 1);
                errorFlag.SetDetected(level + 1);

                errorFlag.IsDetectedAtAnylevel.Should().BeTrue();
            }
Пример #8
0
            public void Should_BeFalse_AfterLeavingLevel_MultipleTimes()
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(1, 1);
                errorFlag.SetEnabled(10, 1);
                errorFlag.SetEnabled(666, 1);

                errorFlag.IsEnabledAtAnyLevel.Should().BeTrue();

                errorFlag.LeaveLevelAndTryGetError(1, out _);
                errorFlag.IsEnabledAtAnyLevel.Should().BeTrue();

                errorFlag.LeaveLevelAndTryGetError(10, out _);
                errorFlag.IsEnabledAtAnyLevel.Should().BeTrue();

                errorFlag.LeaveLevelAndTryGetError(666, out _);

                errorFlag.IsEnabledAtAnyLevel.Should().BeFalse();
            }
Пример #9
0
            public void Should_ReturnFalse_When_LevelEnabledAndNotDetected()
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(10, 1);

                var tryResult = errorFlag.LeaveLevelAndTryGetError(10, out var errorOnLeaving);

                errorOnLeaving.Should().Be(-1);
                tryResult.Should().BeFalse();
            }
Пример #10
0
            public void Should_ReturnTrue_And_SameErrorIdWhenEnabled_When_LevelEnabledAndDetected(int level, int errorId)
            {
                var errorFlag = new ErrorFlag();

                errorFlag.SetEnabled(level, errorId);
                errorFlag.SetDetected(level);

                var tryResult = errorFlag.LeaveLevelAndTryGetError(level, out var errorOnLeaving);

                errorOnLeaving.Should().Be(errorId);
                tryResult.Should().BeTrue();
            }