Beispiel #1
0
        public void WhenHumidityInLimitThenNoAlert()
        {
            var r = new EnvironmentMonitor(new StringReader("Temperature,Humidity,Date,Time\n10C,50%,15-09-2020,1:10pm\n"));

            AlertWrapper.WhenSetAlerterMock();
            r.WhenGetPropertyNamesThenSetPropertyNames();
            r.WhenGetReadingsFromSensorThenAnalyze();
            Assert.True(AlertWrapper.AlertStaticObj.FinalStringPrintedOnConsole.Equals(""));
        }
Beispiel #2
0
        public void WhenHumidityReachedErrorLevelThenAlert()
        {
            var r = new EnvironmentMonitor(new StringReader("Temperature,Humidity,Date,Time\n10C,91%,15-09-2020,1:10pm\n"));

            AlertWrapper.WhenSetAlerterMock();
            r.WhenGetPropertyNamesThenSetPropertyNames();
            r.WhenGetReadingsFromSensorThenAnalyze();
            Assert.Contains("Humidity reached Error level:91%", AlertWrapper.AlertStaticObj.FinalStringPrintedOnConsole);
        }
Beispiel #3
0
        public void WhenTempInLowWarningLimitThenAlert()
        {
            var r = new EnvironmentMonitor(new StringReader("Temperature,Humidity,Date,Time\n2C,70%,15-09-2020,1:10pm\n"));

            AlertWrapper.WhenSetAlerterMock();
            r.WhenGetPropertyNamesThenSetPropertyNames();
            r.WhenGetReadingsFromSensorThenAnalyze();
            Assert.Contains("Temperature reached Low Warning level:2C", AlertWrapper.AlertStaticObj.FinalStringPrintedOnConsole);
        }
Beispiel #4
0
        public void WhenPropertiesArePassedOnly()
        {
            var r = new EnvironmentMonitor(new StringReader("Temperature,Humidity,Date,Time\n"));

            r.WhenGetPropertyNamesThenSetPropertyNames();
            Assert.True(r.AnalyzerObj.PropertiesList[0].PropertyName.Equals("Temperature"));
            Assert.True(r.AnalyzerObj.PropertiesList[1].PropertyName.Equals("Humidity"));
            Assert.True(r.AnalyzerObj.PropertiesList[2].PropertyName.Equals("Date"));
            Assert.True(r.AnalyzerObj.PropertiesList[3].PropertyName.Equals("Time"));
        }
Beispiel #5
0
        public void WhenHumidityValueIsNotProvidedBySenderThenPromptUser()
        {
            var r = new EnvironmentMonitor(new StringReader("Temperature,Humidity,Date,Time\n"));

            AlertWrapper.WhenSetAlerterMock();
            r.WhenGetPropertyNamesThenSetPropertyNames();
            var values = r.WhenToSplitLine("41C,NA,12-9-2019,11:10am");

            r.AnalyzerObj.WhenAnalyzeHumidity(values);
            Assert.True(AlertWrapper.AlertStaticObj.FinalStringPrintedOnConsole.Equals("Humidity value not provided by sender.Possibility of error in humidity sensor."));
        }
Beispiel #6
0
        public void WhenTimePropertyNotProvidedBySenderThenPromptUser()
        {
            var r = new EnvironmentMonitor(new StringReader("Temperature,Humidity,Date\n"));

            AlertWrapper.WhenSetAlerterMock();
            r.WhenGetPropertyNamesThenSetPropertyNames();
            var values = r.WhenToSplitLine("50C,50%,15-09-2020");

            r.AnalyzerObj.WhenAnalyzeTemperature(values);
            Assert.True(AlertWrapper.AlertStaticObj.FinalStringPrintedOnConsole.Equals("CSV does not contain Time property."));
        }
Beispiel #7
0
        public void WhenTemperatureInLimitThenNoAlert()
        {
            var r = new EnvironmentMonitor(new StringReader("Temperature,Humidity,Date,Time\n"));

            AlertWrapper.WhenSetAlerterMock();
            r.WhenGetPropertyNamesThenSetPropertyNames();
            var values = r.WhenToSplitLine("20C,60%,15-09-2020,1:10pm");

            r.AnalyzerObj.WhenAnalyzeTemperature(values);
            Assert.True(AlertWrapper.AlertStaticObj.FinalStringPrintedOnConsole.Equals(""));
        }
Beispiel #8
0
        public void WhenInputIsCorrect()
        {
            var r = new EnvironmentMonitor(
                new StringReader(
                    "Temperature,Humidity,Date,Time\n37C,50%,15-09-2020,11:10am\n32C,20%,15-09-2020,12:10pm\n\n"));

            AlertWrapper.WhenSetAlerterMock();
            r.WhenGetPropertyNamesThenSetPropertyNames();
            var b = r.WhenGetReadingsFromSensorThenAnalyze();

            Assert.True(b);
            Assert.True(AlertWrapper.AlertStaticObj.FinalStringPrintedOnConsole.Equals(""));
        }
Beispiel #9
0
        public void WhenCompleteCodeCoverage()
        {
            Alert alerter = new Alert();

            alerter.PrintOnConsole(null);
            alerter.PrintOnConsole("Environment Monitoring");
            Alert alerter2 = new Alert();

            alerter2.PrintOnConsole("Environment Monitoring");
            EnvironmentMonitor r = new EnvironmentMonitor();

            r.WhenToSplitLine("");
            AlertWrapper.WhenSetAlerterMock();
        }