public DataContracts.ICompany GetCompanyById(int companyId)
        {
            Company company = null;

            using (var connection = new SqlConnection(base.ConnectionString))
            {
                connection.Open();

                using (var command = new SqlCommand("select * from Company where CompanyId = " + companyId, connection))
                {
                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        company = new Company();

                        company.Name = Convert.ToString(reader["Name"]);
                        company.Address.City = Convert.ToString(reader["City"]);
                        company.Address.Street1 = Convert.ToString(reader["Address1"]);
                        company.Address.Street2 = Convert.ToString(reader["Address2"]);
                        company.Address.PostalCode = Convert.ToString(reader["Zip"]);
                        company.Address.StateCode = Convert.ToString(reader["StateId"]);
                        company.CompanyId = Convert.ToInt32(reader["CompanyId"]);
                        company.PhoneNumber = Convert.ToString(reader["PhoneNumber"]);
                    }

                }
            }
            return company;
        }
        public void TestProperlyConstructedCompanyPasses()
        {
            var company = new Company {Name = "Solutia Consulting",
                                       Address = new Address{Street1 = "123 Main St.", City = "St. Paul", PostalCode="55117", StateCode="MN"},
                                       PhoneNumber = "7153388711",
                                       };
            var validator = new CompanyValidator();

               var result = validator.validateCompany(company);

               Assert.AreEqual(0,result.Count);
        }
        public void TestCompanyDoesntHaveAddress()
        {
            var company = new Company
            {   Name = "Solutia Consulting",
                PhoneNumber = "7153388711",
            };
            var validator = new CompanyValidator();

            var result = validator.validateCompany(company);

            Assert.AreNotEqual(0, result.Count);
        }
        public void TestCompanyDoesntHavePhoneNumber()
        {
            var company = new Company
            {
                Name = "Solutia Consulting",
                Address = new Address { Street1 = "123 Main St.", City = "St. Paul", PostalCode = "55117", StateCode = "MN" }
            };
            var validator = new CompanyValidator();

            var result = validator.validateCompany(company);

            Assert.AreNotEqual(0, result.Count);
        }
        public void TestCompanyDoesntHaveName()
        {
            var company = new Company
            {
                Address = new Address { Street1 = "123 Main St.", City = "St. Paul", PostalCode = "55117", StateCode = "MN" },
                PhoneNumber = "7153388711",
            };
            var validator = new CompanyValidator();

            var result = validator.validateCompany(company);

            Assert.AreEqual(1, result.Count);
        }