protected override IEnumerable <ITestCommand> EnumerateTestCommands(IMethodInfo method) { var commands = base.EnumerateTestCommands(method); var attrs = method.MethodInfo.GetCustomAttributes(typeof(DataAttribute), false); if (commands.Count() != attrs.Count()) { throw new InvalidOperationException("Some data attribute doesn't generate test command"); } var filteredCommands = new List <ITestCommand>(); int index = 0; foreach (var command in commands) { var theoryCmd = command as TheoryCommand; var skippableData = attrs.ElementAt(index++) as ISkippable; if (skippableData != null && !string.IsNullOrEmpty(skippableData.SkipReason)) { SkipCommand cmd = new SkipCommand(method, theoryCmd.DisplayName, skippableData.SkipReason); filteredCommands.Add(cmd); } else { filteredCommands.Add(command); } } return(filteredCommands); }
public void ThrowArgumentNullException_WhenNullStringArgumentsPassed() { var skip = new SkipCommand(); var bmanager = new Mock <IBattleManager>(); Assert.Throws <ArgumentNullException>(() => skip.ProcessCommand(bmanager.Object, null)); }
public void ThrowArgumentException_WhenLessStringArgumentsArePassed() { var skip = new SkipCommand(); var bmanager = new Mock <IBattleManager>(); Assert.Throws <ArgumentException>( () => skip.ProcessCommand(bmanager.Object, new string[] { })); }
public void SkipReturnSkipResult() { MethodInfo method = typeof(SpyStub).GetMethod("Skip"); SkipCommand command = new SkipCommand(Reflector.Wrap(method), null, "reason"); MethodResult result = command.Execute(new SpyStub()); SkipResult skipResult = Assert.IsType<SkipResult>(result); Assert.Equal("reason", skipResult.Reason); }
public void SkipReturnSkipResult() { MethodInfo method = typeof(SpyStub).GetMethod("Skip"); SkipCommand command = new SkipCommand(Reflector.Wrap(method), null, "reason"); MethodResult result = command.Execute(new SpyStub()); SkipResult skipResult = Assert.IsType <SkipResult>(result); Assert.Equal("reason", skipResult.Reason); }
public void CallSkipMethod_WhenValidDataIsPassed() { var skip = new SkipCommand(); var bmanager = new Mock <IBattleManager>(); bmanager.Setup(x => x.Skip(It.IsAny <CreatureIdentifier>())); skip.ProcessCommand(bmanager.Object, new string[] { "Archangel(2)" }); bmanager.Verify(x => x.Skip(It.IsAny <CreatureIdentifier>()), Times.Once); }
public void SettingSkipReasonGeneratesSkipCommand() { MethodInfo method = typeof(ClassWithSkippedTest).GetMethod("SkippedTest"); TestClassCommand classCommand = new TestClassCommand(typeof(ClassWithSkippedTest)); var commands = new List <ITestCommand>(classCommand.EnumerateTestCommands(Reflector.Wrap(method))); ITestCommand command = Assert.Single(commands); SkipCommand skipCommand = Assert.IsType <SkipCommand>(command); Assert.Equal("My Skip Reason", skipCommand.Reason); }
public void ParseArgumentsSetsRowsToSkip() { SkipCommand cmd = new SkipCommand(); cmd.ArgumentsString = @"15"; Document doc = new Document(); var slide = new SlideElement(doc); ShapeElementBase element = (ShapeElementBase)(ShapeElementBaseTest.Create()); cmd.TargetElement = element; cmd.ParseArguments(); Assert.AreEqual(15, cmd.RowsToSkip); }
public void SkipCommandTest() { StartGameCommandTest(); int robotBattery = _context.Robot.BatteryBalance; int mass = _context.Robot.Mass; ICommand skipCommand = new SkipCommand(_context); skipCommand.Execute(); Assert.IsFalse(robotBattery == _context.Robot.BatteryBalance); Assert.IsTrue(mass == _context.Robot.Mass); Assert.IsTrue(_context.State is DecidingState); }
public void ApplyToDataRemovesRowsFromTheData() { SkipCommand cmd = new SkipCommand() { RowsToSkip = 1 }; DataElement da = Helpers.CreateTestDataElement(); cmd.ApplyToData(da); Assert.AreEqual(1, da.Rows.Count); Assert.AreEqual(1, da.Columns[0].Data.Count); Assert.AreEqual(1, da.Columns[1].Data.Count); Assert.AreEqual(1, da.Columns[2].Data.Count); Assert.AreEqual(5.05, da.Columns[0].Data[0]); Assert.AreEqual("client 2", da.Columns[1].Data[0]); Assert.AreEqual(true, da.Columns[2].Data[0]); Assert.AreEqual(da.Columns[0].Data[0], da.Rows[0].Data[0]); Assert.AreEqual(da.Columns[1].Data[0], da.Rows[0].Data[1]); Assert.AreEqual(da.Columns[2].Data[0], da.Rows[0].Data[2]); }
public IExecutable ManageCommand(string[] inputArgs) { IExecutable command = null; switch (inputArgs[0]) { case "build": command = new BuildCommand(inputArgs[1], this.Engine); break; case "skip": command = new SkipCommand(); break; case "empire-status": command = new StatusCommand(this.Engine); break; case "armistice": command = new EndCommand(); break; } return command; }
private void AssignProperties(XmppState state) { SetConnectionStateAndText(state); ContinueCommand.ChangeCanExecute(); SkipCommand.ChangeCanExecute(); }
public Void VisitSkipCommand(SkipCommand ast, Frame frame) { // ... ? return(null); }
public Void VisitSkipCommand(SkipCommand ast, Void arg) { return(null); }
public Void VisitSkipCommand(SkipCommand ast, Void arg) { System.Console.WriteLine("Visiting SkipCommand"); return(null); }
protected internal override void VisitSkipCommand(SkipCommand skipCommand) { this.WriteIndent(); this.writer.WriteLine("#"); }
public void ThrowArgumentNullException_WhenNullBattleManagerIsPassed() { var skip = new SkipCommand(); Assert.Throws <ArgumentNullException>(() => skip.ProcessCommand(null, new string[] { })); }
private void StopSkipParse() { if (Tokens.Count < 2) { return; } bool isSuccess = false; Token t1 = Tokens.Pop(); Token t2 = Tokens.Pop(); switch (t2.Type) { case TokenType.Semicolon when t1.Type == TokenType.Stop: { Command cmd = new StopCommand(); Program.Add(cmd); isSuccess = true; break; } case TokenType.Literal when t1.Type == TokenType.Stop: { if (Tokens.Peek().Type != TokenType.Semicolon) { Error("No semicolon in operation", t2); } else { Tokens.Pop(); int value = Convert.ToInt32(t2.Value); Command cmd = new StopCommand(value); Program.Add(cmd); isSuccess = true; } break; } case TokenType.Semicolon when t1.Type == TokenType.Nop: { Command cmd = new SkipCommand(); Program.Add(cmd); isSuccess = true; break; } case TokenType.Literal when t1.Type == TokenType.Nop: { if (Tokens.Peek().Type != TokenType.Semicolon) { Error("No semicolon in operation", t2); } else { Tokens.Pop(); int value = Convert.ToInt32(t2.Value); Command cmd = new SkipCommand(value); Program.Add(cmd); isSuccess = true; } break; } } if (isSuccess) { return; } Tokens.Push(t2); Tokens.Push(t1); }
public Task SkipFromMediaWebSocket(int seconds) { return(SkipCommand.ExecuteAsync(seconds)); }