public void UpdateContact_Save_ContactUpdated()
        {
            // arrange
            ContactModel serviceResult = new ContactModel {
                Id = 1, Name = "newName", Phone = "123", Email = "*****@*****.**"
            };

            this._contactService.Setup(x => x.UpdateContact(It.IsAny <ContactModel>())).Returns(Task.FromResult <ContactModel>(serviceResult));
            ContactModel contactToUpdate = new ContactModel {
                Id = 1, Name = "name", Phone = "123", Email = "*****@*****.**"
            };
            IContactEditorViewModel contactEditor = this.CreateSubject(contactToUpdate);

            // act
            contactEditor.ShowDialog();
            contactEditor.Contact.Name = "newName";
            contactEditor.SaveCommand.Execute(null);

            // assert
            Assert.IsNotNull(contactEditor.DialogResult);
            ContactModel expected = new ContactModel {
                Id = 1, Name = "newName", Phone = "123", Email = "*****@*****.**"
            };

            expected.Should().BeEquivalentTo(contactEditor.DialogResult);
        }
        public void UpdateContact_Save_Validated()
        {
            // arrange
            ContactModel contactToUpdate = new ContactModel {
                Id = 1, Name = "name", Phone = "123", Email = "*****@*****.**"
            };
            IContactEditorViewModel contactEditor = this.CreateSubject(contactToUpdate);

            // act
            contactEditor.ShowDialog();
            contactEditor.Contact.Name = string.Empty;
            contactEditor.SaveCommand.Execute(null);

            // assert
            Assert.IsTrue(contactEditor.Contact.HasErrors);
        }
        public void CreateContact_Cancel_ContactNotCreated()
        {
            // arrange
            IContactEditorViewModel contactEditor = this.CreateSubject(new ContactModel());

            // act
            contactEditor.ShowDialog();
            contactEditor.Contact.Name  = "Name";
            contactEditor.Contact.Phone = "123";
            contactEditor.Contact.Email = "*****@*****.**";
            contactEditor.CloseCommand.Execute(null);

            // assert
            this._viewAdapter.Verify(x => x.ShowDialog(), Times.Once);
            this._viewAdapter.Verify(x => x.Close(), Times.Once);
            Assert.IsNull(contactEditor.DialogResult);
        }