Beispiel #1
0
        public void TestMethod2()
        {
            double gramsValue = 1;
            WeightConverterLibClass converter = new WeightConverterLibClass();
            double result = converter.fromGramToOunces(gramsValue);

            Assert.AreEqual(0.035274, result);
        }
Beispiel #2
0
        public void TestMethod1()
        {
            double ouncesValue = 1;
            WeightConverterLibClass converter = new WeightConverterLibClass();
            double result = converter.fromOuncesToGrams(ouncesValue);

            Assert.AreEqual(28.35, result);
        }
Beispiel #3
0
        private static void DoIt(TcpClient clientConnection)
        {
            Console.WriteLine("Incoming client " + clientConnection.Client);

            // Step no : 4 ...........................................
            // Server recieved (byte of data) from client , Server perf orm read opertion
            _nstream = _connectionSocket.GetStream();

            while (_nstream != null)
            {
                _sReader = new StreamReader(_nstream);

                _msgFromClient = _sReader.ReadLine();
                int    position        = _msgFromClient.IndexOf("=");
                string firstValue      = _msgFromClient.Substring(0, position);
                string secondValue     = _msgFromClient.Substring(position + 1);
                double valueFromClient = double.Parse(secondValue);

                _sWriter = new StreamWriter(_nstream)
                {
                    AutoFlush = true
                };

                if ("g" == firstValue)
                {
                    WeightConverterLibClass weightConverter = new WeightConverterLibClass();
                    double result = weightConverter.fromGramToOunces(valueFromClient);
                    _sWriter.WriteLine(result);
                    Console.WriteLine("Client Msg:" + result);
                }
                else
                {
                    WeightConverterLibClass weightConverter = new WeightConverterLibClass();
                    double result = weightConverter.fromOuncesToGrams(valueFromClient);
                    _sWriter.WriteLine(result);
                    Console.WriteLine("Client Msg:" + result);
                }
            }
        }