public void InitializeTest()
        {
            // Arrange.
            var model = Mock.Create<UrlCallParameterEdit>();
            var vm = new UrlCallParameterViewModel();

            // Act.
            vm.Initialize(model);

            // Assert.
            Assert.AreSame(model, vm.Model);

            // Exceptions.
            TestsHelper.VerifyThrow<ArgumentNullException>(() => vm.Initialize(null));
        }
        public void WhenModelValidationCompletes_ValueExpressionIsValid_IsUpdated()
        {
            // Arrange.
            var model = Mock.Create<UrlCallParameterEdit>();
            var vm = new UrlCallParameterViewModel();
            vm.Initialize(model);

            var nameBrokenRule = Mock.Create<BrokenRule>();
            Mock.Arrange(() => nameBrokenRule.Property).Returns(UrlCallParameterEdit.NameProperty.Name);

            var valueBrokenRule = Mock.Create<BrokenRule>();
            Mock.Arrange(() => valueBrokenRule.Property).Returns(UrlCallParameterEdit.ValueProperty.Name);

            var brokenRules1 = new BrokenRulesCollection { nameBrokenRule };
            var brokenRules2 = new BrokenRulesCollection { valueBrokenRule };

            Mock.Arrange(() => model.BrokenRulesCollection).Returns(brokenRules1);

            bool? validationResult = null;

            vm.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == TestsHelper.ExtractPropertyName(() => vm.ValueExpressionIsValid))
                        validationResult = vm.ValueExpressionIsValid;
                };

            // Act.
            Mock.Raise(() => model.ValidationComplete += null, EventArgs.Empty);

            // Assert.
            Assert.AreEqual(true, validationResult);

            // Arrange.
            Mock.Arrange(() => model.BrokenRulesCollection).Returns(brokenRules2);
            validationResult = null;

            // Act.
            Mock.Raise(() => model.ValidationComplete += null, EventArgs.Empty);

            // Assert.
            Assert.AreEqual(false, validationResult);
        }
 /// <summary>
 /// Handles the <see cref="E:ModelValidationComplete" /> event.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private static void OnModelValidationComplete(UrlCallParameterViewModel viewModel, object sender, EventArgs e)
 {
     if (viewModel != null)
         viewModel.OnModelValidationComplete();
 }