public void ReadCommand_text_input_should_return_MoveCommand() { CommandReader SUT = new CommandReader(_mockView.Object); _mockView.Setup(x => x.ReadLine()).Returns("N 333"); MoveCommand result = SUT.ReadCommand(); Assert.AreEqual(Direction.N, result.Direction); Assert.AreEqual(333, result.Steps); }
public void TestDirectionEtapsOk() { CommandReader test = new CommandReader(_mockView.Object, _mockRobotCleanerServices.Object); _mockView.Setup(x => x.ReadLine()).Returns("E 2"); MoveCommand result = test.ReadCommand(); Assert.AreEqual(Direction.E, result.Direction); Assert.AreEqual(2, result.Steps); }
public void ReadCommandTest() { string[] args = { "read test" }; CommandReader target = new CommandReader(args); string ResultLine = string.Empty; string ResultLineExpected = string.Empty; string CommandLine = string.Empty; string CommandLineExpected = "read test"; bool expected = true; bool actual; actual = target.ReadCommand(ref ResultLine, out CommandLine); Assert.AreEqual(ResultLineExpected, ResultLine); Assert.AreEqual(CommandLineExpected, CommandLine); Assert.AreEqual(expected, actual); }
public static void StartProgram() { do { try { Command oCommandReceived = CommandReader.ReadCommand(); if (oCommandReceived.CommandIdentifier == 'Q') { break; } DrawCommandProcessor.Execute(oCommandReceived); } catch (Exception ex) { Console.SetCursorPosition(0, 0); Console.Write(new string(' ', Console.WindowWidth)); Console.SetCursorPosition(0, 0); Console.WriteLine("Error: " + ex.Message + ". Press enter to continue"); Console.ReadKey(true); } } while (true); }
private void CommandReceived(CommandReader cr) { Commands cmd = cr.ReadCommand(); if (cmd == Commands.UpdateEntity) { int entityID = cr.ReadData <int>(); EntityType entityType = (EntityType)cr.ReadData <byte>(); Matrix world = cr.ReadMatrix(); Vector3 scale = cr.ReadVector3(); PhysicsShape physicsShape = (PhysicsShape)cr.ReadData <byte>(); float radius = cr.ReadData <float>(); float angularDamping = cr.ReadData <float>(); float linearDamping = cr.ReadData <float>(); Vector3 angularVelocity = cr.ReadVector3(); Vector3 linearVelocity = cr.ReadVector3(); GameEntity entity = gameManager.GetEntity(entityID); if (entity == null) { lock (gameManager) { if (entityType == EntityType.PlanetEarth) { entity = new PlanetEntity(this, entityType, new Sphere(MathConverter.Convert(world.Translation), radius)); } else { entity = new GameEntity(this, entityType, new Sphere(MathConverter.Convert(world.Translation), radius)); } entity.ID = entityID; gameManager.RegisterEntity(entity); } } else { entity.SetScale(scale.X, scale.Y, scale.Z); entity.PhysicsEntity.AngularDamping = angularDamping; entity.PhysicsEntity.LinearDamping = linearDamping; entity.PhysicsEntity.AngularVelocity = MathConverter.Convert(angularVelocity); entity.PhysicsEntity.LinearVelocity = MathConverter.Convert(linearVelocity); entity.PhysicsEntity.WorldTransform = MathConverter.Convert(world); //BEPUutilities.Matrix. //entity.World = world; //entity.PhysicsEntity.WorldTransform = new BEPUutilities.Matrix(world.M11, world.M12, world.M13, world.M14, world.M21, world.M22, world.M23, world.M24, world.M31, world.M32, world.M33, world.M34, world.M41, world.M42, world.M43, world.M44); } if (entityType == EntityType.Player) { cameraTarget = entity; } /* * ServerEntity entity = ServerEntities.ContainsKey(entityID) ? ServerEntities[entityID] : null; * if (entity == null) * { * entity = new ServerEntity() { ID = entityID, EntityType = entityType, World = world, Model = GetModel(entityType) }; * if (entity.Model != null) entity.BoneTransforms = new Matrix[entity.Model.Bones.Count]; * ServerEntities.Add(entityID, entity); * ServerEntityIDs.Add(entityID); * if (entityType == EntityType.Player) CameraTarget = entity; * } * else entity.World = world; */ } }