Ejemplo n.º 1
0
        private void Setup()
        {
            _controller = new TestController();
            _controller.SetTime(TimeSpan.Parse("12:00"));

            var testRollerShutterFactory = new TestRollerShutterFactory(_controller.Timer);

            _weatherStation = new TestWeatherStation();
            _weatherStation.SetTemperature(20);
            _daylightService = new TestDaylightService();

            _rollerShutter = testRollerShutterFactory.CreateTestRollerShutter();
            _controller.ServiceLocator.RegisterService(typeof(TestWeatherStation), _weatherStation);
            _controller.AddComponent(_rollerShutter);

            _automation = new RollerShutterAutomation(
                AutomationIdFactory.EmptyId,
                _controller.ServiceLocator.GetService <ISchedulerService>(),
                _controller.ServiceLocator.GetService <IDateTimeService>(),
                _daylightService,
                _weatherStation,
                _controller);

            _automation.WithRollerShutters(_rollerShutter);
        }
Ejemplo n.º 2
0
        public void API_InvokeCommand()
        {
            var testController = new TestController();
            var socket         = new Lamp("Test", new TestLampAdapter());

            socket.ResetState();
            testController.AddComponent(socket);

            Assert.IsTrue(socket.GetState().Has(PowerState.Off));

            var parameter = new JObject
            {
                ["ComponentId"] = "Test",
                ["CommandType"] = "TurnOnCommand"
            };

            var apiContext = testController.InvokeApi("Service/IComponentRegistryService/ExecuteCommand", parameter);

            Assert.AreEqual(ApiResultCode.Success, apiContext.ResultCode);
            Assert.IsTrue(socket.GetState().Has(PowerState.On));
        }
        private void Setup()
        {
            _controller = new TestController();
            _controller.SetTime(TimeSpan.Parse("12:00"));

            var testRollerShutterFactory = new TestRollerShutterFactory(_controller.Timer);

            _weatherStation = new TestWeatherStation(new DeviceId("Test.WeatherStation"), _controller.Timer);
            _weatherStation.SetTemperature(20);
            _daylightService = new TestDaylightService();

            _rollerShutter = testRollerShutterFactory.CreateTestRollerShutter();
            _controller.RegisterService(_weatherStation);
            _controller.AddComponent(_rollerShutter);

            _automation = new RollerShutterAutomation(
                AutomationIdFactory.EmptyId,
                _controller.Timer,
                _daylightService,
                _weatherStation,
                _controller);

            _automation.WithRollerShutters(_rollerShutter);
        }