public void ReceivePacket_EventCanceled() { // Clear out the password so we know it's empty. Terraria.Netplay.Clients[5] = new Terraria.RemoteClient { Id = 5 }; Terraria.Netplay.ServerPassword = string.Empty; var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player { whoAmI = 5 }; var player = new OrionPlayer(5, terrariaPlayer, events, log); Mock.Get(events) .Setup(em => em.Raise(It.IsAny <PacketReceiveEvent <ClientConnect> >(), log)) .Callback <PacketReceiveEvent <ClientConnect>, ILogger>((evt, log) => evt.Cancel()); var packet = new ClientConnect { Version = "Terraria" + Terraria.Main.curRelease }; player.ReceivePacket(packet); Assert.Equal(0, Terraria.Netplay.Clients[5].State); Mock.Get(events).VerifyAll(); }
public void SendPacket_NotConnected() { Terraria.Netplay.Clients[5] = new Terraria.RemoteClient { Id = 5, Socket = Mock.Of <Terraria.Net.Sockets.ISocket>(s => !s.IsConnected()) }; var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player { whoAmI = 5 }; var player = new OrionPlayer(5, terrariaPlayer, events, log); Mock.Get(events) .Setup(em => em.Raise(It.IsAny <PacketSendEvent <TestPacket> >(), log)); player.SendPacket(new TestPacket { Value = 100 }); Mock.Get(events) .Verify(em => em.Raise(It.IsAny <PacketSendEvent <TestPacket> >(), log), Times.Never); }
public void Name_SetNullValue_ThrowsArgumentNullException() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); Assert.Throws <ArgumentNullException>(() => player.Name = null !); }
public void Inventory_Get_Count_Get() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); Assert.Equal(260, player.Inventory.Count); }
public void Character_Get() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); Assert.NotNull(player.Character); }
public void Inventory_Get_Item_GetIndexOutOfRange_ThrowsIndexOutOfRangeException(int index) { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); Assert.Throws <IndexOutOfRangeException>(() => player.Inventory[index]); }
public void SendPacket_NullPacket_ThrowsArgumentNullException() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); Assert.Throws <ArgumentNullException>(() => player.SendPacket <IPacket>(null !)); }
public void Team_Set() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); player.Team = Team.Red; Assert.Equal(1, terrariaPlayer.team); }
public void Team_Get() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player { team = (int)Team.Red }; var player = new OrionPlayer(terrariaPlayer, events, log); Assert.Equal(Team.Red, player.Team); }
public void Buffs_Get_Item_InvalidTime_Get(int buffTime) { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); terrariaPlayer.buffType[0] = (int)BuffId.ObsidianSkin; terrariaPlayer.buffTime[0] = buffTime; Assert.Equal(default, player.Buffs[0]);
public void MaxMana_Set() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); player.MaxMana = 200; Assert.Equal(200, terrariaPlayer.statManaMax); }
public void Mana_Get() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player { statMana = 100 }; var player = new OrionPlayer(terrariaPlayer, events, log); Assert.Equal(100, player.Mana); }
public void MaxHealth_Get() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player { statLifeMax = 500 }; var player = new OrionPlayer(terrariaPlayer, events, log); Assert.Equal(500, player.MaxHealth); }
public void IsInPvp_Set() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); player.IsInPvp = true; Assert.True(terrariaPlayer.hostile); }
public void Health_Set() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); player.Health = 100; Assert.Equal(100, terrariaPlayer.statLife); }
public void Name_Set() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); player.Name = "test"; Assert.Equal("test", terrariaPlayer.name); }
public void Buffs_Get_Item_Get() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); terrariaPlayer.buffType[0] = (int)BuffId.ObsidianSkin; terrariaPlayer.buffTime[0] = 28800; Assert.Equal(new Buff(BuffId.ObsidianSkin, TimeSpan.FromMinutes(8)), player.Buffs[0]); }
public void Inventory_Get_Item_SetBank4() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); player.Inventory[223] = new ItemStack(ItemId.Sdmg, ItemPrefix.Unreal, 1); Assert.Equal(ItemId.Sdmg, (ItemId)terrariaPlayer.bank4.item[3].type); Assert.Equal(ItemPrefix.Unreal, (ItemPrefix)terrariaPlayer.bank4.item[3].prefix); Assert.Equal(1, terrariaPlayer.bank4.item[3].stack); }
public void Inventory_Get_Item_GetMiscEquips() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); terrariaPlayer.miscEquips[3] = new Terraria.Item { type = (int)ItemId.Sdmg, prefix = (byte)ItemPrefix.Unreal, stack = 1 }; Assert.Equal(new ItemStack(ItemId.Sdmg, ItemPrefix.Unreal, 1), player.Inventory[92]); }
public void Inventory_Get_GetEnumerator() { var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player(); var player = new OrionPlayer(terrariaPlayer, events, log); for (var i = 0; i < player.Inventory.Count; ++i) { player.Inventory[i] = new ItemStack((ItemId)i, ItemPrefix.None, (short)i); } var inventory = player.Inventory.ToList(); for (var i = 0; i < inventory.Count; ++i) { Assert.Equal(new ItemStack((ItemId)i, ItemPrefix.None, (short)i), inventory[i]); } }