Пример #1
0
        public void VerifyAssociate()
        {
            IAssociate associate = BusinessObjectInitializer.CreateAssociate();
            Random     random    = new Random();

            associate.IdCountry          = random.Next(1, 3);
            associate.Name               = DATestUtils.GenerateString(50, true, false);
            associate.InergyLogin        = DATestUtils.GenerateString(50, true, false);
            associate.EmployeeNumber     = DATestUtils.GenerateString(15, true, false);
            associate.IsActive           = true;
            associate.PercentageFullTime = random.Next(1, 100);
            associate.IsSubContractor    = true;

            int newId = InsertAssociateTest(associate);

            //Verifies that the id returned by the insert method is greater than 1
            Assert.Greater(newId, 0);

            int rowsAffected = UpdateAssociateTest(associate);

            //Verifies that one and only one row is affected by the update
            Assert.AreEqual(1, rowsAffected);

            DataTable resultTable = SelectAssociateTest(associate).Tables[0];

            //Verifies that the table contains the correct column names and order
            StringCollection columns = new StringCollection();

            columns.AddRange(new string[] { "CountryName",
                                            "EmployeeNumber",
                                            "Name",
                                            "InergyLogin",
                                            "IsActive",
                                            "PercentageFullTime",
                                            "IsSubContractor",
                                            "Id",
                                            "IdCountry" });

            DATestUtils.CheckTableStructure(resultTable, columns);

            int rowCount = DeleteAssociateTest(associate);

            Assert.AreEqual(1, rowCount);
        }