public void SaveContactCommand_WhenEditDuplicateContactDetailInput_ShouldDisplayAlertAndNotRaiseEventsAndNotNavigateBackToContactsPage() { _contactViewModel.FirstName = "Juan"; _contactViewModel.LastName = "Dela Cruz"; _contactViewModel.ContactNumber = "09180000000"; _contacts = new List <ContactViewModel>(); _contacts.Add(new ContactViewModel() { FirstName = "Rics", LastName = "Magboo", ContactNumber = "09277607229" }); bool isContactAddedEventCalled = false; bool isContactUpdatedEventCalled = false; _viewModel = new ContactDetailPageViewModel(_contactViewModel, _pageService.Object, _contacts); _viewModel.Contact.FirstName = "Rics"; _viewModel.Contact.LastName = "Magboo"; _viewModel.Contact.ContactNumber = "09277607229"; _viewModel.ContactAdded += (sender, args) => isContactAddedEventCalled = true; _viewModel.ContactUpdated += (sender, args) => isContactUpdatedEventCalled = true; _viewModel.SaveContactCommand.Execute(null); _pageService.Verify(x => x.DisplayAlert(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once); Assert.IsFalse(isContactAddedEventCalled); Assert.IsFalse(isContactUpdatedEventCalled); _pageService.Verify(x => x.PopAsync(), Times.Never); _pageService.VerifyNoOtherCalls(); }
public void WhenPageDisplayedAndIsInEditMode_ShouldDisplayUpdateButtonText() { _contactViewModel.FirstName = "Rics"; _contactViewModel.LastName = "Magboo"; _contactViewModel.ContactNumber = "09277607229"; _viewModel = new ContactDetailPageViewModel(_contactViewModel, _pageService.Object, _contacts); Assert.IsTrue(_viewModel.ButtonText.Contains("Update")); }
public void WhenPageDisplayedAndIsInEditMode_ShouldDisplayTheContactDetails() { _contactViewModel.FirstName = "Rics"; _contactViewModel.LastName = "Magboo"; _contactViewModel.ContactNumber = "09277607229"; _viewModel = new ContactDetailPageViewModel(_contactViewModel, _pageService.Object, _contacts); Assert.IsTrue(_viewModel.Contact.FirstName.Equals(_contactViewModel.FirstName)); Assert.IsTrue(_viewModel.Contact.LastName.Equals(_contactViewModel.LastName)); Assert.IsTrue(_viewModel.Contact.ContactNumber.Equals(_contactViewModel.ContactNumber)); }
public ContactDetailPage(Contact contact = null) { InitializeComponent(); if (contact == null) { ViewModel = new ContactDetailPageViewModel(Navigation); } else { ViewModel = new ContactDetailPageViewModel(Navigation, contact); } this.BindingContext = ViewModel; }
public void SaveContactCommand_WhenLastNameIsEmpty_ShouldDisplayAlertAndNotRaiseEventsAndNotNavigateBackToContactsPage() { _contactViewModel.FirstName = "Rics"; _contactViewModel.LastName = ""; _contactViewModel.ContactNumber = "09277607229"; bool isContactAddedEventCalled = false; bool isContactUpdatedEventCalled = false; _viewModel = new ContactDetailPageViewModel(_contactViewModel, _pageService.Object, _contacts); _viewModel.ContactAdded += (sender, args) => isContactAddedEventCalled = true; _viewModel.ContactUpdated += (sender, args) => isContactUpdatedEventCalled = true; _viewModel.SaveContactCommand.Execute(null); _pageService.Verify(x => x.DisplayAlert(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once); Assert.IsFalse(isContactAddedEventCalled); Assert.IsFalse(isContactUpdatedEventCalled); _pageService.Verify(x => x.PopAsync(), Times.Never); _pageService.VerifyNoOtherCalls(); }
public ContactPage() { InitializeComponent(); ViewModel = new ContactDetailPageViewModel(Navigation); }
public ContactDetailPage(ContactDetailPageViewModel viewModel) { InitializeComponent(); BindingContext = viewModel; }
public ContactDetailPage(PhoneContact contactInfo) { viewModel = new ContactDetailPageViewModel(contactInfo); InitializeComponent(); BindingContext = viewModel; }
public void WhenPageDisplayedAndIsInAddMode_ShouldDisplayUpdateButtonText() { _viewModel = new ContactDetailPageViewModel(_contactViewModel, _pageService.Object, _contacts); Assert.IsTrue(_viewModel.ButtonText.Contains("Save")); }
public void WhenPageDisplayedAndIsInAddMode_ShouldDisplayAddContactTitle() { _viewModel = new ContactDetailPageViewModel(_contactViewModel, _pageService.Object, _contacts); Assert.IsTrue(_viewModel.PageTitle.Contains("Add")); }
public ContactDetailPage() { InitializeComponent(); BindingContext = new ContactDetailPageViewModel(); }