public void TestMethods1() { Converting obj = new Converting(); double expected = 0.2822; double actual = obj.ConvertToOunces(8); 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(); }