コード例 #1
0
        public void MultipleForcastAlerts()
        {
            List <string> expected = new List <string> {
                "Snow Alert for Saturday, March 10",
                "Ice Alert for Saturday, March 10"
            };

            DateTime date   = new DateTime(2018, 3, 10);
            var      result = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "ice and snow"));
        }
コード例 #2
0
        public void ForcastAndTemp_GeneratesTwoAlerts()
        {
            List <string> expected = new List <string> {
                "Freezing Temperature Alert for Saturday, March 10",
                "Ice Alert for Saturday, March 10"
            };

            DateTime date   = new DateTime(2018, 3, 10);
            var      result = AlertGenerator.generateAlerts(new Forcast(date, -40, 70, "ice"));
        }
コード例 #3
0
        public void NoAlerts_ReturnsEmptyList()
        {
            List <string> expected = new List <string>();

            DateTime date = new DateTime(2018, 3, 10);

            var result = AlertGenerator.generateAlerts(new Forcast(date, 40, 50, "Nothing"));

            CollectionAssert.AreEqual(expected, result);
        }
コード例 #4
0
        public void HighTempAt85_GeneratesHighHeatAlert()
        {
            List <string> expected = new List <string> {
                "High Heat Alert for Saturday, March 10"
            };

            DateTime date = new DateTime(2018, 3, 10);

            var result = AlertGenerator.generateAlerts(new Forcast(date, 50, 85, "Nothing"));

            CollectionAssert.AreEqual(expected, result);
        }
コード例 #5
0
        public void LowTempAt32_GeneratesFreezingTempAlert()
        {
            List <string> expected = new List <string> {
                "Freezing Temperature Alert for Saturday, March 10"
            };

            DateTime date = new DateTime(2018, 3, 10);

            var result = AlertGenerator.generateAlerts(new Forcast(date, 32, 50, "Nothing"));

            CollectionAssert.AreEqual(expected, result);
        }
コード例 #6
0
        public void LowTempBelow32_And_HighTempAbove85_GeneratesTwoAlerts()
        {
            List <string> expected = new List <string> {
                "Freezing Temperature Alert for Saturday, March 10",
                "High Heat Alert for Saturday, March 10"
            };

            DateTime date = new DateTime(2018, 3, 10);

            var result = AlertGenerator.generateAlerts(new Forcast(date, 30, 90, "Nothing"));

            CollectionAssert.AreEqual(expected, result);
        }
コード例 #7
0
        public void LowTempLessThan32_GeneratesFreezingTempAlert()
        {
            List <string> expected = new List <string> {
                "Freezing Temperature Alert for Saturday, March 10"
            };

            DateTime date = new DateTime(2018, 3, 10);

            var result1 = AlertGenerator.generateAlerts(new Forcast(date, 0, 50, "Nothing"));

            CollectionAssert.AreEqual(expected, result1);

            var result2 = AlertGenerator.generateAlerts(new Forcast(date, 20, 70, "Nothing"));

            CollectionAssert.AreEqual(expected, result2);

            var result3 = AlertGenerator.generateAlerts(new Forcast(date, -60, -40, "Nothing"));

            CollectionAssert.AreEqual(expected, result2);
        }
コード例 #8
0
        public void ForcastContainsIce_GeneratesIceAlert()
        {
            List <string> expected = new List <string> {
                "Ice Alert for Saturday, March 10"
            };

            DateTime date = new DateTime(2018, 3, 10);

            var result1 = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "Ice"));

            CollectionAssert.AreEqual(expected, result1);

            var result2 = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "black ice"));

            CollectionAssert.AreEqual(expected, result2);

            var result3 = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "some more ice"));

            CollectionAssert.AreEqual(expected, result2);
        }
コード例 #9
0
        public void ForcastContainsSnow_GeneratesSnowAlert()
        {
            List <string> expected = new List <string> {
                "Snow Alert for Saturday, March 10"
            };

            DateTime date = new DateTime(2018, 3, 10);

            var result1 = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "Snow"));

            CollectionAssert.AreEqual(expected, result1);

            var result2 = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "light snow"));

            CollectionAssert.AreEqual(expected, result2);

            var result3 = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "Scattered Snow"));

            CollectionAssert.AreEqual(expected, result2);
        }
コード例 #10
0
        public void ForcastContainsThunderstorm_GeneratesThunderstormAlert()
        {
            List <string> expected = new List <string> {
                "Thunderstorm Alert for Saturday, March 10"
            };

            DateTime date = new DateTime(2018, 3, 10);

            var result1 = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "Thunderstorms"));

            CollectionAssert.AreEqual(expected, result1);

            var result2 = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "Scattered Thunderstorms"));

            CollectionAssert.AreEqual(expected, result2);

            var result3 = AlertGenerator.generateAlerts(new Forcast(date, 50, 70, "Heavy Thunderstorm"));

            CollectionAssert.AreEqual(expected, result2);
        }
コード例 #11
0
        public void LowTemp_AboveHighTemp_ThrowsException()
        {
            DateTime date = new DateTime(2018, 3, 10);

            var result = AlertGenerator.generateAlerts(new Forcast(date, 70, 60, "Nothing"));
        }