public void Before_Each_Test() { console = MockRepository.GenerateMock<IConsoleFacade>(); repository = MockRepository.GenerateMock<IRepository<GameObject>>(); player = MockRepository.GenerateMock<IPlayer>(); dbPlayer = new GameObject() { GameObjectId = 3, Location = dbHallway, Location_Id = 8, Description = "Just some dude." }; player.Stub(qq => qq.Id).Return(3); dbHallway = new GameObject() { Name = "Hallway", Description = " It's a hallway", GameObjectId = 8 }; dbBall = new GameObject() { Name = "Ball", Description = "A shiny rubber ball", Location = dbPlayer, Location_Id = 3 }; dbRing = new GameObject() { Name = "Ring", Description = "A simple gold ring", Location = dbHallway, Location_Id = 8 }; dbExit = new GameObject() {Name = "Exit", Description ="", Location= dbHallway, Location_Id = 8, GameObjectId = 16, Type = "Exit", Destination = 8 }; dbPlayer.Inventory.Add(dbBall); dbHallway.Inventory.Add(dbPlayer); dbHallway.Inventory.Add(dbRing); dbHallway.Inventory.Add(dbExit); dbList = new List<GameObject>() { dbPlayer, dbBall, dbRing, dbExit, dbHallway }; repository.Stub(qq => qq.AsQueryable()).Return(dbList.AsQueryable()); exit = new ExitAlias() { AliasId = 2, ExitId = 16, Alais = "North" }; exit2 = new ExitAlias() { AliasId = 2, ExitId = 16, Alais = "Hall" }; dbExit.ExitAliases.Add(exit); dbExit.ExitAliases.Add(exit2); aliasList = new List<ExitAlias> { exit, exit2 }; }
public void Execute_Should_Set_the_Description_of_Something() { // Arrange var ball = new GameObject() { Name = "Ball" }; var ring = new GameObject() { Name = "Ring" }; var list = new List<GameObject>() { ball, ring }; repository.Stub(qq => qq.AsQueryable()).Return(list.AsQueryable()); // Act cmd.Execute("describe Ball=A red rubber ball."); // Assert Assert.AreEqual("A red rubber ball.", ball.Description); //repository.AssertWasCalled(m => m.Dispose()); }
public void Execute_Should_Notify_if_Name_Not_Recognized() { // Arrange var ball = new GameObject() { Name = "Ball" }; var ring = new GameObject() { Name = "Ring" }; var list = new List<GameObject>() { ball, ring }; repository.Stub(qq => qq.AsQueryable()).Return(list.AsQueryable()); // Act cmd.Execute("describe stupid=foo"); // Assert console.AssertWasCalled(m => m.WriteLine("What is '{0}'?", "stupid")); }
public void Execute_Should_Set_the_Name_of_Ball_to_Orb() { // Arrange var ball = new GameObject() { Name = "Ball" }; var ring = new GameObject() { Name = "Ring" }; var list = new List<GameObject>() { ball, ring }; repository.Stub(qq => qq.AsQueryable()).Return(list.AsQueryable()); // Act cmd.Execute("rename Ball=Orb"); // Assert Assert.AreEqual("Orb", ball.Name); repository.AssertWasCalled(m => m.Dispose()); }
public void Execute_Should_List_Contents_Of_Inventory() { // Arrange var db_Player = new GameObject() { GameObjectId = 3 }; var ball = new GameObject() { Name = "Ball", Location = db_Player }; var ring = new GameObject() { Name = "Ring" }; db_Player.Inventory.Add(ball); var list = new List<GameObject>() { db_Player, ball, ring }; repository.Stub(qq => qq.AsQueryable()).Return(list.AsQueryable()); player.Stub(qq => qq.Id).Return(3); // Act cmd.Execute("inventory"); // Assert console.AssertWasCalled(m => m.Write("{0} ", "Ball")); console.AssertWasNotCalled(m => m.Write("{0} ", "Ring")); repository.AssertWasCalled(m => m.Dispose()); }
public IPlayer FindPlayer() { using (repository) { var Player = repository.AsQueryable() .FirstOrDefault(qq => qq.Type == "Player"); if (Player == null) { Player = new GameObject() { Name = "DefaultPlayer", Description = "This is the default player description.", Type = "Player", Location_Id = master.Id }; repository.Add(Player); repository.UnitOfWork.Save(); } return new Player() { Id = Player.GameObjectId }; } }
public void Format(GameObject obj) { if (obj.Inventory.Count > 0) { console.WriteLine(); console.WriteLine("Inventory:"); var count = 0; foreach (var item in obj.Inventory) { if (typeof(Exit).IsInstanceOfType(item) == false && typeof(Player).IsInstanceOfType(item) == false) { count++; console.Write("{0,-20}", item.Name); if ((count % 3) == 0) console.WriteLine(); } } var nonHiddenExits = obj.Inventory.OfType<Exit>().Where(m => m.Statuses.Any(x => x.Value == "Hidden") == false); if (nonHiddenExits.Count() > 0) { console.WriteLine(); console.WriteLine("Exits:"); count = 0; foreach (var item in nonHiddenExits) { count++; console.Write("{0,-20}", item.Name); if ((count % 3) == 0) console.WriteLine(); } } console.WriteLine(); } }
public void Format(GameObject obj) { console.WriteLine(obj.Name); console.WriteLine(obj.Description); }
public void Format(GameObject obj) { console.WriteLine("I don't see that here"); }
/// <summary> /// Create a new GameObject object. /// </summary> /// <param name="gameObjectId">Initial value of the GameObjectId property.</param> public static GameObject CreateGameObject(global::System.Int32 gameObjectId) { GameObject gameObject = new GameObject(); gameObject.GameObjectId = gameObjectId; return gameObject; }
/// <summary> /// Deprecated Method for adding a new object to the GameObjects EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToGameObjects(GameObject gameObject) { base.AddObject("GameObjects", gameObject); }
public void Output(GameObject obj) { console.WriteLine(obj.Description); }