Exemplo n.º 1
0
        public void Should_Return_ValidationResults_When_Detect_ValidationErrors()
        {
            // Arrange
            var model = new ValidationTestModel();

            // Act
            var validationResults = ModelValidator.Validate(model);

            // Assert
            Assert.Equal(2, validationResults.Count());
        }
Exemplo n.º 2
0
        public void Should_Work_Faster_After_FirstValidation()
        {
            // Arrange
            var model = new ValidationTestModel();

            // Act
            var duration1 = GetActionDuration(() => ModelValidator.Validate(model));
            var duration2 = GetActionDuration(() => ModelValidator.Validate(model));

            // Assert
            Assert.True(duration1 > duration2);
        }
Exemplo n.º 3
0
        public async Task Should_Work_Concurrently_When_ValidatingAsync()
        {
            // Arrange
            var model1 = new ValidationTestModel()
            {
                Id = 1
            };
            var model2 = new ValidationTestModel()
            {
                Value = "Test"
            };

            // Act
            Func <IEnumerable <ValidationResult> > func1 = () => ModelValidator.Validate(model1);
            Func <IEnumerable <ValidationResult> > func2 = () => ModelValidator.Validate(model2);
            var validationResults = await Task.WhenAll(Task.Run(func1), Task.Run(func2));

            // Assert
            Assert.Equal(2, validationResults.Count());
        }