public static void SaveTestSets(RegressionSuite suite, Project project, IList<Member> owners)
        {
            IAssetType testSetType = Program.MetaModel.GetAssetType("TestSet");
            IAttributeDefinition testSetName = testSetType.GetAttributeDefinition("Name");
            IAttributeDefinition testSetRegressionSuite = testSetType.GetAttributeDefinition("RegressionSuite");
            IAttributeDefinition testSetPriority = testSetType.GetAttributeDefinition("Priority");
            IAttributeDefinition testSetStatus = testSetType.GetAttributeDefinition("Status");
            IAttributeDefinition testSetEstimate = testSetType.GetAttributeDefinition("Estimate");
            IAttributeDefinition testSetEnvironment = testSetType.GetAttributeDefinition("Environment");
            IAttributeDefinition testSetIteration = testSetType.GetAttributeDefinition("Timebox");
            IAttributeDefinition testSetOwners = testSetType.GetAttributeDefinition("Owners");

            int randomForEnvironment = 1;
            foreach (RegressionTestSet testSet in suite.RegressionTestSets)
            {
                //Asset asset = Program.Services.New(testSetType, Oid.FromToken(project.Id, Program.MetaModel));
                Asset asset = Program.Services.New(testSetType, Oid.FromToken(project.Releases[0].Id, Program.MetaModel));
                asset.SetAttributeValue(testSetName, testSet.Name);
                asset.SetAttributeValue(testSetRegressionSuite, Oid.FromToken(suite.Id, Program.MetaModel));
                asset.SetAttributeValue(testSetPriority, Oid.FromToken(testSet.Priority, Program.MetaModel));
                asset.SetAttributeValue(testSetEstimate, testSet.Estimate);

                if (project.Environments.Count > 0)
                {
                    randomForEnvironment %= project.Environments.Count;
                    asset.SetAttributeValue(testSetEnvironment, project.Environments[randomForEnvironment].Id);
                }

                //if ( testSet.Iteration != null )
                //{
                    //asset.SetAttributeValue( testSetIteration, Oid.FromToken( testSet.Iteration.Id, Program.MetaModel ) );
                    asset.SetAttributeValue(testSetIteration, Oid.FromToken(project.Iterations[0].Id, Program.MetaModel));

                    // Only add owner if story is in iteration
                    asset.AddAttributeValue(testSetOwners, Oid.FromToken(owners[0].Id, Program.MetaModel));
                //}

                if (testSet.Status != Utils.StatusNone)
                    asset.SetAttributeValue(testSetStatus, Oid.FromToken(testSet.Status, Program.MetaModel));

                Program.Services.Save(asset);
                testSet.Id = asset.Oid.Momentless.Token;
                randomForEnvironment++;

                IOperation copyTest = Program.MetaModel.GetOperation("TestSet.CopyAcceptanceTestsFromRegressionSuite");
                Oid testSetOid = Program.Services.ExecuteOperation(copyTest, Oid.FromToken( testSet.Id, Program.MetaModel));

                // Update owner, detail estimate, todo and status for all TestSet tests in an iteration
                //if ( testSet.Iteration != null )
                //    UpdateIterationTests( testSetOid, owners );
            }
        }
        // This method creates Regression Suites AND the Regression Tests that are associated to them.
        // To create RTs just for the inventory add them via the RegressionTest class.
        public static void AddRegressionSuites(Project project)
        {
            RegressionSuite suite;

            suite = new RegressionSuite("Login/out", 0);
            suite.RegressionTests.Add(new RegressionTest("Login - Web security", "", "", "Login"));
            suite.RegressionTests.Add(new RegressionTest("Login - Integrated security", "", "", "Login"));
            suite.RegressionTests.Add(new RegressionTest("Logout check", "", "", "Logout"));
            suite.RegressionTests.Add(new RegressionTest("Session restored from previous", "", "", "User Login"));
            RegressionTestSet.AddReleaseTestSets(suite);
            project.RegressionSuites.Add(suite);

            suite = new RegressionSuite("Settings", 0);
            suite.RegressionTests.Add(new RegressionTest("Update User Settings", "", "", "User Account"));
            suite.RegressionTests.Add(new RegressionTest("Save User Settings", "", "", "User Account"));
            project.RegressionSuites.Add(suite);
            
            suite = new RegressionSuite("Bookstore Quicklist", 1);
            suite.RegressionTests.Add(new RegressionTest("Listings by Genre", "", "", "Quicklist"));
            suite.RegressionTests.Add(new RegressionTest("Recommended listings based on prior purchases", "", "", "Quicklist User"));
            project.RegressionSuites.Add(suite);
            
            suite = new RegressionSuite("Cart", 1);
            suite.RegressionTests.Add(new RegressionTest("Cart persisted across sessions", "", "", "Cart"));
            suite.RegressionTests.Add(new RegressionTest("Add/Remove Cart Item", "", "", "Account Cart"));
            project.RegressionSuites.Add(suite);

            suite = new RegressionSuite("Search", 1);
            suite.RegressionTests.Add(new RegressionTest("Search books by Genre", "", "", "Search"));
            suite.RegressionTests.Add(new RegressionTest("Search books by ISBN", "", "", "Search"));
            suite.RegressionTests.Add(new RegressionTest("Search books by Title", "", "", "Search"));
            project.RegressionSuites.Add(suite);
            
            suite = new RegressionSuite("Cancel Order", 2);
            suite.RegressionTests.Add(new RegressionTest("Order not Processed", "", "", "Orders"));
            suite.RegressionTests.Add(new RegressionTest("Order in Shipping", "", "", "Orders"));
            project.RegressionSuites.Add(suite);

            suite = new RegressionSuite("Checkout", 2);
            suite.RegressionTests.Add(new RegressionTest("1-Click Order", "", "", "Orders"));
            suite.RegressionTests.Add(new RegressionTest("Send as Gift Item", "", "", "Orders"));
            project.RegressionSuites.Add(suite);
            
            suite = new RegressionSuite("Special Orders", 2);
            suite.RegressionTests.Add(new RegressionTest("Apply Coupon Code", "", "", "Orders"));
            suite.RegressionTests.Add(new RegressionTest("Super Saver Shipping", "", "", "Orders"));                       
            project.RegressionSuites.Add(suite);
        }
 public static void AddReleaseTestSets(RegressionSuite regressionSuite)
 {
     regressionSuite.RegressionTestSets.Add(new RegressionTestSet("Regression Tests for sprint 1", Utils.PriorityHigh, Utils.StatusNone, 1));
 }