Esempio n. 1
0
        public void Contact_MissingData_ShouldNotBeAllowed()
        {
            Contact contact;

            // Valid Contract
            contact = TestModelCreator.NewValidContact();
            Assert.IsTrue(ModelIsValid(contact));

            //Without First Name
            contact           = TestModelCreator.NewValidContact();
            contact.FirstName = null;
            Assert.IsFalse(ModelIsValid(contact));

            //Without Last Name
            contact          = TestModelCreator.NewValidContact();
            contact.LastName = null;
            Assert.IsFalse(ModelIsValid(contact));

            //Without Phonenumber
            contact = TestModelCreator.NewValidContact();
            contact.MobilePhoneNumber = null;
            Assert.IsFalse(ModelIsValid(contact));

            //Without ContactSkills
            contact = TestModelCreator.NewValidContact();
            contact.ContactSkills = null;
            Assert.IsFalse(ModelIsValid(contact));

            //Without Empty ContactSkills
            contact = TestModelCreator.NewValidContact();
            contact.ContactSkills.Clear();
            Assert.IsFalse(ModelIsValid(contact));

            //Without Skill Name
            contact = TestModelCreator.NewValidContact();
            contact.ContactSkills[0].Skill.Name = null;
            Assert.IsFalse(ModelIsValid(contact));

            //Without Skill
            contact = TestModelCreator.NewValidContact();
            contact.ContactSkills[0].Skill = null;
            Assert.IsFalse(ModelIsValid(contact));

            //Without Address
            contact             = TestModelCreator.NewValidContact();
            contact.MainAddress = null;
            Assert.IsFalse(ModelIsValid(contact));

            //Without Address Postal Code
            contact = TestModelCreator.NewValidContact();
            contact.MainAddress.PostalCode = null;
            Assert.IsFalse(ModelIsValid(contact));

            //Without Address Country
            contact = TestModelCreator.NewValidContact();
            contact.MainAddress.CountryCode = null;
            Assert.IsFalse(ModelIsValid(contact));

            //ToDo: Expand Tests
        }
Esempio n. 2
0
        public async Task Contact_InsertNewContact_ShouldBeAbleToRetrieveItBack()
        {
            ContactController controller      = new ContactController(_storage);
            Contact           contact         = TestModelCreator.NewValidContact(Guid.NewGuid().ToString());
            Contact           insertedContact = await controller.PostAsync(contact);

            Assert.AreEqual(contact.FirstName, insertedContact.FirstName);
        }