Ejemplo n.º 1
0
        public void StartTest(bool isEnabled, bool isServiceable)
        {
            var task = new TcoMomentaryTask();

            task._enabled.Synchron       = isEnabled;
            task._isServiceable.Synchron = isServiceable;
            task._setOnRequest.Synchron  = false;
            _logger.ClearLastMessage();
            var expected = isEnabled && isServiceable;

            task.Start();

            Assert.AreEqual(expected, task._setOnRequest.Synchron);

            if (expected)
            {
                Assert.AreEqual("Task '' started. {@sender}", _logger.LastMessage.message);
                Assert.IsInstanceOf <LogInfo>(_logger.LastMessage.payload);
                Assert.AreEqual("Information", _logger.LastMessage.serverity);
            }
            else
            {
                Assert.IsTrue(_logger.IsLastMessageEmpty());
            }
        }
Ejemplo n.º 2
0
        public void RecordTaskAction_get_set_test()
        {
            var task = new TcoMomentaryTask();

            Assert.IsNull(task.RecordTaskAction);
            task.RecordTaskAction = (a, b) => Console.WriteLine();
            Assert.IsNotNull(task.RecordTaskAction);
        }
Ejemplo n.º 3
0
        public void LogPayloadPropertyTest()
        {
            var task = new TcoMomentaryTask();

            task.LogPayloadDecoration = () => "hey I am payload".ToUpper();

            var actual = task.LogPayloadDecoration();

            Assert.AreEqual("hey I am payload".ToUpper(), actual);
        }
Ejemplo n.º 4
0
        public void CanExecuteTest_enabled_serviceable(bool isEnabled, bool isServiceable)
        {
            var task = new TcoMomentaryTask();

            task._enabled.Synchron       = isEnabled;
            task._isServiceable.Synchron = isServiceable;
            var expected = isEnabled && isServiceable;

            var actual = task.CanExecute(new object());

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        public void ExecuteTest(bool isEnabled, bool isServiceable)
        {
            var task = new TcoMomentaryTask();

            task._enabled.Synchron       = isEnabled;
            task._isServiceable.Synchron = isServiceable;
            task._setOnRequest.Synchron  = false;
            _logger.ClearLastMessage();
            var expected = isEnabled && isServiceable;

            task.Execute(new object());

            Assert.AreEqual(false, task._setOnRequest.Synchron);
            Assert.IsTrue(_logger.IsLastMessageEmpty());
        }
Ejemplo n.º 6
0
        public void button_up_task_enabled_execute()
        {
            var task = new TcoMomentaryTask(new MockRootObject(), string.Empty, string.Empty);

            task._isServiceable.Synchron = true;
            task._enabled.Synchron       = true;
            var vm = new TcoMomentaryTaskViewModel()
            {
                Model = task
            };

            vm.ButtonUp.Execute(null);

            Assert.IsFalse(vm.TcoMomentaryTask._setOnRequest.Synchron);
        }
Ejemplo n.º 7
0
        public void TcoMomentaryTaskViewModelTest()
        {
            var task = new TcoMomentaryTask(new MockRootObject(), string.Empty, string.Empty);
            var vm   = new TcoMomentaryTaskViewModel()
            {
                Model = task
            };

            Assert.IsNotNull(vm);
            Assert.IsNotNull(vm.TcoMomentaryTask);
            Assert.IsNotNull(vm.Model);

            Assert.IsInstanceOf <TcoMomentaryTask>(vm.TcoMomentaryTask);
            Assert.IsInstanceOf <TcoMomentaryTask>(vm.Model);
        }
Ejemplo n.º 8
0
        public void get_caption()
        {
            var task = new TcoMomentaryTask(new MockRootObject(), string.Empty, string.Empty);

            task.GetConnector().BuildAndStart();

            task._isServiceable.Synchron = true;
            task._enabled.Synchron       = true;
            task.AttributeName           = "momentary task button";
            task.AttributeStateOffDesc   = "is off";
            task.AttributeStateOnDesc    = "is on";
            var vm = new TcoMomentaryTaskViewModel()
            {
                Model = task
            };

            Assert.AreEqual("momentary task button : is off", vm.Caption);

            task._state.Synchron = true;

            vm.UpdateCaption();

            Assert.AreEqual("momentary task button : is on", vm.Caption);
        }
Ejemplo n.º 9
0
        public void PexCtor()
        {
            var task = new TcoMomentaryTask(new MockRootObject(), string.Empty, string.Empty);

            Assert.IsNotNull(task);
        }
Ejemplo n.º 10
0
        public void CodeProvider_get_default_when_null()
        {
            var task = new TcoMomentaryTask();

            Assert.IsInstanceOf <TcoCore.Swift.TcoMomentaryTaskDefaultCodeProvider>(task.CodeProvider);
        }