public static IEnumerable <ITestCommand> Make(ITestClassCommand classCommand, IMethodInfo method) { foreach (var testCommand in classCommand.EnumerateTestCommands(method)) { ITestCommand wrappedCommand = testCommand; // Timeout (if they have one) -> Capture -> Timed -> Lifetime (if we need an instance) -> BeforeAfter wrappedCommand = new BeforeAfterCommand(wrappedCommand, method.MethodInfo); if (testCommand.ShouldCreateInstance) { wrappedCommand = new LifetimeCommand(wrappedCommand, method); } wrappedCommand = new TimedCommand(wrappedCommand); wrappedCommand = new ExceptionCaptureCommand(wrappedCommand, method); if (wrappedCommand.Timeout > 0) { wrappedCommand = new TimeoutCommand(wrappedCommand, wrappedCommand.Timeout, method); } yield return(wrappedCommand); } }
public static CutScene LoadCutScene(BinaryReader reader) { CutScene scene = new CutScene(); scene.name = reader.ReadString(); scene.length = reader.ReadInt32(); //read timed commands int tCommands = reader.ReadInt32(); for (int i = 0; i < tCommands; i++) { TimedCommand c = new TimedCommand(); c.time = reader.ReadInt32(); c.command = reader.ReadString(); } //read NPCs int npcCount = reader.ReadInt32(); for (int i = 0; i < npcCount; i++) { scene.NPCs.Add(LoadNPC(reader)); } //read player actions int pActions = reader.ReadInt32(); for (int i = 0; i < pActions; i++) { scene.playerActions.Add((Trainers.Action)reader.ReadByte()); } return(scene); }
public void MeasuresTime() { TimedCommand command = new TimedCommand(new DummyCommand()); MethodResult result = command.Execute(null); Assert.InRange(result.ExecutionTime, 0.01, 100.0); }
public static IEnumerable <ITestCommand> Make(ITestClassCommand classCommand, IMethodInfo method) { foreach (var testCommand in classCommand.EnumerateTestCommands(method)) { var wrappedCommand = testCommand; wrappedCommand = new BeforeAfterCommand(wrappedCommand, method.MethodInfo); if (testCommand.ShouldCreateInstance) { wrappedCommand = new LifetimeCommand(wrappedCommand, method); } wrappedCommand = new TimedCommand(wrappedCommand); wrappedCommand = new ExceptionInterceptingCommand(wrappedCommand, method); wrappedCommand = new ExceptionAndOutputCaptureCommand(wrappedCommand, method); // Note that we don't use a TimeoutCommand - we'll let the Silverlight framework handle that yield return(wrappedCommand); } }