Пример #1
0
        public void PropertyPath_GetPropertyPath()
        {
            var viewModel = new SampleViewModel
            {
                Context = new TestDotvvmRequestContext
                {
                    Configuration = DotvvmTestHelper.CreateConfiguration(),
                    ModelState    = new ModelState()
                }
            };

            var error = new ViewModelValidationError
            {
                ErrorMessage = "Testing validation error.",
                PropertyPath = PropertyPath.BuildPath <SampleViewModel>(vm => vm.Users[0].Post.PostText,
                                                                        viewModel.Context.Configuration)
            };

            viewModel.Context.ModelState.Errors.Add(error);

            Assert.AreEqual("Users()[0].Post().PostText", error.PropertyPath);
        }