예제 #1
0
        public void Should_ConvertPersonObject_ToString()
        {
            Person person = new Person();
            Parser parser = new Parser();

            person.Id = 1;
            person.CityId = 8;
            person.FIO = "Ivanov Petr Olegovich";
            string res = parser.AddPersonEncode(person);
            Assert.AreEqual(res,"#12#1#8#Ivanov Petr Olegovich");
        }
예제 #2
0
        public void Should_ConvertCityObject_ToString()
        {
            City city = new City();
            city.Id = 0;
            city.Name = "Donetsk";
            city.Region = "Don";
            city.Country = "UA";
            city.Attrib = false;

            Parser parser = new Parser();
            string res = parser.AddCityEncode(city);
            Assert.AreEqual(res,"#02#0#Donetsk#Don#UA#False");
        }
예제 #3
0
 private bool Check(IPAddress ip)
 {
     StreamReader reader;
     StreamWriter writer;
     Parser parser = new Parser();
     try
     {
         using (TcpClient tcpClient = new TcpClient(ip.ToString(), port))
         {
             reader = new StreamReader(tcpClient.GetStream());
             writer = new StreamWriter(tcpClient.GetStream());
             writer.WriteLine(parser.TestConnectionEncode());
             writer.Flush();
             if ((reader.ReadLine() != Resources.Success) || !tcpClient.Connected)
             {
                 return false;
             }
             else
             {
                 return true;
             }
         }
     }
     catch(SocketException ex)
     {
         MessageBox.Show(ex.Message);
         return false;
     }
 }