public void ToFarenheitCount()
 {
     var tData = new TemperatureData(54.44);
     var actual = tData.ToFarenheitCount();
     Assert.AreEqual(actual.Count, 0, "Just constructed so count should be zero.");
     Assert.AreEqual(actual.Farenheit, 129.992, "Celsius should be converted to the ~130 Farenheit.");
 }
 public void ToCelsiusCount()
 {
     var tData = new TemperatureData(54.44);
     var actual = tData.ToCelsiusCount();
     Assert.AreEqual(actual.Count, 0, "Just constructed so count should be zero.");
     Assert.AreEqual(actual.Celsius, 54.44, "Celsius should be the same as passed in the constructor.");
 }
 public void TemperatureData_Zero()
 {
     var tData = new TemperatureData(0);
     var expected = "0 C => 32 F requested 0 time.";
     var actual = tData.ToString();
     Assert.AreEqual(expected, actual, "Zero Celius is 32 Farenheit");
 }
 public void TemperatureData_Positive()
 {
     var tData = new TemperatureData(54.44);
     var expected = "54.44 C => 129.992 F requested 0 time.";
     var actual = tData.ToString();
     Assert.AreEqual(expected, actual, "54.44 Celius is around 130 Farenheit.  Medium rare.");
 }
 public void TemperatureData_Negative()
 {
     var tData = new TemperatureData(-20);
     var expected = "-20 C => -4 F requested 0 time.";
     var actual = tData.ToString();
     Assert.AreEqual(expected, actual, "-20 Celius is -4 Farenheit");
 }
Exemplo n.º 6
0
        /// <summary>
        /// Return a string containing the Farenheit conversion and the number of times it was requested.
        /// Insert into storage if this is the first time this value is requested.
        /// Update the requested count.
        /// </summary>
        /// <param name="celcius"></param>
        /// <returns></returns>
        public FarenheitCount Query(double celsius)
        {
            TemperatureData tData;

            lock (_lockObject)
            {
                if (!_currentStorage.ContainsKey(celsius))
                {
                    tData = new TemperatureData(celsius);
                    _currentStorage[celsius] = tData;
                }
                else
                {
                    tData = _currentStorage[celsius];
                }

                tData.Count++;
            }

            return tData.ToFarenheitCount();
        }