Exemplo n.º 1
0
        public void ShouldWriteLicenseInformation()
        {
            // Arrange
            var command        = new DisplayVersionCommand();
            var messageService = new Mock <IMessageService>();

            command.MessageService = messageService.Object;

            // Act
            command.Execute(new[] { "version" });

            // Assert
            messageService.Verify(m => m.WriteLine("License MIT: The MIT License"));
            messageService.Verify(m => m.WriteLine("This is free software: you are free to change and redistribute it."));
            messageService.Verify(m => m.WriteLine("There is NO WARRANTY, to the extent permitted by law."));
        }
Exemplo n.º 2
0
        public void ShouldWriteAssemblyCopyrightStatement()
        {
            // Arrange
            var command        = new DisplayVersionCommand();
            var messageService = new Mock <IMessageService>();

            command.MessageService = messageService.Object;
            var assembly    = typeof(dbversion.Console.Program).Assembly;
            var versionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

            // Act
            command.Execute(new[] { "version" });

            // Assert
            messageService.Verify(m => m.WriteLine(versionInfo.LegalCopyright));
        }
Exemplo n.º 3
0
        public void ShouldDisplayProgramNameAndVersion()
        {
            // Arrange
            var command        = new DisplayVersionCommand();
            var messageService = new Mock <IMessageService>();

            command.MessageService = messageService.Object;
            var    name          = typeof(dbversion.Console.Program).Assembly.GetName().Name;
            var    version       = typeof(dbversion.Console.Program).Assembly.GetName().Version;
            string expectedTitle = string.Format("{0} {1}", name, version);

            // Act
            command.Execute(new[] { "version" });

            // Assert
            messageService.Verify(m => m.WriteLine(expectedTitle));
        }
Exemplo n.º 4
0
        static int Main(string[] args)
        {
            var options = Options.Parse(args);

            if (options.ShowHelp)
            {
                Console.WriteLine(options.PrintHelp());
                return(1);
            }

            var      code    = 0;
            ICommand command = null;

            if (options.ShowAssemblyVersion)
            {
                command = new ShowAssemblyVersionCommand();
            }
            else if (options.Verb == "init")
            {
                command = new InitConfigCommand();
            }
            else if (options.Verb == "major")
            {
                command = new BumpMajorVersionCommand();
            }
            else if (options.Verb == "minor")
            {
                command = new BumpMinorVersionCommand();
            }
            else if (options.Verb == "tag")
            {
                command = new TagCommand();
            }
            else
            {
                command = new DisplayVersionCommand();
            }

            code = command?.Execute(options) ?? -1;

            return(code);
        }