Esempio n. 1
0
        public async Task GetEnvironments_ReturnsAList_WithAllTheEnvironments_ForTheGivenApplication()
        {
            //arrange
            var app = Application.Create("TestApp", "DEV", false);

            var expectedEnvNames = new List <string>
            {
                "DEV",
                "QA",
                "SBX",
                "TRN",
                "LIVE"
            };

            app.AddDeployEnvironment("QA", false, false, false);
            app.AddDeployEnvironment("SBX", false, false, false);
            app.AddDeployEnvironment("TRN", false, false, false);
            app.AddDeployEnvironment("LIVE", false, false, false);
            await _appRepository.AddAsync(app);

            //act
            var results = await _featureToggleController.GetEnvironments(app.Id) as OkObjectResult;

            //assert
            var returnedEnvs = (results.Value as IEnumerable <DeployEnvironment>).Select(env => env.EnvName);

            returnedEnvs.Should().BeEquivalentTo(expectedEnvNames);
        }
Esempio n. 2
0
        public void GetEnvironments_ReturnsAList_WithAllTheDistinctEnvironments_ForTheGivenApplication()
        {
            //arrange
            var app = new Application {
                Id = 1, AppName = "TestApp"
            };
            var dev = new DeployEnvironment {
                Application = app, ApplicationId = app.Id, Id = 10, EnvName = "DEV"
            };
            var qa = new DeployEnvironment {
                Application = app, ApplicationId = app.Id, Id = 11, EnvName = "QA"
            };
            var duplicateQa = new DeployEnvironment {
                Application = app, ApplicationId = app.Id, Id = 12, EnvName = "QA"
            };

            var expectedEnvNames = new List <string> {
                dev.EnvName, qa.EnvName
            };

            _context.DeployEnvironments.AddRange(dev, qa, duplicateQa);
            _context.SaveChanges();
            var controller = new FeatureTogglesController(_context);

            //act
            var results = controller.GetEnvironments(app.Id) as OkObjectResult;

            //assert
            results.Value.Should().BeEquivalentTo(expectedEnvNames);
        }