Esempio n. 1
0
        private void DoClient(TcpClient client)
        {
            while (client.Connected)
            {
                var getStream    = client.GetStream();
                var streamReader = new StreamReader(getStream);
                var streamWriter = new StreamWriter(getStream);
                streamWriter.Flush();

                string[] incommingStrings;
                incommingStrings = streamReader.ReadLine().Split(' ');
                var options = incommingStrings[0].ToUpper();

                if (options == "TOGRAM")
                {
                    double unitWeight    = double.Parse(incommingStrings[1]);
                    double convertResult = WeightConverter.OzToGrams(unitWeight);

                    streamWriter.WriteLine(convertResult);
                }

                if (options == "TOOZ")
                {
                    double unitWeight    = double.Parse(incommingStrings[1]);
                    double convertResult = WeightConverter.GramsToOz(unitWeight);

                    streamWriter.WriteLine(convertResult);
                }
            }
        }
Esempio n. 2
0
 // Expected to pass
 public void OzToGrams()
 {
     Assert.AreEqual(2834.9523125, WeightConverter.OzToGrams(100), 0.0001);
 }