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);
        }
 public void Parse_throws_exception_if_text_is_illegal(string illegalText)
 {
     Assert.Throws <ArgumentException>(() => FeatureToggleValue.Parse(illegalText));
 }
 public void Parse_throws_exception_if_text_is_in_wrong_format(string text)
 {
     Assert.Throws <FormatException>(() => FeatureToggleValue.Parse(text));
 }
示例#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();
        }