Beispiel #1
0
        public void RemoveInstanceShouldRemoveAllValidatorsAssociatedWithInstance()
        {
            ValidatableViewModel viewModel = GetValidatableViewModel();

            ValidatorProvider.Register <SpyValidator>();
            var instance  = new object();
            var instance2 = new object();

            viewModel.AddInstance(instance);
            viewModel.AddInstance(instance2);
            viewModel.AddValidator <ManualValidator>(instance);
            viewModel.GetValidators().Count.ShouldEqual(4);

            viewModel.RemoveInstance(instance);
            viewModel.GetValidators().Single(validator => validator != viewModel.Validator).Context.Instance.ShouldEqual(instance2);
        }