public void TestMethods() { Converting obj = new Converting(); double expected = 283.4952; double actual = obj.ConvertToGrams(10); double delta = 0.0001; Assert.AreEqual(expected, actual, delta); }
private static void Weight(TcpClient client) { NetworkStream stream = client.GetStream(); StreamReader reader = new StreamReader(stream); StreamWriter writer = new StreamWriter(stream); while (true) { string request = reader.ReadLine(); if (request == "Bye") { break; } Console.WriteLine("Request: " + request); string[] values = request.Split(" "); string function = (string)values[0]; double x = Double.Parse(values[1]); double response = 0; Converting cv = new Converting(); if (function == "ConvertToGrams") { response = cv.ConvertToGrams(x); } else if (function == "ConvertToOunces") { response = cv.ConvertToOunces(x); } Console.WriteLine("Response: " + response); writer.WriteLine(response); writer.Flush(); } client.Close(); }