示例#1
0
        static void Main(string[] args)
        {
            IThermometer thermometer;
            var          freezingNotification = new FreezingNotification("Freezing notification", 0.0m, 0.5m, () => Console.WriteLine("----Freezing!!!------"));
            var          boilingNotification  = new BoilingNotification("Boiling notification", 100, 0.5m, () => Console.WriteLine("----Boiling Alert!!!----"));

            thermometer = new AdvancedThermometer(Unit.Celsius, freezingNotification, boilingNotification);


            for (var i = 0; i < 2; i++)
            {
                foreach (var temperature in GetTemperatures())
                {
                    Console.WriteLine($"new temp received {temperature}");
                    try
                    {
                        thermometer.UpdateTemperature(temperature);
                        Console.WriteLine($" -- >temp in Thermometer {thermometer.Temperature}");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine();
                        Console.WriteLine(ex.Message);
                    }

                    Thread.Sleep(1000);
                }
            }
        }
 public void ConstructorTestWithNullString()
 {
     var notification = new FreezingNotification(null, -50, -50, null);
 }
 public FreezingNotificationTests()
 {
     freezingNotification = new FreezingNotification(notificationName, 10.0m, 0.5m, () => notificationRaised = true);
 }