public void RemoveFieldCommandTest()
        {
            // Arrange.
            var field1 = ServiceExposedTypeFieldEdit.NewServiceExposedTypeField();
            var field2 = ServiceExposedTypeFieldEdit.NewServiceExposedTypeField();

            var model = ServiceExposedTypeEdit.NewServiceExposedType();
            model.Fields.Add(field1);
            model.Fields.Add(field2);

            var parentViewModel = Mock.Create<IServiceCreationSettingsViewModel>();

            var vm = new ServiceExposedTypeViewModel();
            vm.Initialize(model, parentViewModel);

            // Act / Assert.
            Assert.AreEqual(2, model.Fields.Count);
            Assert.IsFalse(vm.RemoveFieldCommand.CanExecute(null));

            Assert.IsTrue(vm.RemoveFieldCommand.CanExecute(field1));
            vm.RemoveFieldCommand.Execute(field1);
            Assert.AreEqual(1, model.Fields.Count);
            Assert.IsFalse(model.Fields.Contains(field1));

            Assert.IsTrue(vm.RemoveFieldCommand.CanExecute(field2));
            vm.RemoveFieldCommand.Execute(field2);
            Assert.AreEqual(0, model.Fields.Count);
            Assert.IsFalse(model.Fields.Contains(field2));
        }
 public void PropertiesTest()
 {
     // Arrange.
     var model = ServiceExposedTypeEdit.NewServiceExposedType();
     var parentViewModel = Mock.Create<IServiceCreationSettingsViewModel>();
     
     var vm = new ServiceExposedTypeViewModel();
     vm.Initialize(model, parentViewModel);
     
     // Assert.
     Assert.AreSame(model, vm.Model);
     Assert.AreSame(parentViewModel, vm.ParentViewModel);
 }
        public void AddFieldCommandTest()
        {
            // Arrange.
            var model = ServiceExposedTypeEdit.NewServiceExposedType();
            var parentViewModel = Mock.Create<IServiceCreationSettingsViewModel>();

            var vm = new ServiceExposedTypeViewModel();
            vm.Initialize(model, parentViewModel);

            // Act / Assert.
            vm.AddFieldCommand.Execute(null);
            Assert.AreEqual(1, model.Fields.Count);

            vm.AddFieldCommand.Execute(null);
            Assert.AreEqual(2, model.Fields.Count);
        }