Exemplo n.º 1
0
        private string GetPassword(AppArguments arguments)
        {
            var value = arguments.GetProperty("p");
            if (string.IsNullOrEmpty(value))
                output.WriteLine("error: no password specified");

            return value;
        }
Exemplo n.º 2
0
        private string GetEmail(AppArguments arguments)
        {
            var value = arguments.GetProperty("email");
            if (string.IsNullOrEmpty(value))
                output.WriteLine("error: no email specified");

            return value;
        }
Exemplo n.º 3
0
        private string GetLastName(AppArguments arguments)
        {
            var value = arguments.GetProperty("ln");
            if (string.IsNullOrEmpty(value))
                output.WriteLine("error: no last name specified");

            return value;
        }
Exemplo n.º 4
0
        private string GetPassword(AppArguments arguments)
        {
            var value = arguments.GetProperty("p");

            if (string.IsNullOrEmpty(value))
            {
                output.WriteLine("error: no password specified");
            }

            return(value);
        }
Exemplo n.º 5
0
        private string GetLastName(AppArguments arguments)
        {
            var value = arguments.GetProperty("ln");

            if (string.IsNullOrEmpty(value))
            {
                output.WriteLine("error: no last name specified");
            }

            return(value);
        }
Exemplo n.º 6
0
        private string GetEmail(AppArguments arguments)
        {
            var value = arguments.GetProperty("email");

            if (string.IsNullOrEmpty(value))
            {
                output.WriteLine("error: no email specified");
            }

            return(value);
        }
Exemplo n.º 7
0
        public void should_output_a_missing_first_name_error()
        {
            var properties = new Dictionary<string, string>();
            properties["ln"] = "Salin";
            properties["email"] = "*****@*****.**";
            properties["p"] = "pass123";

            var arguments = new AppArguments { Command = "add", Properties = properties };

            sut.Run(arguments);
            ((OutputStub)output).Contains("error: no first name specified").ShouldBeTrue();
        }
Exemplo n.º 8
0
        public void should_output_a_missing_email_error()
        {
            var properties = new Dictionary<string, string>();
            properties["fn"] = "Louis";
            properties["ln"] = "Salin";
            properties["p"] = "pass123";

            var arguments = new AppArguments { Command = "add", Properties = properties };

            sut.Run(arguments);
            ((OutputStub)output).Contains("error: no email specified").ShouldBeTrue();
        }
Exemplo n.º 9
0
        public void Run(AppArguments arguments)
        {
            var firstname = GetFirstName(arguments);
            var lastname = GetLastName(arguments);
            var email = GetEmail(arguments);
            var password = GetPassword(arguments);

            var user = new User {FirstName = firstname,
                                 LastName = lastname,
                                 Email = email,
                                 Password = password};

            persister.Save(user);
        }
Exemplo n.º 10
0
        public void Run(AppArguments arguments)
        {
            var firstname = GetFirstName(arguments);
            var lastname  = GetLastName(arguments);
            var email     = GetEmail(arguments);
            var password  = GetPassword(arguments);

            var user = new User {
                FirstName = firstname,
                LastName  = lastname,
                Email     = email,
                Password  = password
            };

            persister.Save(user);
        }
Exemplo n.º 11
0
        public AppArguments Parse(string[] args)
        {
            if (args.Length == 0 || args[0].StartsWith("-"))
            {
                output.WriteLine("error: no command specified");
                return null;
            }

            var arguments = new AppArguments { Command = args[0], Properties = new Dictionary<string, string>() };

            for (var i = 1; i < args.Length; i++)
            {
                if (!UpdateProperties(args[i].Substring(1), arguments.Properties))
                    return null;
            }

            return arguments;
        }
Exemplo n.º 12
0
        public AppArguments Parse(string[] args)
        {
            if (args.Length == 0 || args[0].StartsWith("-"))
            {
                output.WriteLine("error: no command specified");
                return(null);
            }

            var arguments = new AppArguments {
                Command = args[0], Properties = new Dictionary <string, string>()
            };

            for (var i = 1; i < args.Length; i++)
            {
                if (!UpdateProperties(args[i].Substring(1), arguments.Properties))
                {
                    return(null);
                }
            }

            return(arguments);
        }
Exemplo n.º 13
0
        public void should_save_the_user()
        {
            var properties = new Dictionary<string, string>();
            properties["fn"] = "Louis";
            properties["ln"] = "Salin";
            properties["email"] = "*****@*****.**";
            properties["p"] = "pass123";

            var arguments = new AppArguments { Command = "add", Properties = properties };

            sut.Run(arguments);
            persister.SavedUser.FirstName.ShouldEqual("Louis");
            persister.SavedUser.LastName.ShouldEqual("Salin");
            persister.SavedUser.Email.ShouldEqual("*****@*****.**");
            persister.SavedUser.Password.ShouldEqual("pass123");
        }