コード例 #1
0
        public void BiggerNumberCorrectInput(int value, int minValue, bool awaitedResult)
        {
            //arrange
            minValueValidator = new MinValueValidator(minValue);
            //act
            var result = minValueValidator.Validate(value);

            //assert
            Assert.AreEqual(result, awaitedResult);
        }
コード例 #2
0
            public void ShouldBeInvalidIfValueBelowMin(IComparable value, IComparable min)
            {
                // Arrange
                var validator = new MinValueValidator(min);

                // Act
                validator.Validate(value);

                // Assert
                validator.IsInvalid.ShouldBe(true);
            }
コード例 #3
0
            public void ShouldBeDirtyOnceValidated()
            {
                // Arrange
                int value     = 1;
                var validator = new MinValueValidator(0);

                // Act
                validator.Validate(value);

                // Assert
                validator.IsDirty.ShouldBe(true);
            }
コード例 #4
0
        public override void SetMinMaxValue()
        {
            var consolInput = new ControlService();

            Console.Clear();
            View.Print("Player 1 pleas enter min value of the range: ");
            gameResources.MinValue = consolInput.ReadIntFromConsole();

            View.Print("Player 1 pleas enter max value of the range: ");
            var minValueValidator = new MinValueValidator(gameResources.MinValue);

            gameResources.MaxValue = consolInput.ReadIntFromConsole(minValueValidator);
        }
コード例 #5
0
 public void WhenParameterIsLessThanMinValue_ThrowsException()
 {
     try
     {
         var temp = 3;
         var nullValidator = new MinValueValidator<int>(() => temp, 4);
         nullValidator.Validate();
     }
     catch (ArgumentOutOfRangeException argumentOutOfRangeException)
     {
         Assert.AreEqual("temp", argumentOutOfRangeException.ParamName);
         throw;
     }
 }
コード例 #6
0
 public void WhenParameterIsGreaterThanMinValue_DoesNotThrowException()
 {
     var temp = 3;
     var nullValidator = new MinValueValidator<int>(() => temp, 2);
     nullValidator.Validate();
 }