public void TestFindAllReportsByManufacturer_MultipleReports_ShouldReturnProperReports()
        {
            const string Manufacturer = "Toshiba";
            const string Model = "Z550";
            const string Model2 = "Z6000";
            const string Rating = "A";
            const int PowerUsage = 20;
            var commandExecutor = new CommandExecutor();

            commandExecutor.RegisterStationaryAirConditioner(Manufacturer, Model, Rating, PowerUsage);
            commandExecutor.RegisterStationaryAirConditioner(Manufacturer, Model2, Rating, PowerUsage);
            commandExecutor.TestAirConditioner(Manufacturer, Model);
            commandExecutor.TestAirConditioner(Manufacturer, Model2);
            var reports = commandExecutor.FindAllReportsByManufacturer("Toshiba");
            var mark = commandExecutor.Database.AirConditioners.First().HasPassedTest ? "Passed" : "Failed";
            var expectedReport = new StringBuilder();
            expectedReport.AppendFormat("Reports from {0}:", Manufacturer)
                .AppendLine()
                .AppendLine("Report")
                .AppendLine(Constants.ReportDelimiter)
                .AppendLine("Manufacturer: " + Manufacturer)
                .AppendLine("Model: " + Model)
                .AppendLine("Mark: " + mark)
                .AppendLine(Constants.ReportDelimiter)
                .AppendLine("Report")
                .AppendLine(Constants.ReportDelimiter)
                .AppendLine("Manufacturer: " + Manufacturer)
                .AppendLine("Model: " + Model2)
                .AppendLine("Mark: " + mark)
                .Append(Constants.ReportDelimiter);

            Assert.AreEqual(expectedReport.ToString(), reports, "Reports are not equal.");
        }
 public void TestStationaryAirConditioner_NegativePowerUsage_ShouldThrow()
 {
     const string Manufacturer = "Toshiba";
     const string Model = "Z550";
     const string Rating = "Z";
     const int PowerUsage = -1;
     var commandExecutor = new CommandExecutor();
     commandExecutor.RegisterStationaryAirConditioner(Manufacturer, Model, Rating, PowerUsage);
 }
 public void TestStationaryAirConditioner_InvalidModelName_ShouldThrow()
 {
     const string Manufacturer = "Toshiba";
     string incorrectModel = new string('A', Constants.ModelMinLength - 1);
     const string Rating = "A";
     const int PowerUsage = 20;
     var commandExecutor = new CommandExecutor();
     commandExecutor.RegisterStationaryAirConditioner(Manufacturer, incorrectModel, Rating, PowerUsage);
 }
 public void TestStationaryAirConditioner_IncorrectEfficiencyRating_ShouldThrow()
 {
     const string Manufacturer = "Toshiba";
     const string Model = "Z550";
     const string IncorrectRating = "Z";
     const int PowerUsage = 20;
     var commandExecutor = new CommandExecutor();
     commandExecutor.RegisterStationaryAirConditioner(Manufacturer, Model, IncorrectRating, PowerUsage);
 }
示例#5
0
        public void TestStatus_NoAirConditioners_TestedAirConditionersPercentageShouldBeZero()
        {
            var commandExecutor = new CommandExecutor();

            var message = commandExecutor.Status();
            var expectedMessage = "Jobs complete: 0.00%";

            Assert.AreEqual(expectedMessage, message, "Status should be zero percent.");
        }
示例#6
0
        public void TestStatus_OneAirConditionerNoReports_TestedAirConditionersPercentageShouldBeZero()
        {
            var commandExecutor = new CommandExecutor();

            commandExecutor.RegisterCarAirConditioner("Toshiba", "B50", 9);
            var message = commandExecutor.Status();
            var expectedMessage = "Jobs complete: 0.00%";

            Assert.AreEqual(expectedMessage, message, "Status should be zero percent.");
        }
示例#7
0
        public void TestStatus_OneUntestedOfThreeAirConditioners_OutputShouldBeRoundedTwoDecimalPlaces()
        {
            var commandExecutor = new CommandExecutor();

            commandExecutor.RegisterCarAirConditioner("Toshiba", "B50", 9);
            commandExecutor.RegisterCarAirConditioner("Toshiba2", "B50", 9);
            commandExecutor.RegisterCarAirConditioner("Toshiba3", "B50", 9);
            commandExecutor.TestAirConditioner("Toshiba", "B50");
            commandExecutor.TestAirConditioner("Toshiba2", "B50");
            var message = commandExecutor.Status();
            var expectedMessage = "Jobs complete: 66.67%";

            Assert.AreEqual(expectedMessage, message, "Status should be zero percent.");
        }
        // [TestMethod]
        public void TestTestAirController_ValidData_ShouldReturnSuccessMessage()
        {
            var carAirConditioner = new CarAirConditioner("Toshiba", "Z99", 9);
            var mockedData = new Mock<AirConditionerTesterSystemData>();
            mockedData.Setup(data => data.GetAirConditioner(null, null))
                .Returns(carAirConditioner);

            var commandExecutor = new CommandExecutor(mockedData.Object);
            var message = commandExecutor.TestAirConditioner(null, null);
            var expectedMessage = "Air Conditioner model Z99 from Toshiba tested successfully.";

            // throw new OutOfTimeException
            Assert.AreEqual(expectedMessage, message);
        }
        public void TestStationaryAirConditioner_SingleAirConditioner_ManufacturersShouldBeEqual()
        {
            const string Manufacturer = "Toshiba";
            const string Model = "Z550";
            const string Rating = "A";
            const int PowerUsage = 20;
            var commandExecutor = new CommandExecutor();

            commandExecutor.RegisterStationaryAirConditioner(Manufacturer, Model, Rating, PowerUsage);

            Assert.AreEqual(
                Manufacturer,
                commandExecutor.Database.AirConditioners.First().Manufacturer,
                "Manufacturers differ.");
        }
        public void TestStationaryAirConditioner_SingleAirConditioner_ShouldReturnSuccessMessage()
        {
            const string Manufacturer = "Toshiba";
            const string Model = "Z550";
            const string Rating = "A";
            const int PowerUsage = 20;
            var commandExecutor = new CommandExecutor();
            var expectedMessage = string.Format(Constants.Register, Model, Manufacturer);

            var message = commandExecutor.RegisterStationaryAirConditioner(Manufacturer, Model, Rating, PowerUsage);

            Assert.AreEqual(expectedMessage, message, "Messages differ.");
        }
        public void TestStationaryAirConditioner_SingleAirConditioner_RatingsShouldBeEqual()
        {
            const string Manufacturer = "Toshiba";
            const string Model = "Z550";
            const string Rating = "A";
            const int PowerUsage = 20;
            var commandExecutor = new CommandExecutor();

            commandExecutor.RegisterStationaryAirConditioner(Manufacturer, Model, Rating, PowerUsage);
            var expectedRaiting = (int)Enum.Parse(typeof(EnergyEfficiencyRating), Rating);

            Assert.AreEqual(
                expectedRaiting,
                (commandExecutor.Database.AirConditioners.First() as StationaryAirConditioner).EnergyRating,
                "Ratings differ.");
        }
示例#12
0
 public Engine(ConsoleUserInterface userInterface)
 {
     this.ac = new CommandExecutor();
     this.userInterface = userInterface;
 }
        public void TestFindAllReportsByManufacturer_NoReports_ShouldReturnNoReportsMessage()
        {
            var commandExecutor = new CommandExecutor();

            var message = commandExecutor.FindAllReportsByManufacturer("Toshiba");

            Assert.AreEqual("No reports.", message);
        }