Пример #1
0
        public void Spawn()
        {
            // Clear the NPC so that we know it's empty.
            Terraria.Main.npc[0] = new Terraria.NPC {
                whoAmI = 0
            };

            var events = Mock.Of <IEventManager>();
            var log    = Mock.Of <ILogger>();

            using var npcService = new OrionNpcService(events, log);

            var npc = npcService.Spawn(NpcId.BlueSlime, Vector2f.Zero);

            Assert.NotNull(npc);
            Assert.Equal(NpcId.BlueSlime, npc !.Id);
        }
Пример #2
0
        public void Spawn_ReturnsNull()
        {
            // Fill up all of the NPC slots so that the spawn fails.
            for (var i = 0; i < Terraria.Main.maxNPCs; ++i)
            {
                Terraria.Main.npc[i] = new Terraria.NPC {
                    whoAmI = i, active = true
                };
            }

            var events = Mock.Of <IEventManager>();
            var log    = Mock.Of <ILogger>();

            using var npcService = new OrionNpcService(events, log);

            var npc = npcService.Spawn(NpcId.BlueSlime, Vector2f.Zero);

            Assert.Null(npc);
        }