Ejemplo n.º 1
0
        private string CreateExpectedMessage(LoginCredentials loginCredentials)
        {
            int dataLength = loginCredentials.Name.Length + 1;

            dataLength += loginCredentials.Password.Length + 1;

            char[] commandChar = CommandCharacterMapping.GetCommandCharacter(typeof(LoginCommand));

            int totalSize = CommandWriter.Header.Length +
                            dataLength.ToString().Length +
                            commandChar.Length +
                            CommandWriter.Footer.Length +
                            dataLength;

            StringWriter sw = new StringWriter();

            sw.Write(CommandWriter.Header);
            sw.Write(totalSize);
            sw.Write(commandChar);
            sw.Write(loginCredentials.Name);
            sw.Write(CommandWriter.SEPERATOR);
            sw.Write(loginCredentials.Password);
            sw.Write(CommandWriter.SEPERATOR);
            sw.Write(CommandWriter.Footer);

            return(sw.ToString());
        }
Ejemplo n.º 2
0
        private string CreateExpectedMessage(Employee employee)
        {
            int dataLength = employee.Name.Length + 1;

            dataLength += employee.Address.Length + 1;
            dataLength += employee.City.Length + 1;
            dataLength += employee.State.Length + 1;
            dataLength += employee.YearlySalary.ToString().Length + 1;

            char[] commandChar = CommandCharacterMapping.GetCommandCharacter(typeof(AddEmployeeCmd));

            int totalSize = CommandWriter.Header.Length +
                            dataLength.ToString().Length +
                            commandChar.Length +
                            CommandWriter.Footer.Length +
                            dataLength;

            StringWriter sw = new StringWriter();

            sw.Write(CommandWriter.Header);
            sw.Write(totalSize);
            sw.Write(commandChar);
            sw.Write(employee.Name);
            sw.Write(CommandWriter.SEPERATOR);
            sw.Write(employee.Address);
            sw.Write(CommandWriter.SEPERATOR);
            sw.Write(employee.City);
            sw.Write(CommandWriter.SEPERATOR);
            sw.Write(employee.State);
            sw.Write(CommandWriter.SEPERATOR);
            sw.Write(employee.YearlySalary);
            sw.Write(CommandWriter.SEPERATOR);
            sw.Write(CommandWriter.Footer);

            return(sw.ToString());
        }
Ejemplo n.º 3
0
 public LoginCommand(LoginCredentials loginCredentials)
     : base(CommandCharacterMapping.GetCommandCharacter(typeof(LoginCommand)))
 {
     LoginCredentials = loginCredentials;
 }
Ejemplo n.º 4
0
 public AddEmployeeCmd(Employee employee)
     : base(CommandCharacterMapping.GetCommandCharacter(typeof(AddEmployeeCmd)))
 {
     this.employee = employee;
 }