public void PropertiesTest() { var viewModel = Container.GetExportedValue<EmailAccountsViewModel>(); var root = new EmailClientRoot(); AssertHelper.PropertyChangedEvent(viewModel, x => x.EmailClientRoot, () => viewModel.EmailClientRoot = root); Assert.AreEqual(root, viewModel.EmailClientRoot); root = new EmailClientRoot(); root.AddEmailAccount(new EmailAccount()); root.AddEmailAccount(new EmailAccount()); AssertHelper.PropertyChangedEvent(viewModel, x => x.SelectedEmailAccount, () => viewModel.EmailClientRoot = root); Assert.AreEqual(root.EmailAccounts.First(), viewModel.SelectedEmailAccount); AssertHelper.PropertyChangedEvent(viewModel, x => x.SelectedEmailAccount, () => viewModel.SelectedEmailAccount = root.EmailAccounts.ElementAt(1)); Assert.AreEqual(root.EmailAccounts.ElementAt(1), viewModel.SelectedEmailAccount); var emptyCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.NewAccountCommand, () => viewModel.NewAccountCommand = emptyCommand); Assert.AreEqual(emptyCommand, viewModel.NewAccountCommand); AssertHelper.PropertyChangedEvent(viewModel, x => x.RemoveAccountCommand, () => viewModel.RemoveAccountCommand = emptyCommand); Assert.AreEqual(emptyCommand, viewModel.RemoveAccountCommand); AssertHelper.PropertyChangedEvent(viewModel, x => x.EditAccountCommand, () => viewModel.EditAccountCommand = emptyCommand); Assert.AreEqual(emptyCommand, viewModel.EditAccountCommand); }
public void PropertiesTest() { var viewModel = Container.GetExportedValue<ContactListViewModel>(); List<Contact> contacts = new List<Contact>() { new Contact(), new Contact() }; Assert.IsNull(viewModel.Contacts); AssertHelper.PropertyChangedEvent(viewModel, x => x.Contacts, () => viewModel.Contacts = contacts); Assert.AreEqual(contacts, viewModel.Contacts); Assert.IsNull(viewModel.SelectedContact); AssertHelper.PropertyChangedEvent(viewModel, x => x.SelectedContact, () => viewModel.SelectedContact = contacts.First()); Assert.AreEqual(contacts.First(), viewModel.SelectedContact); var emptyCommand = new DelegateCommand(() => { }); Assert.IsNull(viewModel.DeleteContactCommand); AssertHelper.PropertyChangedEvent(viewModel, x => x.DeleteContactCommand, () => viewModel.DeleteContactCommand = emptyCommand); Assert.AreEqual(emptyCommand, viewModel.DeleteContactCommand); Assert.AreEqual("", viewModel.FilterText); AssertHelper.PropertyChangedEvent(viewModel, x => x.FilterText, () => viewModel.FilterText = "abc"); Assert.AreEqual("abc", viewModel.FilterText); }
public void PropertiesTest() { var viewModel = Container.GetExportedValue<EmailListViewModel>(); var emails = new List<Email>() { new Email(), new Email(), }; Assert.IsNull(viewModel.Emails); AssertHelper.PropertyChangedEvent(viewModel, x => x.Emails, () => viewModel.Emails = emails); Assert.AreEqual(emails, viewModel.Emails); Assert.IsNull(viewModel.SelectedEmail); AssertHelper.PropertyChangedEvent(viewModel, x => x.SelectedEmail, () => viewModel.SelectedEmail = emails.First()); Assert.AreEqual(emails.First(), viewModel.SelectedEmail); var emptyCommand = new DelegateCommand(() => { }); Assert.IsNull(viewModel.DeleteEmailCommand); AssertHelper.PropertyChangedEvent(viewModel, x => x.DeleteEmailCommand, () => viewModel.DeleteEmailCommand = emptyCommand); Assert.AreEqual(emptyCommand, viewModel.DeleteEmailCommand); Assert.AreEqual("", viewModel.FilterText); AssertHelper.PropertyChangedEvent(viewModel, x => x.FilterText, () => viewModel.FilterText = "abc"); Assert.AreEqual("abc", viewModel.FilterText); }
public EditEmailAccountController(CompositionContainer container, EditEmailAccountViewModel editEmailAccountViewModel, BasicEmailAccountViewModel basicEmailAccountViewModel) { this.container = container; this.editEmailAccountViewModel = editEmailAccountViewModel; AddWeakEventListener(editEmailAccountViewModel, EmailAccountsViewModelPropertyChanged); this.basicEmailAccountViewModel = basicEmailAccountViewModel; backCommand = new DelegateCommand(Back, CanBack); nextCommand = new DelegateCommand(Next, CanNext); }
public BookController(CompositionContainer container, IShellService shellService, IEntityService entityService, BookViewModel bookViewModel) { this.container = container; this.shellService = shellService; this.entityService = entityService; this.bookViewModel = bookViewModel; this.addNewCommand = new DelegateCommand(AddNewBook, CanAddNewBook); this.removeCommand = new DelegateCommand(RemoveBook, CanRemoveBook); this.lendToCommand = new DelegateCommand(p => LendTo((Book)p)); }
public EditEmailAccountController(EditEmailAccountViewModel editEmailAccountViewModel, BasicEmailAccountViewModel basicEmailAccountViewModel, ExportFactory<Pop3SettingsViewModel> pop3SettingsViewModelFactory, ExportFactory<ExchangeSettingsViewModel> exchangeSettingsViewModelFactory) { this.editEmailAccountViewModel = editEmailAccountViewModel; this.basicEmailAccountViewModel = basicEmailAccountViewModel; this.pop3SettingsViewModelFactory = pop3SettingsViewModelFactory; this.exchangeSettingsViewModelFactory = exchangeSettingsViewModelFactory; backCommand = new DelegateCommand(Back, CanBack); nextCommand = new DelegateCommand(Next, CanNext); }
public BookController(IShellService shellService, IEntityService entityService, BookListViewModel bookListViewModel, BookViewModel bookViewModel, ExportFactory<LendToViewModel> lendToViewModelFactory) { this.shellService = shellService; this.entityService = entityService; this.bookListViewModel = bookListViewModel; this.bookViewModel = bookViewModel; this.lendToViewModelFactory = lendToViewModelFactory; this.addNewCommand = new DelegateCommand(AddNewBook, CanAddNewBook); this.removeCommand = new DelegateCommand(RemoveBook, CanRemoveBook); this.lendToCommand = new DelegateCommand(p => LendTo((Book)p)); }
public PersonController(CompositionContainer container, IMessageService messageService, IShellService shellService, IEntityService entityService, IEmailService emailService, PersonViewModel personViewModel) { this.container = container; this.messageService = messageService; this.shellService = shellService; this.entityService = entityService; this.emailService = emailService; this.personViewModel = personViewModel; this.addNewCommand = new DelegateCommand(AddNewPerson, CanAddPerson); this.removeCommand = new DelegateCommand(RemovePerson, CanRemovePerson); this.createNewEmailCommand = new DelegateCommand(CreateNewEmail); }
public void ToolBarCommandsDelegation() { var shellView = Container.GetExportedValue<MockShellView>(); var shellViewModel = Container.GetExportedValue<ShellViewModel>(); var emptyCommand = new DelegateCommand(() => { }); var newToolBarCommands = new ToolBarCommand[] { new ToolBarCommand(emptyCommand, "Command 1"), new ToolBarCommand(emptyCommand, "Command 2") }; Assert.IsFalse(shellView.ToolBarCommands.Any()); shellViewModel.AddToolBarCommands(newToolBarCommands); Assert.IsTrue(shellView.ToolBarCommands.SequenceEqual(newToolBarCommands)); shellViewModel.ClearToolBarCommands(); Assert.IsFalse(shellView.ToolBarCommands.Any()); }
public void ShellViewModelPropertiesTest() { ShellViewModel shellViewModel = Container.GetExportedValue<ShellViewModel>(); DelegateCommand mockCommand = new DelegateCommand(() => {}); AssertHelper.PropertyChangedEvent(shellViewModel, x => x.SaveCommand, () => shellViewModel.SaveCommand = mockCommand); Assert.AreEqual(mockCommand, shellViewModel.SaveCommand); AssertHelper.PropertyChangedEvent(shellViewModel, x => x.ExitCommand, () => shellViewModel.ExitCommand = mockCommand); Assert.AreEqual(mockCommand, shellViewModel.ExitCommand); Assert.IsTrue(shellViewModel.IsValid); AssertHelper.PropertyChangedEvent(shellViewModel, x => x.IsValid, () => shellViewModel.IsValid = false); Assert.IsFalse(shellViewModel.IsValid); AssertHelper.PropertyChangedEvent(shellViewModel, x => x.DatabasePath, () => shellViewModel.DatabasePath = @"C:\MyDatabase.sdf"); Assert.AreEqual(@"C:\MyDatabase.sdf", shellViewModel.DatabasePath); }
public void PropertiesTest() { var viewModel = Container.GetExportedValue<EditEmailAccountViewModel>(); var emptyCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.BackCommand, () => viewModel.BackCommand = emptyCommand); Assert.AreEqual(emptyCommand, viewModel.BackCommand); AssertHelper.PropertyChangedEvent(viewModel, x => x.NextCommand, () => viewModel.NextCommand = emptyCommand); Assert.AreEqual(emptyCommand, viewModel.NextCommand); var contentView = new object(); AssertHelper.PropertyChangedEvent(viewModel, x => x.ContentView, () => viewModel.ContentView = contentView); Assert.AreEqual(contentView, viewModel.ContentView); Assert.IsTrue(viewModel.IsValid); AssertHelper.PropertyChangedEvent(viewModel, x => x.IsValid, () => viewModel.IsValid = false); Assert.IsFalse(viewModel.IsValid); Assert.IsFalse(viewModel.IsLastPage); AssertHelper.PropertyChangedEvent(viewModel, x => x.IsLastPage, () => viewModel.IsLastPage = true); Assert.IsTrue(viewModel.IsLastPage); }
public void PropertiesTest() { var viewModel = Container.GetExportedValue<NewEmailViewModel>(); var emptyCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.SelectContactCommand, () => viewModel.SelectContactCommand = emptyCommand); Assert.AreEqual(emptyCommand, viewModel.SelectContactCommand); AssertHelper.PropertyChangedEvent(viewModel, x => x.SendCommand, () => viewModel.SendCommand = emptyCommand); Assert.AreEqual(emptyCommand, viewModel.SendCommand); // Email accounts tests var emailAccounts = new List<EmailAccount>() { new EmailAccount(), new EmailAccount() }; AssertHelper.PropertyChangedEvent(viewModel, x => x.EmailAccounts, () => viewModel.EmailAccounts = emailAccounts); Assert.AreEqual(emailAccounts, viewModel.EmailAccounts); AssertHelper.PropertyChangedEvent(viewModel, x => x.SelectedEmailAccount, () => viewModel.SelectedEmailAccount = emailAccounts.First()); Assert.AreEqual(emailAccounts.First(), viewModel.SelectedEmailAccount); // Email tests var email = new Email(); AssertHelper.PropertyChangedEvent(viewModel, x => x.Email, () => viewModel.Email = email); Assert.AreEqual(email, viewModel.Email); string to = "*****@*****.**"; AssertHelper.PropertyChangedEvent(viewModel, x => x.To, () => viewModel.To = to); Assert.AreEqual(to, viewModel.To); Assert.AreEqual(to, email.To.Single()); string cc1 = "*****@*****.**"; string cc2 = "*****@*****.**"; string cc = cc1 + ", " + cc2; AssertHelper.PropertyChangedEvent(viewModel, x => x.CC, () => viewModel.CC = cc); Assert.AreEqual(cc1 + "; " + cc2, viewModel.CC); Assert.IsTrue(email.CC.SequenceEqual(new[] { cc1, cc2 })); string bcc1 = "*****@*****.**"; string bcc2 = "*****@*****.**"; string bcc3 = "*****@*****.**"; string bcc = bcc1 + "; " + bcc2 + " " + bcc3; AssertHelper.PropertyChangedEvent(viewModel, x => x.Bcc, () => viewModel.Bcc = bcc); Assert.AreEqual(bcc1 + "; " + bcc2 + "; " + bcc3, viewModel.Bcc); Assert.IsTrue(email.Bcc.SequenceEqual(new[] { bcc1, bcc2, bcc3 })); string newEmail = "*****@*****.**"; AssertHelper.PropertyChangedEvent(viewModel, x => x.To, () => email.To = new[] { newEmail }); Assert.AreEqual(newEmail, viewModel.To); AssertHelper.PropertyChangedEvent(viewModel, x => x.CC, () => email.CC = new[] { newEmail }); Assert.AreEqual(newEmail, viewModel.CC); AssertHelper.PropertyChangedEvent(viewModel, x => x.Bcc, () => email.Bcc = new[] { newEmail }); Assert.AreEqual(newEmail, viewModel.Bcc); viewModel.Email = new Email(); }
public SelectContactController(SelectContactViewModel selectContactViewModel, ContactListViewModel contactListViewModel) { this.selectContactViewModel = selectContactViewModel; this.contactListViewModel = contactListViewModel; this.selectContactCommand = new DelegateCommand(SelectContact, CanSelectContact); }