コード例 #1
0
            public void ValidationShouldFail_IfNoNameIsSupplied()
            {
                //arrange
                using (new CultureContext(new CultureInfo("en")))
                {
                    var model  = new TaskSummaryViewModel();
                    var tester = new PropertyValidationHelper <TaskSummaryViewModel>(model);

                    //act
                    var result = tester.ValidateProperty(m => m.Name);

                    //assert
                    Assert.Contains("The Name field is required.", result.Select(r => r.ErrorMessage));
                }
            }
コード例 #2
0
            public void ValidationShouldFail_IfNoNumberOfVolunteersRequiredIsSupplied()
            {
                //arrange
                using (new CultureContext(new CultureInfo("en")))
                {
                    var model  = new TaskSummaryViewModel();
                    var tester = new PropertyValidationHelper <TaskSummaryViewModel>(model);

                    //act
                    var result = tester.ValidateProperty(m => m.NumberOfVolunteersRequired);

                    //assert
                    Assert.Contains("'Volunteers Required' must be greater than 0", result.Select(r => r.ErrorMessage));
                }
            }
コード例 #3
0
            public void ValidationShouldFail_IfNoNumberOfVolunteersRequiredIsSupplied()
            {
                //arrange
                using (new CultureContext(new CultureInfo("en")))
                {
                    var model = new TaskSummaryViewModel();
                    var tester = new PropertyValidationHelper<TaskSummaryViewModel>(model);

                    //act
                    var result = tester.ValidateProperty(m => m.NumberOfVolunteersRequired);

                    //assert
                    Assert.Contains("'Volunteers Required' must be greater than 0", result.Select(r => r.ErrorMessage));
                }
            }
コード例 #4
0
            public void ValidationShouldFail_IfNoNameIsSupplied()
            {
                //arrange
                using (new CultureContext(new CultureInfo("en")))
                {
                    var model = new TaskSummaryViewModel();
                    var tester = new PropertyValidationHelper<TaskSummaryViewModel>(model);

                    //act
                    var result = tester.ValidateProperty(m => m.Name);

                    //assert
                    Assert.Contains("The Name field is required.", result.Select(r => r.ErrorMessage));
                }
            }
コード例 #5
0
            public void ValidationShouldSucceed_IfNumberOfVolunteersRequiredIs1()
            {
                //arrange
                using (new CultureContext(new CultureInfo("en")))
                {
                    var model = new TaskSummaryViewModel
                    {
                        NumberOfVolunteersRequired = 1
                    };
                    var tester = new PropertyValidationHelper <TaskSummaryViewModel>(model);

                    //act
                    var result = tester.ValidateProperty(m => m.NumberOfVolunteersRequired);

                    //assert
                    Assert.Empty(result);
                }
            }
コード例 #6
0
            public void ValidationShouldSucceed_IfNameIsSupplied()
            {
                //arrange
                using (new CultureContext(new CultureInfo("en")))
                {
                    var model = new TaskSummaryViewModel
                    {
                        Name = "name"
                    };
                    var tester = new PropertyValidationHelper <TaskSummaryViewModel>(model);

                    //act
                    var result = tester.ValidateProperty(m => m.Name);

                    //assert
                    Assert.Empty(result);
                }
            }
コード例 #7
0
            public void ValidationShouldSucceed_IfNameIsSupplied()
            {
                //arrange
                using (new CultureContext(new CultureInfo("en")))
                {
                    var model = new TaskSummaryViewModel
                    {
                        Name = "name"
                    };
                    var tester = new PropertyValidationHelper<TaskSummaryViewModel>(model);

                    //act
                    var result = tester.ValidateProperty(m => m.Name);

                    //assert
                    Assert.Empty(result);
                }
            }
コード例 #8
0
            public void ValidationShouldSucceed_IfNumberOfVolunteersRequiredIs1()
            {
                //arrange
                using (new CultureContext(new CultureInfo("en")))
                {
                    var model = new TaskSummaryViewModel
                    {
                        NumberOfVolunteersRequired = 1
                    };
                    var tester = new PropertyValidationHelper<TaskSummaryViewModel>(model);

                    //act
                    var result = tester.ValidateProperty(m => m.NumberOfVolunteersRequired);

                    //assert
                    Assert.Empty(result);
                }
            }