internal string InsertPausePlaybackCommand() { if (CurrentState != State.Recording) { const string message = "Method should be called only when recording"; throw new InvalidOperationException(message); } var pausePlaybackCommand = new DynamoModel.PausePlaybackCommand(20); RecordCommand(pausePlaybackCommand); return pausePlaybackCommand.Tag; }
public void TestRecordableCommand() { //Arrange //The tag passed as parameter is null, then it will raise an exception later var cmd = new Mock <DynamoModel.RecordableCommand>(null); var pausePlaybackCommand = new DynamoModel.PausePlaybackCommand(20); //Act var xmlElements = pausePlaybackCommand.Serialize(); //Assert Assert.IsNotNull(JToken.Parse(xmlElements));//Verify that the json serialized is valid //This will execute the exception section in RecordableCommand(string tag), because tag is null Assert.Throws <System.Reflection.TargetInvocationException>(() => executive.ExecuteCommand(cmd.Object, "TestRecordable", "ExtensionTests")); Assert.AreEqual(-1, cmdExecutionState);//It means that the command was not executed successfully }