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

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

            return value;
        }
예제 #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;
        }
예제 #4
0
        private string GetPassword(AppArguments arguments)
        {
            var value = arguments.GetProperty("p");

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

            return(value);
        }
예제 #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);
        }
예제 #6
0
        private string GetEmail(AppArguments arguments)
        {
            var value = arguments.GetProperty("email");

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

            return(value);
        }
예제 #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();
        }
예제 #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();
        }
예제 #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);
        }
예제 #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);
        }
예제 #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;
        }
예제 #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);
        }
예제 #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");
        }