Exemplo n.º 1
0
            public void IsModelRegistered_ExistingModel()
            {
                var person = new Person();
                person.FirstName = "first name";
                person.LastName = "last name";

                var viewModel = new TestViewModel(person);

                Assert.IsFalse(viewModel.HasDirtyModel);

                person.FirstName = "new first name";

                Assert.IsTrue(viewModel.HasDirtyModel);
            }            
Exemplo n.º 2
0
        public void Constructor_InjectedServiceLocator()
        {
            var serviceLocator = new ServiceLocator();
            var messageService = new MessageService();
            serviceLocator.RegisterInstance<IMessageService>(messageService);

            var navigationService = new NavigationService();
            serviceLocator.RegisterInstance<INavigationService>(navigationService);

            var viewModel = new TestViewModel(serviceLocator);
            Assert.AreEqual(messageService, viewModel.GetService<IMessageService>());
            Assert.IsTrue(ReferenceEquals(messageService, viewModel.GetService<IMessageService>()));
            Assert.AreEqual(navigationService, viewModel.GetService<INavigationService>());
            Assert.IsTrue(ReferenceEquals(navigationService, viewModel.GetService<INavigationService>()));
        }
Exemplo n.º 3
0
        public async Task CloseAfterCloseProtection()
        {
            var auditor = new TestAuditor();

            AuditingManager.RegisterAuditor(auditor);

            var vm = new TestViewModel();

            Assert.AreEqual(false, auditor.OnViewModelClosedCalled);

            await vm.CloseViewModel(null);

            Assert.AreEqual(true, auditor.OnViewModelClosedCalled);

            auditor.OnViewModelClosedCalled = false;

            await vm.CloseViewModel(null);

            Assert.AreEqual(false, auditor.OnViewModelClosedCalled);
        }
Exemplo n.º 4
0
        public void ModelValidation_NotifyDataWarningInfo_BusinessWarnings()
        {
            var testViewModel = new TestViewModel();
            var validation    = testViewModel as IModelValidation;

            Assert.IsFalse(validation.HasWarnings);

            testViewModel.SpecialValidationModel = new SpecialValidationModel();

            Assert.IsFalse(validation.HasWarnings);

            testViewModel.SpecialValidationModel.BusinessRuleWarningWhenEmpty = string.Empty;

            Assert.IsTrue(validation.HasWarnings);
            Assert.AreNotEqual(string.Empty, ((IDataWarningInfo)testViewModel).Warning);

            testViewModel.SpecialValidationModel.BusinessRuleWarningWhenEmpty = "no warning";

            Assert.IsFalse(validation.HasWarnings);
        }
Exemplo n.º 5
0
        public void ViewModelWithViewModelToModelMappings_PropertyChanges()
        {
            const string FirstName = "first name";
            const string LastName = "last name";
            const uint Age1 = 1;
            const uint Age2 = 2;

            var person = new Person();
            var viewModel = new TestViewModel(person);

            Assert.AreEqual(string.Empty, person.FirstName);
            Assert.AreEqual(string.Empty, viewModel.FirstName);
            Assert.AreEqual(string.Empty, person.LastName);
            Assert.AreEqual(string.Empty, viewModel.LastName);

            Assert.AreEqual(string.Empty, viewModel.FullName);

            Assert.AreEqual(0, person.Age);
            Assert.AreEqual("0", viewModel.Age);

            // Model to view model mapping
            person.FirstName = FirstName;
            Assert.AreEqual(FirstName, person.FirstName);
            Assert.AreEqual(FirstName, viewModel.FirstName);
            Assert.AreEqual(FirstName, viewModel.FullName);

            // View model to model mapping
            viewModel.LastName = LastName;
            Assert.AreEqual(LastName, person.LastName);
            Assert.AreEqual(LastName, viewModel.LastName);
            Assert.AreEqual(FirstName + " " + LastName, viewModel.FullName);
            Assert.AreEqual(FirstName + ";" + LastName, viewModel.FullNameWithCustomSeparator);

            person.Age = Age1;
            Assert.AreEqual(Age1, person.Age);
            Assert.AreEqual(Age1.ToString(), viewModel.Age);

            viewModel.Age = Age2.ToString();
            Assert.AreEqual(Age2, person.Age);
            Assert.AreEqual(Age2.ToString(), viewModel.Age);
        }
Exemplo n.º 6
0
        public void ViewModelWithViewModelToModelMappings_PropertyChanges()
        {
            const string FirstName = "first name";
            const string LastName  = "last name";
            const uint   Age1      = 1;
            const uint   Age2      = 2;

            var person    = new Person();
            var viewModel = new TestViewModel(person);

            Assert.AreEqual(string.Empty, person.FirstName);
            Assert.AreEqual(string.Empty, viewModel.FirstName);
            Assert.AreEqual(string.Empty, person.LastName);
            Assert.AreEqual(string.Empty, viewModel.LastName);

            Assert.AreEqual(string.Empty, viewModel.FullName);

            Assert.AreEqual(0, person.Age);
            Assert.AreEqual("0", viewModel.Age);

            // Model to view model mapping
            person.FirstName = FirstName;
            Assert.AreEqual(FirstName, person.FirstName);
            Assert.AreEqual(FirstName, viewModel.FirstName);
            Assert.AreEqual(FirstName, viewModel.FullName);

            // View model to model mapping
            viewModel.LastName = LastName;
            Assert.AreEqual(LastName, person.LastName);
            Assert.AreEqual(LastName, viewModel.LastName);
            Assert.AreEqual(FirstName + " " + LastName, viewModel.FullName);
            Assert.AreEqual(FirstName + ";" + LastName, viewModel.FullNameWithCustomSeparator);

            person.Age = Age1;
            Assert.AreEqual(Age1, person.Age);
            Assert.AreEqual(Age1.ToString(), viewModel.Age);

            viewModel.Age = Age2.ToString();
            Assert.AreEqual(Age2, person.Age);
            Assert.AreEqual(Age2.ToString(), viewModel.Age);
        }
Exemplo n.º 7
0
        public void ViewModelWithViewModelToModelMappings_PropertyChanges()
        {
            const string FirstName = "first name";
            const string LastName  = "last name";

            var person    = new Person();
            var viewModel = new TestViewModel(person);

            Assert.AreEqual(string.Empty, person.FirstName);
            Assert.AreEqual(string.Empty, viewModel.FirstName);
            Assert.AreEqual(string.Empty, person.LastName);
            Assert.AreEqual(string.Empty, viewModel.LastName);

            // Model to view model mapping
            person.FirstName = FirstName;
            Assert.AreEqual(FirstName, person.FirstName);
            Assert.AreEqual(FirstName, viewModel.FirstName);

            // View model to model mapping
            viewModel.LastName = LastName;
            Assert.AreEqual(LastName, person.LastName);
            Assert.AreEqual(LastName, viewModel.LastName);
        }
Exemplo n.º 8
0
        public void ViewModelWithViewModelToModelMappings_FieldWarnings()
        {
            var person    = new Person();
            var viewModel = new TestViewModel(person);

            var personAsWarning    = (IDataWarningInfo)person;
            var viewModelAsWarning = (IDataWarningInfo)viewModel;

            person.FirstName = "first name";
            person.LastName  = "last name";

            Assert.IsFalse(viewModel.HasErrors);
            Assert.IsTrue(viewModel.HasWarnings);
            Assert.AreNotEqual(string.Empty, personAsWarning[Person.MiddleNameProperty.Name]);
            Assert.AreNotEqual(string.Empty, viewModelAsWarning[TestViewModel.MiddleNameProperty.Name]);

            person.MiddleName = "middle name";

            Assert.IsFalse(viewModel.HasErrors);
            Assert.IsFalse(viewModel.HasWarnings);
            Assert.AreEqual(string.Empty, personAsWarning[Person.MiddleNameProperty.Name]);
            Assert.AreEqual(string.Empty, viewModelAsWarning[TestViewModel.MiddleNameProperty.Name]);
        }
Exemplo n.º 9
0
        public void ViewModelWithViewModelToModelMappings_PropertyChanges()
        {
            const string FirstName = "first name";
            const string LastName = "last name";

            var person = new Person();
            var viewModel = new TestViewModel(person);

            Assert.AreEqual(string.Empty, person.FirstName);
            Assert.AreEqual(string.Empty, viewModel.FirstName);
            Assert.AreEqual(string.Empty, person.LastName);
            Assert.AreEqual(string.Empty, viewModel.LastName);

            // Model to view model mapping
            person.FirstName = FirstName;
            Assert.AreEqual(FirstName, person.FirstName);
            Assert.AreEqual(FirstName, viewModel.FirstName);

            // View model to model mapping
            viewModel.LastName = LastName;
            Assert.AreEqual(LastName, person.LastName);
            Assert.AreEqual(LastName, viewModel.LastName);
        }
Exemplo n.º 10
0
        public void ChildViewModelUpdatesValidation()
        {
            Person person = new Person();

            person.LastName = "last name";

            var viewModel      = new TestViewModel();
            var childViewModel = new TestViewModel(person);

            ((IRelationalViewModel)viewModel).RegisterChildViewModel(childViewModel);

            Assert.IsTrue(viewModel.HasErrors);
            Assert.IsTrue(childViewModel.HasErrors);

            person.FirstName = "first name";

            Assert.IsFalse(viewModel.HasErrors);
            Assert.IsFalse(childViewModel.HasErrors);

            person.FirstName = string.Empty;

            Assert.IsTrue(viewModel.HasErrors);
            Assert.IsTrue(childViewModel.HasErrors);
        }
Exemplo n.º 11
0
        public void SaveAfterCloseProtection()
        {
            var auditor = new TestAuditor();

            AuditingManager.RegisterAuditor(auditor);

            var vm = new TestViewModel();

            Assert.AreEqual(false, auditor.OnViewModelSavedCalled);
            Assert.AreEqual(false, auditor.OnViewModelClosedCalled);

            vm.SaveAndCloseViewModel();

            Assert.AreEqual(true, auditor.OnViewModelSavedCalled);
            Assert.AreEqual(true, auditor.OnViewModelClosedCalled);

            auditor.OnViewModelSavedCalled  = false;
            auditor.OnViewModelClosedCalled = false;

            vm.SaveAndCloseViewModel();

            Assert.AreEqual(false, auditor.OnViewModelSavedCalled);
            Assert.AreEqual(false, auditor.OnViewModelClosedCalled);
        }
Exemplo n.º 12
0
        public void SetParentviewModel()
        {
            var viewModel = new TestViewModel();
            var parentViewModel = new InterestedViewModel();

            Assert.IsNull(viewModel.GetParentViewModelForTest());
            ((IRelationalViewModel)viewModel).SetParentViewModel(parentViewModel);
            Assert.AreEqual(parentViewModel, viewModel.GetParentViewModelForTest());
        }
Exemplo n.º 13
0
        public void RegisterChildViewModel_Null()
        {
            var viewModel = new TestViewModel();

            ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => ((IRelationalViewModel)viewModel).RegisterChildViewModel(null));
        }
Exemplo n.º 14
0
        public void ModelValidation_NotifyDataWarningInfo_BusinessWarnings()
        {
            var testViewModel = new TestViewModel();

            Assert.IsFalse(testViewModel.HasWarnings);

            testViewModel.SpecialValidationModel = new SpecialValidationModel();

            Assert.IsFalse(testViewModel.HasWarnings);

            testViewModel.SpecialValidationModel.BusinessRuleWarningWhenEmpty = string.Empty;

            Assert.IsTrue(testViewModel.HasWarnings);
            Assert.AreNotEqual(string.Empty, ((IDataWarningInfo)testViewModel).Warning);

            testViewModel.SpecialValidationModel.BusinessRuleWarningWhenEmpty = "no warning";

            Assert.IsFalse(testViewModel.HasWarnings);
        }
Exemplo n.º 15
0
        public void InvalidateCommands_AutomaticByPropertyChange()
        {
            bool canExecuteChangedTriggered = false;
            var canExecuteChangedEvent = new ManualResetEvent(false);

            var viewModel = new TestViewModel();
            viewModel.SetInvalidateCommandsOnPropertyChanged(true);

            ICatelCommand command = viewModel.GenerateData;
            command.CanExecuteChanged += delegate
            {
                canExecuteChangedTriggered = true;
                canExecuteChangedEvent.Set();
            };

            // By default, command can be executed
            Assert.IsTrue(viewModel.GenerateData.CanExecute(null));

            viewModel.FirstName = "first name";

            Assert.IsFalse(viewModel.GenerateData.CanExecute(null));
#if NET
            canExecuteChangedEvent.WaitOne(1000, false);
#else
            canExecuteChangedEvent.WaitOne(1000);
#endif
            Assert.IsTrue(canExecuteChangedTriggered);
        }
Exemplo n.º 16
0
        public void ModelsCanceledByCancel()
        {
            Person person = new Person();
            person.FirstName = "first name";
            person.LastName = "last name";

            var viewModel = new TestViewModel(person);
            Assert.IsTrue(person.IsInEditSession);

            viewModel.FirstName = "new first name";

            viewModel.CancelAndCloseViewModel();

            Assert.IsFalse(person.IsInEditSession);
            Assert.AreEqual("first name", person.FirstName);            
        }
Exemplo n.º 17
0
        public void ChildViewModelUpdatesValidation()
        {
            Person person = new Person();
            person.LastName = "last name";

            var viewModel = new TestViewModel();
            var childViewModel = new TestViewModel(person);

            ((IRelationalViewModel)viewModel).RegisterChildViewModel(childViewModel);

            Assert.IsTrue(viewModel.HasErrors);
            Assert.IsTrue(childViewModel.HasErrors);

            person.FirstName = "first name";

            Assert.IsFalse(viewModel.HasErrors);
            Assert.IsFalse(childViewModel.HasErrors);

            person.FirstName = string.Empty;

            Assert.IsTrue(viewModel.HasErrors);
            Assert.IsTrue(childViewModel.HasErrors);
        }
Exemplo n.º 18
0
        public void ViewModelWithViewModelToModelMappings_FieldWarnings()
        {
            var person = new Person();
            var viewModel = new TestViewModel(person);

            var personAsWarning = (IDataWarningInfo)person;
            var viewModelAsWarning = (IDataWarningInfo)viewModel;

            person.FirstName = "first name";
            person.LastName = "last name";

            Assert.IsFalse(viewModel.HasErrors);
            Assert.IsTrue(viewModel.HasWarnings);
            Assert.AreNotEqual(string.Empty, personAsWarning[Person.MiddleNameProperty.Name]);
            Assert.AreNotEqual(string.Empty, viewModelAsWarning[TestViewModel.MiddleNameProperty.Name]);

            person.MiddleName = "middle name";

            Assert.IsFalse(viewModel.HasErrors);
            Assert.IsFalse(viewModel.HasWarnings);
            Assert.AreEqual(string.Empty, personAsWarning[Person.MiddleNameProperty.Name]);
            Assert.AreEqual(string.Empty, viewModelAsWarning[TestViewModel.MiddleNameProperty.Name]);
        }
Exemplo n.º 19
0
        public void ViewModelWithViewModelToModelMappings_FieldErrors()
        {
            var person = new Person();
            var viewModel = new TestViewModel(person);

            var personAsError = (IDataErrorInfo)person;
            var viewModelAsError = (IDataErrorInfo)viewModel;

            person.FirstName = "first name";

            Assert.AreEqual(string.Empty, personAsError[Person.FirstNameProperty.Name]);
            Assert.AreEqual(string.Empty, viewModelAsError[TestViewModel.FirstNameProperty.Name]);

            person.FirstName = string.Empty;

            Assert.AreNotEqual(string.Empty, personAsError[Person.FirstNameProperty.Name]);
            Assert.AreNotEqual(string.Empty, viewModelAsError[TestViewModel.FirstNameProperty.Name]);
        }
Exemplo n.º 20
0
        public async void SaveAfterCloseProtection()
        {
            var auditor = new TestAuditor();
            AuditingManager.RegisterAuditor(auditor);

            var vm = new TestViewModel();

            Assert.AreEqual(false, auditor.OnViewModelSavedCalled);
            Assert.AreEqual(false, auditor.OnViewModelClosedCalled);

            await vm.SaveAndCloseViewModel();

            Assert.AreEqual(true, auditor.OnViewModelSavedCalled);
            Assert.AreEqual(true, auditor.OnViewModelClosedCalled);

            auditor.OnViewModelSavedCalled = false;
            auditor.OnViewModelClosedCalled = false;

            await vm.SaveAndCloseViewModel();

            Assert.AreEqual(false, auditor.OnViewModelSavedCalled);
            Assert.AreEqual(false, auditor.OnViewModelClosedCalled);
        }
Exemplo n.º 21
0
        public void ModelValidation_NotifyDataWarningInfo_FieldWarnings()
        {
            var testViewModel = new TestViewModel();
            var validation = testViewModel as IModelValidation;

            Assert.IsFalse(validation.HasWarnings);

            testViewModel.SpecialValidationModel = new SpecialValidationModel();

            Assert.IsFalse(validation.HasWarnings);

            testViewModel.SpecialValidationModel.FieldWarningWhenEmpty = string.Empty;

            Assert.IsTrue(validation.HasWarnings);
            Assert.AreNotEqual(string.Empty, ((IDataWarningInfo)testViewModel)["FieldWarningWhenEmpty"]);

            testViewModel.SpecialValidationModel.FieldWarningWhenEmpty = "no warning";

            Assert.IsFalse(validation.HasWarnings);
        }
Exemplo n.º 22
0
        public void IsModelRegistered_ExistingModel()
        {
            var person = new Person();
            person.FirstName = "first name";
            person.LastName = "last name";

            var viewModel = new TestViewModel(person);

            Assert.IsTrue(viewModel.IsModelRegisteredForTest("Person"));
        }
Exemplo n.º 23
0
        public async void ModelsSavedBySave()
        {
            var person = new Person();
            person.FirstName = "first name";
            person.LastName = "last name";

            var model = person as IModel;
            var viewModel = new TestViewModel(person);
            Assert.IsTrue(model.IsInEditSession);

            viewModel.FirstName = "new first name";

            await viewModel.SaveAndCloseViewModel();

            Assert.IsFalse(model.IsInEditSession);
            Assert.AreEqual("new first name", person.FirstName);
        }
Exemplo n.º 24
0
        public void RegisterChildViewModel_Null()
        {
            var viewModel = new TestViewModel();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => ((IRelationalViewModel)viewModel).RegisterChildViewModel(null));
        }
Exemplo n.º 25
0
        public void RegisterChildViewModel_RemovedViaUnregisterChildViewModel()
        {
            bool validationTriggered = false;
            ManualResetEvent validatedEvent = new ManualResetEvent(false);

            Person person = new Person();
            person.FirstName = "first name";
            person.LastName = "last name";

            var viewModel = new TestViewModel();
            var childViewModel = new TestViewModel(person);

            Assert.IsFalse(childViewModel.HasErrors);

            ((IRelationalViewModel)viewModel).RegisterChildViewModel(childViewModel);
            viewModel.Validating += delegate
            {
                validationTriggered = true;
                validatedEvent.Set();
            };

            childViewModel.FirstName = string.Empty;

#if NET
            validatedEvent.WaitOne(2000, false);
#else
            validatedEvent.WaitOne(2000);
#endif
            Assert.IsTrue(validationTriggered, "Validating event is not triggered");

            ((IRelationalViewModel)viewModel).UnregisterChildViewModel(childViewModel);

            validationTriggered = false;
            validatedEvent.Reset();

#if NET
            validatedEvent.WaitOne(2000, false);
#else
            validatedEvent.WaitOne(2000);
#endif
            Assert.IsFalse(validationTriggered, "Validating event should not be triggered because child view model is removed");
        }
Exemplo n.º 26
0
        public void CloseAfterCloseProtection()
        {
            var auditor = new TestAuditor();
            AuditingManager.RegisterAuditor(auditor);

            var vm = new TestViewModel();

            Assert.AreEqual(false, auditor.OnViewModelClosedCalled);

            vm.CloseViewModel(null);

            Assert.AreEqual(true, auditor.OnViewModelClosedCalled);

            auditor.OnViewModelClosedCalled = false;

            vm.CloseViewModel(null);

            Assert.AreEqual(false, auditor.OnViewModelClosedCalled);
        }
Exemplo n.º 27
0
        public void GetAllModels()
        {
            Person person = new Person();
            person.FirstName = "first name";
            person.LastName = "last name";

            var viewModel = new TestViewModel(person);

            object[] models = viewModel.GetAllModelsForTest();
            Assert.AreEqual(2, models.Length);
            Assert.AreEqual(person, models[0]);
        }
Exemplo n.º 28
0
        public void ViewModelWithViewModelToModelMappings_ValidateModelsOnInitialization()
        {
            var person = new PersonWithDataAnnotations();
            var viewModel = new TestViewModel(person, true);

            Assert.AreNotEqual(0, viewModel.ValidationContext.GetValidationCount());
        }
Exemplo n.º 29
0
        public void IsModelRegistered_NonExistingModel()
        {
            Person person = new Person();
            person.FirstName = "first name";
            person.LastName = "last name";

            var viewModel = new TestViewModel(person);

            Assert.IsFalse(viewModel.IsModelRegisteredForTest("SecondPerson"));
        }
Exemplo n.º 30
0
        public void ViewModelWithViewModelToModelMappings_DoNotValidateModelsOnInitialization_UpdateViaModel()
        {
            var person = new PersonWithDataAnnotations();
            var viewModel = new TestViewModel(person, false);

            Assert.AreEqual(0, person.ValidationContext.GetValidationCount());
            Assert.AreEqual(0, viewModel.ValidationContext.GetValidationCount());

            person.FirstName = null;

            Assert.AreNotEqual(0, person.ValidationContext.GetValidationCount());
            Assert.AreNotEqual(0, viewModel.ValidationContext.GetValidationCount());
        }
Exemplo n.º 31
0
        public void ModelValidation_NotifyDataErrorInfo_BusinessErrors()
        {
            var testViewModel = new TestViewModel();

            Assert.IsFalse(testViewModel.HasErrors);

            testViewModel.SpecialValidationModel = new SpecialValidationModel();

            Assert.IsFalse(testViewModel.HasErrors);

            testViewModel.SpecialValidationModel.BusinessRuleErrorWhenEmpty = string.Empty;

            Assert.IsTrue(testViewModel.HasErrors);
            Assert.AreNotEqual(string.Empty, ((IDataErrorInfo)testViewModel).Error);

            testViewModel.SpecialValidationModel.BusinessRuleErrorWhenEmpty = "no error";

            Assert.IsFalse(testViewModel.HasErrors);
        }
Exemplo n.º 32
0
        public void ViewModelWithViewModelToModelMappings_DoNotMapWhenViewModelIsClosed()
        {
            var person = new Person();
            var viewModel = new TestViewModel(person, true);

            Assert.AreNotEqual("test1", person.FirstName);
            viewModel.FirstName = "test1";
            Assert.AreEqual("test1", person.FirstName);

            viewModel.CloseViewModel(true);
            viewModel.FirstName = "test2";

            Assert.AreEqual("test1", person.FirstName);
        }
Exemplo n.º 33
0
        public void ViewModelWithViewModelToModelMappings_BusinessErrors()
        {
            var person = new Person();
            var viewModel = new TestViewModel(person);

            var personAsError = (IDataErrorInfo)person;
            var viewModelAsError = (IDataErrorInfo)viewModel;

            person.FirstName = "first name";
            person.LastName = "last name";

            Assert.AreEqual(string.Empty, personAsError.Error);
            Assert.AreEqual(string.Empty, viewModelAsError.Error);

            person.FirstName = string.Empty;

            Assert.AreNotEqual(string.Empty, personAsError.Error);
            Assert.AreNotEqual(string.Empty, viewModelAsError.Error);
        }
Exemplo n.º 34
0
        public async Task ModelsCanceledByCancel()
        {
            var person = new Person();
            person.FirstName = "first name";
            person.LastName = "last name";

            var model = person as IModel;
            var viewModel = new TestViewModel(person);
            Assert.IsTrue(model.IsInEditSession);

            viewModel.FirstName = "new first name";

            await viewModel.CancelAndCloseViewModelAsync();

            Assert.IsFalse(model.IsInEditSession);
            Assert.AreEqual("first name", person.FirstName);
        }
Exemplo n.º 35
0
        public void Tombstoning_AutomaticRecovery()
        {
            var vm = new TestViewModel();
            vm.FirstName = "John";
            vm.LastName = "Doe";

            var data = vm.SerializeForTombstoning();
            var recoveredVm = ViewModelBase.DeserializeFromTombstoning(typeof(TestViewModel), data);

            Assert.AreEqual(vm, recoveredVm);
        }
Exemplo n.º 36
0
        public void ViewModelWithViewModelToModelMappings_BusinessWarnings()
        {
            var person = new Person();
            var viewModel = new TestViewModel(person);

            var personAsWarning = (IDataWarningInfo)person;
            var viewModelAsWarning = (IDataWarningInfo)viewModel;

            person.FirstName = "first name";
            person.LastName = "last name";

            Assert.AreNotEqual(string.Empty, personAsWarning.Warning);
            Assert.AreNotEqual(string.Empty, viewModelAsWarning.Warning);

            person.MiddleName = "middle name";

            Assert.AreEqual(string.Empty, personAsWarning.Warning);
            Assert.AreEqual(string.Empty, viewModelAsWarning.Warning);
        }