public void TestAddEmployeeCmdWriter(string name, string address, string city, string state, int yearlySalary)
        {
            StringWriter expectedWriter = new StringWriter();

            expectedWriter.Write(new char[] { (char)0xde, (char)0xad });
            expectedWriter.Write(name.Length + address.Length + city.Length + state.Length + yearlySalary.ToString().Length + 11);
            expectedWriter.Write((char)0x02);
            expectedWriter.Write(name);
            expectedWriter.Write((char)0x00);
            expectedWriter.Write(address);
            expectedWriter.Write((char)0x00);
            expectedWriter.Write(city);
            expectedWriter.Write((char)0x00);
            expectedWriter.Write(state);
            expectedWriter.Write((char)0x00);
            expectedWriter.Write(yearlySalary);
            expectedWriter.Write(new char[] { (char)0x00, (char)0xbe, (char)0xef });

            string expected = expectedWriter.ToString();

            AddEmployeeCmd cmd    = new AddEmployeeCmd(name, address, city, state, yearlySalary);
            StringWriter   writer = new StringWriter();

            cmd.Write(writer);

            string actual = writer.ToString();

            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public void SentCorrectly(int index)
        {
            EmployeeDetail employeeDetail = new EmployeeDetail("Fred Brooks", "123 My House", "Springfield", "IL", "72000");
            AddEmployeeCmd cmd            = new AddEmployeeCmd(employeeDetail);
            StringWriter   writer         = new StringWriter();

            cmd.Write(writer);
            Assert.AreEqual(KnownGood[index], writer.ToString()[index], "comparison failed at byte number " + index);
        }
Exemple #3
0
        public void SentCorrectly(Employee employee)
        {
            string expected = CreateExpectedMessage(employee);

            AddEmployeeCmd cmd    = new AddEmployeeCmd(employee);
            StringWriter   writer = new StringWriter();

            cmd.Write(writer);

            Assert.AreEqual(expected, writer.ToString());
        }