Exemplo n.º 1
0
        public void UndoAfterExecuteCommitTest()
        {
            //Arrange
            ICommand innerCommand = MockRepository.GenerateStrictMock <ICommand>();

            innerCommand.Expect(ic => ic.Execute()).
            Repeat.Once().
            Return(true);
            innerCommand.Expect(ic => ic.Commit()).
            Repeat.Once().
            Return(true);
            innerCommand.Expect(ic => ic.Undo()).
            Repeat.Never();

            SwitchCommand command = new SwitchCommand(innerCommand);

            //Act
            bool execteResult = command.Execute();
            bool commitResult = command.Commit();
            bool undoResult   = command.Undo();

            //Assert
            Assert.IsTrue(execteResult);
            Assert.IsTrue(commitResult);
            Assert.IsFalse(undoResult);

            innerCommand.VerifyAllExpectations();
        }
Exemplo n.º 2
0
        public void ExecuteTest()
        {
            //Arrange
            ICommand innerCommand = MockRepository.GenerateStrictMock <ICommand>();

            innerCommand.Expect(ic => ic.Execute()).
            Repeat.Once().
            Return(true);

            SwitchCommand command = new SwitchCommand(innerCommand);

            //Act
            bool executeResult = command.Execute();

            //Assert
            Assert.IsTrue(executeResult);

            innerCommand.VerifyAllExpectations();
        }
        public void InitializeServer()
        {
            server = new RestServer(8000, "RelayAutomation");

            server.GetContentRequestData = (method, data) =>
            {
                if (method == GetLamps)
                {
                    return(JsonConvert.SerializeObject(Lamps));
                }
                else if (method == SwitchLamp)
                {
                    SwitchCommand.Execute(null);
                    return(JsonConvert.SerializeObject(Lamps.First()));
                }

                return(String.Empty);
            };

            server.StartServer();
        }