Пример #1
0
        public ContactViewModel(Contact contact, ContactRepository contactRepository)
        {
            if (contact == null)
                throw new ArgumentNullException("contact");

            if (contactRepository == null)
                throw new ArgumentNullException("contactRepository");

            _contact = contact;
            _contactRepository = contactRepository;
        }
Пример #2
0
        public void TestNewCustomerIsAddedProperly()
        {
            var target = new ContactRepository(Constants.CONTACT_DATA_FILE);
            var contact = Contact.CreateNewContact();

            bool eventArgIsValid = false;
            target.ContactAdded += (sender, e) => eventArgIsValid = (e.NewContact == contact);
            target.AddContact(contact);

            Assert.IsTrue(eventArgIsValid, "Invalid NewContact property");
            Assert.IsTrue(target.ContainsContact(contact), "New contact was not added");
        }
Пример #3
0
        public AllContactsViewModel(ContactRepository contactRepository)
        {
            if (contactRepository == null)
                throw new ArgumentNullException("contactRepository");

            base.DisplayName = Resources.AllContactsViewModel_DisplayName;

            _contactRepository = contactRepository;

            _contactRepository.ContactAdded += this.OnContactAddedToRepository;

            this.CreateAllContacts();
        }
Пример #4
0
        public void CustomerFieldsShouldWorkCorreclty()
        {
            var cust = Contact.CreateNewContact();
            var repos = new ContactRepository(Constants.CONTACT_DATA_FILE);
            var target = new ContactViewModel(cust, repos);

            target.FirstName = Resources.Contact_Error_MissingFirstName;
            Assert.AreEqual(target.FirstName, "First name is missing");

            target.LastName = Resources.Contact_Error_MissingLastName;
            Assert.AreEqual(target.LastName, "Last name is missing");

            target.PhoneNumber = Resources.Contact_Error_MissingPhoneNumber;
            Assert.AreEqual(target.PhoneNumber, "Phone number is missing");

            target.Email = Resources.Contact_Error_InvalidEmail;
            Assert.AreEqual(target.Email, "E-mail address is invalid");

            target.Email = Resources.Contact_Error_MissingEmail;
            Assert.AreEqual(target.Email, "E-mail address is missing");
        }
Пример #5
0
        public MainWindowViewModel(string contactDataFile)
        {
            base.DisplayName = Resources.MainWindowViewModel_DisplayName;

            _contactRepository = new ContactRepository(contactDataFile);
        }
Пример #6
0
 public void TestAllCustomersAreLoaded()
 {
     var target = new ContactRepository(Constants.CONTACT_DATA_FILE);
     Assert.AreEqual(4, target.GetContacts().Count, "Invalid number of contacts in repository.");
 }