コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: wilcorook/CommandPattern
        public void Should_TurnOffThermostat_When_AssignedButtonIsPressed()
        {
            //Arrange
            Thermostat thermostat = new Thermostat();
            Remote     remote     = new Remote();

            remote.SetButton(1, new TurnThermostatOff(thermostat));
            string expected = "Off";

            //Act
            remote.PressButton(1);

            //Assert
            Assert.AreEqual(expected, thermostat.ToString());
        }
コード例 #2
0
        public void testToString_shouldReturnNicelyFormattedString()
        {
            Thermostat t = new Thermostat();

            try
            {
                var json = LoadString(TEST_EMPTY_THERMOSTAT);
                Assert.AreEqual(json, t.ToString());
            }
            catch (IOException e)
            {
                Trace.WriteLine(e.StackTrace);
                Assert.Fail();
            }
        }
コード例 #3
0
        public void ToString_NormalUse_ReturnsExpectedString()
        {
            // Arrange
            var thermostat = new Thermostat
                                 {
                                     Name = "TestDevice",
                                     CurrentTemp = new Measurement<float?>(10, new DateTime(2013, 01, 01, 01, 02, 03))
                                 };
            const string expectedToString = "Thermostat TestDevice, CurrentTemp = 10 (2013-01-01 01:02:03)";

            // Act
            string actualToString = thermostat.ToString();

            // Assert
            Assert.AreEqual(expectedToString, actualToString);
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: wilcorook/CommandPattern
        public void Should_TurnDownThermostat_When_AssignedButtonIsPressed()
        {
            //Arrange
            Thermostat thermostat = new Thermostat();
            Remote     remote     = new Remote();

            remote.SetButton(1, new TurnThermostatOn(thermostat));
            remote.SetButton(1, new TurnThermostatUp(thermostat));
            remote.SetButton(1, new TurnThermostatUp(thermostat));
            remote.SetButton(1, new TurnThermostatDown(thermostat));
            string expected = "On, temperature is set to 1";

            //Act
            remote.PressButton(1);

            //Assert
            Assert.AreEqual(expected, thermostat.ToString());
        }