private static void DoIt(TcpClient client) { NetworkStream stream = client.GetStream(); StreamReader reader = new StreamReader(stream); StreamWriter writer = new StreamWriter(stream); while (true) { string request = reader.ReadLine(); if (request == "Stop") { break; } else { Console.WriteLine("Request: " + request); string[] values = request.Split(' '); string funcion = (string)values[0]; double _response = 0; double a = Double.Parse(values[1]); ConvertorClass c = new ConvertorClass(); if (funcion == "ToOunces") { _response = c.ConvertToOunces(a); } else if (funcion == "ToGrams") { _response = c.ConvertToGrams(a); } Console.WriteLine("Response: " + _response); writer.WriteLine(_response); writer.Flush(); } } client.Close(); }
public void TestConvertToGrams() { double result = c1.ConvertToGrams(30); Assert.AreEqual(850.486, result, 0.001); }