Exemplo n.º 1
0
        public void Parse_returns_expected(string text, string expectedId, bool expectedState)
        {
            var sut = FeatureToggleValue.Parse(text);

            Assert.AreEqual(expectedId, sut.Id);
            Assert.AreEqual(expectedState, sut.IsEnabled);
        }
Exemplo n.º 2
0
 public void Parse_throws_exception_if_text_is_illegal(string illegalText)
 {
     Assert.Throws <ArgumentException>(() => FeatureToggleValue.Parse(illegalText));
 }
Exemplo n.º 3
0
 public void Parse_throws_exception_if_text_is_in_wrong_format(string text)
 {
     Assert.Throws <FormatException>(() => FeatureToggleValue.Parse(text));
 }
Exemplo n.º 4
0
        public async Task ImportToggles(Guid environmentId, string format, MemoryStream stream)
        {
            var userId = authService.CurrentUserId();

            Guard.IsTrue(await hasEnvironmentPermission.ToRead(userId, environmentId), "Invalid permissions for read this environment");

            var environments = unitOfWork.Repository <ApplicationEnvironment, Guid>();
            var environment  = await environments.GetById(environmentId, "Application.FeatureToggles,FeatureToggleValues");

            var values = importer.Parse(stream, format);

            foreach (var entry in values)
            {
                environment.AddOrEditFeatureToggleValue(entry.Key, description: null, FeatureToggleValue.Parse(entry.Value).IsEnabled);
            }
            await unitOfWork.SaveAsync();
        }