public void CreateEnvironmentTest() {
            var environment = CreateEnvironment(EnvironmentName, null);

            var filter = new EnvironmentFilter();
            filter.Name.Add(EnvironmentName);

            ResetInstance();

            var environments = new List<Environment>(Instance.Get.Environments(filter));
            CollectionAssert.Contains(environments, environment);
            Assert.AreEqual(EnvironmentName, environments[0].Name);
        }
        public void GetEnvironmentByName() {
            var environment = CreateEnvironment(EnvironmentName);
            var filter = new EnvironmentFilter();
            filter.Name.Add(EnvironmentName);
            
            var environments = Instance.Get.Environments(filter);

            CollectionAssert.Contains(environments, environment);

            filter = new EnvironmentFilter();
            filter.Name.Add("WrongName");
            
            environments = Instance.Get.Environments(filter);
            
            Assert.AreEqual(0, environments.Count);
        }
        public void GetEnvironmentWithSpecificProjectTest() {
            var project2 = EntityFactory.Create(() => Instance.Create.Project("other", SandboxProject.ParentProject, DateTime.Now, SandboxSchedule));
            var environment = CreateEnvironment(EnvironmentName);
            var filter = new EnvironmentFilter();
            filter.Project.Add(SandboxProject);

            var environments = Instance.Get.Environments(filter);

            CollectionAssert.Contains(environments, environment);

            filter = new EnvironmentFilter();
            filter.Project.Add(project2);

            environments = Instance.Get.Environments(filter);

            Assert.AreEqual(0, environments.Count);
        }
        public void GetEnvironmentByID() {
            var environment = CreateEnvironment(EnvironmentName);
            var displayId = environment.DisplayID;
            var filter = new EnvironmentFilter();
            filter.DisplayID.Add(displayId);
            
            var environments = Instance.Get.Environments(filter);

            Assert.AreEqual(1, environments.Count);
            CollectionAssert.Contains(environments, environment);

            filter = new EnvironmentFilter();
            filter.DisplayID.Add("WrongNumber");
            
            environments = Instance.Get.Environments(filter);
            
            Assert.AreEqual(0, environments.Count);
        }
        public void UpdateEnvironmentTest() {
            var environment = CreateEnvironment(EnvironmentName, null);
            ResetInstance();

            var environmentNew = Instance.Get.EnvironmentByID(environment.ID);
            Assert.AreEqual(EnvironmentName, environmentNew.Name);
            Assert.AreEqual(environment, environmentNew);
            
            environment.Name = EnvironmentNameUpdated;
            environment.Save();

            var filter = new EnvironmentFilter();
            filter.Name.Add(EnvironmentNameUpdated);
            filter.Project.Add(SandboxProject);

            ResetInstance();

            var environments = new List<Environment>(Instance.Get.Environments(filter));
            Assert.AreEqual(EnvironmentNameUpdated, environments[0].Name);
            CollectionAssert.Contains(environments, environment);
        }
        public void CreateEnvironmentWithAttributesTest() {
            const string newName = "AnotherName";
            var newProject = EntityFactory.CreateProject("new project", SandboxProject, null);
            
            var attributes = new Dictionary<string, object> {
                {"Name", newName}, 
                {"Scope", newProject.ID.Token}
            };
            var environment = CreateEnvironment(EnvironmentName, attributes);

            ResetInstance();

            var filter = new EnvironmentFilter();
            filter.Name.Add(newName);
            filter.Project.Add(newProject);

            var environments = new List<Environment>(Instance.Get.Environments(filter));
            CollectionAssert.Contains(environments, environment);
            Assert.AreEqual(newProject, environments[0].Project);
            Assert.AreEqual(newName, environments[0].Name);
        }