示例#1
0
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments <ConfigCommand, ServerListCommand>(args)
            .WithParsed((c) => Task.Run(async() => await AbstractCommandHandler.StartWork((ICommand)c, ContainerConfig.Configure())));

            Console.Read();
        }
示例#2
0
        public async Task ServerListCommandHandler_HandlesNotLocal()
        {
            ServerListCommand command = new ServerListCommand()
            {
                FetchLocal = false
            };

            string serversPath = JsonConvert.DeserializeObject <StorageSettings>(new StreamReader("./StorageSettings.json").ReadToEnd()).ServerSavePath;

            if (File.Exists(serversPath))
            {
                File.Delete(serversPath);
            }

            await AbstractCommandHandler.StartWork(command, ContainerConfig.Configure());

            IEnumerable <Server> servers = null;

            using (var sr = new StreamReader(serversPath))
            {
                servers = JsonConvert.DeserializeObject <IEnumerable <Server> >(sr.ReadToEnd());
            }

            Assert.NotNull(servers);
            Assert.NotEmpty(servers);
        }
        public async Task ConfigCommandHandler_HandlesDefault(string username, string password)
        {
            ConfigCommand command = new ConfigCommand()
            {
                Username = username, Password = password
            };

            string credentialsPath = JsonConvert.DeserializeObject <StorageSettings>(new StreamReader("./StorageSettings.json").ReadToEnd()).CredentialsSavePath;

            if (File.Exists(credentialsPath))
            {
                File.Delete(credentialsPath);
            }

            await AbstractCommandHandler.StartWork(command, ContainerConfig.Configure());

            var credentials = JsonConvert.DeserializeObject <Credentials>(new StreamReader(credentialsPath).ReadToEnd());

            Assert.Equal(command.Username, credentials.Username);
            Assert.Equal(command.Password, credentials.Password);
        }