public void FilterByEnvironmentTest() {
            var plan = CreateRegressionPlan();
            var suite = CreateRegressionSuite("Suite", plan);

            var matchingEnvironment = CreateEnvironment("Windows 7 x64", null);
            var nonMatchingEnvironment = CreateEnvironment("Windows 7 x86", null);
            var testSet = EntityFactory.CreateTestSet(TestSetName, suite);
            testSet.Environment = matchingEnvironment;
            testSet.Save();

            ResetInstance();

            var filter = new TestSetFilter();
            filter.Environment.Add(matchingEnvironment);
            var testSets = Instance.Get.TestSets(filter);
            CollectionAssert.Contains(testSets, testSet);

            filter.Environment.Clear();
            filter.Environment.Add(nonMatchingEnvironment);
            testSets = Instance.Get.TestSets(filter);
            CollectionAssert.DoesNotContain(testSets, testSet);

            matchingEnvironment.Close();
            nonMatchingEnvironment.Close();
        }
 /// <summary>
 /// TestSets associated with this Environment
 /// </summary>
 /// <param name="filter"></param>
 /// <returns>Criteria to filter TestSets on. </returns>
 public ICollection<TestSet> GetTestSets(TestSetFilter filter)
 {
     filter = filter ?? new TestSetFilter();
     filter.Environment.Clear();
     filter.Environment.Add(this);
     return Instance.Get.TestSets(filter);
 }
        public void CreateTestSetTest() {
            var regressionSuite = GetRegressionSuite();
            var testSet = EntityFactory.CreateTestSet(TestSetName, regressionSuite);
            var filter = new TestSetFilter();
            filter.RegressionSuite.Add(regressionSuite);
            filter.Project.Add(SandboxProject);

            ResetInstance();

            var testSets = new List<TestSet>(Instance.Get.TestSets(filter));
            CollectionAssert.Contains(testSets, testSet);
            Assert.IsTrue(testSets[0].Project.Equals(SandboxProject));
            Assert.IsTrue(testSets[0].RegressionSuite.Equals(regressionSuite));
        }
        public void CreateTestSetWithAttributesTest() {
            var regressionSuite = GetRegressionSuite();
            var attributes = new Dictionary<string, object> {{"Description", TestSetDescription}};

            var testSet = EntityFactory.CreateTestSet(TestSetName, regressionSuite, attributes);

            ResetInstance();

            var filter = new TestSetFilter();
            filter.RegressionSuite.Add(regressionSuite);
            filter.Project.Add(SandboxProject);

            var testSets = new List<TestSet>(Instance.Get.TestSets(filter));
            CollectionAssert.Contains(testSets, testSet);
            Assert.IsTrue(testSets[0].Project.Equals(SandboxProject));
            Assert.IsTrue(testSets[0].RegressionSuite.Equals(regressionSuite));
        }
        public void DeleteTestSetTest() {
            var regressionSuite = GetRegressionSuite();
            var attributes = new Dictionary<string, object> {{"Description", TestSetDescription}};

            var testSet = EntityFactory.CreateTestSet(TestSetName, regressionSuite, attributes);

            ResetInstance();

            var filter = new TestSetFilter();
            filter.RegressionSuite.Add(regressionSuite);
            filter.Project.Add(SandboxProject);
            var testSets = Instance.Get.TestSets(filter);

            Assert.IsTrue(testSets.Count == 1);

            testSet.Delete();
            ResetInstance();

            testSets = Instance.Get.TestSets(filter);
            Assert.IsTrue(testSets.Count == 0);
        }
        public void FilterByRegressionSuiteTest() {
            var plan = CreateRegressionPlan();
            var suite1 = CreateRegressionSuite("Suite 1", plan);
            var suite2 = CreateRegressionSuite("Suite 2", plan);
            EntityFactory.Create(() => Instance.Create.TestSet(TestSetName, suite1, SandboxProject));

            var filter = new TestSetFilter();

            filter.RegressionSuite.Add(suite2);

            var testSets = Instance.Get.TestSets(filter);
            Assert.AreEqual(0, testSets.Count);

            filter.RegressionSuite.Add(suite1);

            testSets = Instance.Get.TestSets(filter);
            Assert.AreEqual(1, testSets.Count);

            filter.RegressionSuite.Remove(suite2);

            testSets = Instance.Get.TestSets(filter);
            Assert.AreEqual(1, testSets.Count);
        }
        /// <summary>
        /// Request related Test Sets.
        /// </summary>
        /// <param name="filter">Test Set filter</param>
        /// <returns>Related Test Sets</returns>
        public ICollection<TestSet> GetTestSets(TestSetFilter filter) {
            filter = filter ?? new TestSetFilter();
            filter.RegressionSuite.Clear();
            filter.RegressionSuite.Add(this);

            return Instance.Get.TestSets(filter);
        }
        public void CreateTestSetWithEnvironmentTest() {
            var regressionSuite = GetRegressionSuite();
            var environment = CreateEnvironment("Environment for TestSet", null);
            var testSet = EntityFactory.CreateTestSet(TestSetName, regressionSuite);
            testSet.Environment = environment;
            testSet.Save();

            var filter = new TestSetFilter();
            filter.Environment.Add(environment);
            filter.Project.Add(SandboxProject);

            ResetInstance();

            var testSets = new List<TestSet>(Instance.Get.TestSets(filter));
            CollectionAssert.Contains(testSets, testSet);
            Assert.IsTrue(testSets[0].Project.Equals(SandboxProject));
            Assert.IsTrue(testSets[0].Environment.Equals(environment));
        }