Ejemplo n.º 1
0
        private async Task <int> ForceUpdate()
        {
            var newBit = BuildBit();
            await _repo.UpdateAsync(newBit);

            SystemContext.ConsoleWriteLine("Feature bit updated.");
            return(0);
        }
        public void ItShouldBeAbleToUseASubstituteForConsoleDotWriteLine()
        {
            // Arrange
            var builder = new StringBuilder();

            SystemContext.ConsoleWriteLine = s => builder.Append(s);

            // Act
            SystemContext.ConsoleWriteLine("foo" + Environment.NewLine);

            // Assert
            Assert.Equal("foo" + Environment.NewLine, builder.ToString());

            // Afterwards
            SystemContext.ConsoleWriteLine = null;
        }
        public async Task <int> RunAsync()
        {
            int returnValue = 0;
            var name        = _opts.Name;
            var def         = await _repo.GetByNameAsync(name);

            if (def == null)
            {
                SystemContext.ConsoleErrorWriteLine($"Feature bit '{_opts.Name}' could not be found.");
                returnValue = 1;
            }
            else
            {
                await _repo.RemoveAsync(def);

                SystemContext.ConsoleWriteLine("Feature bit removed.");
            }

            return(returnValue);
        }
Ejemplo n.º 4
0
        public async Task <int> RunAsync()
        {
            int returnValue = 0;

            try
            {
                IFeatureBitDefinition newBit = BuildBit();
                await _repo.AddAsync(newBit);

                SystemContext.ConsoleWriteLine("Feature bit added.");
            }
            catch (DataException e)
            {
                returnValue = await HandleFeatureBitAlreadyExists(e);
            }
            catch (Exception e)
            {
                returnValue = 1;
                SystemContext.ConsoleErrorWriteLine(e.ToString());
            }

            return(returnValue);
        }