text:
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Subterfuge.Remake.Api.Network;
using Subterfuge.Remake.Core;
using Subterfuge.Remake.Core.Players;
using Subterfuge.Remake.Core.Timing;

namespace Subterfuge.Remake.Test
{
    [TestClass]
    public class GameTickTest
    {
        DateTime _time;
        int _tickNumber;
        GameTick _tick;
        private TestUtils testUtils = new TestUtils();

        [TestInitialize]
        public void Setup()
        {
            _time = DateTime.UtcNow;
            _tickNumber = 0;
            _tick = new GameTick(_tickNumber);
            GameConfiguration config = testUtils.GetDefaultGameConfiguration(new List<Player>{ new Player(new SimpleUser() { Id = "1" }) });
            new Game(config);
        }

        [TestMethod]
        public void Constructor()
        {
            Assert.AreEqual(_tickNumber, _tick.GetTick());
            Assert.AreEqual(_time, _tick.GetDate(_time));
        }

        [TestMethod]
        public void GetNextTick()
        {
            GameTick nextTick = _tick.GetNextTick();

            Assert.AreEqual(_time.AddMinutes(GameTick.MinutesPerTick), nextTick.GetDate(_time));
            Assert.AreEqual(_tickNumber + 1, nextTick.GetTick());
        }

        [TestMethod]
        public void GetPreviousTick()
        {
            // Check cannot go back before the first tick
            GameTick previousTick = _tick.GetPreviousTick();

            Assert.AreEqual(_tick, previousTick);

            // Advance and then come back
            GameTick startingTick = _tick.GetNextTick().GetPreviousTick();

            Assert.AreEqual(_time, startingTick.GetDate(_time));
            Assert.AreEqual(_tickNumber, startingTick.GetTick());
        }

        [TestMethod]
        public void Advance()
        {
            // Check advancing N ticks
            int ticksToAdvance = 10;
            GameTick tenMoreTicks = _tick.Advance(ticksToAdvance);

            Assert.AreEqual(_time.AddMinutes(GameTick.MinutesPerTick * ticksToAdvance), tenMoreTicks.GetDate(_time));
            Assert.AreEqual(_tickNumber + ticksToAdvance, tenMoreTicks.GetTick());
        }

        [TestMethod]
        public void Rewind()
        {
            int ticksToReverse = 10;
            GameTick tenTicksBefore = _tick.Rewind(ticksToReverse);

            // Should not be able to reverse
            Assert.AreEqual(true, tenTicksBefore == _tick);

            // Advance and then go back
            GameTick startingTick = _tick.Advance(ticksToReverse).Rewind(ticksToReverse);

            Assert.AreEqual(_time, startingTick.GetDate(_time));
            Assert.AreEqual(_tickNumber, startingTick.GetTick());

        }

        [TestMethod]
        public void FromTick()
        {
            int numberOfTicks = 4;
            double minutes = GameTick.MinutesPerTick * numberOfTicks;
            DateTime newDate = _time.AddMinutes(minutes);
            GameTick newTick = new GameTick(numberOfTicks);

            Assert.AreEqual(_tick.GetTick() + numberOfTicks, newTick.GetTick());
            Assert.AreEqual(newDate.ToLongTimeString(), newTick.GetDate(_time).ToLongTimeString());
            Assert.AreEqual(newDate.ToLongDateString(), newTick.GetDate(_time).ToLongDateString());
        }

        [TestMethod]
        public void FasterGameSpeed()
        {
            GameTick.MinutesPerTick = 0.1;
            DateTime start = _tick.GetDate(_time);
            GameTick forward = _tick.Advance(10);
            Assert.AreEqual(forward.GetDate(_time).ToLongTimeString(), start.AddMinutes(GameTick.MinutesPerTick * 10).ToLongTimeString());
        }

    }
}


text:
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Subterfuge.Remake.Api.Network;
using Subterfuge.Remake.Core;
using Subterfuge.Remake.Core.Entities.Components;
using Subterfuge.Remake.Core.Entities.Positions;
using Subterfuge.Remake.Core.GameEvents.PlayerTriggeredEvents;
using Subterfuge.Remake.Core.Players;
using Subterfuge.Remake.Core.Timing;
using Subterfuge.Remake.Core.Topologies;

namespace Subterfuge.Remake.Test
{
    [TestClass]
    public class OutpostTest
    {
	    Rft _map;
        RftVector _outpostLocation;
        Outpost _outpost;
        Outpost _outpost2;
        private readonly TestUtils _testUtils = new TestUtils();

        private readonly List<Player> _playersInGame = new List<Player>()
        {
            new Player(new SimpleUser() { Id = "1" })
        };

        private TimeMachine _timeMachine;

        [TestInitialize]
        public void Setup()
        {
            this._map = new Rft(3000, 3000);
            this._outpostLocation = new RftVector(_map, 0, 0);
            this._outpostLocation = new RftVector(_map, 15, 15);
            this._timeMachine = new TimeMachine(new GameState(_playersInGame));
            this._outpost = new Factory("0", _outpostLocation, _playersInGame[0], _timeMachine);
            this._outpost2 = new Factory("1", _outpostLocation, _playersInGame[0], _timeMachine);
        }

        [TestMethod]
        public void HasDrillerCarrier()
        {
            Assert.IsNotNull(_outpost.GetComponent<DrillerCarrier>());
        }

        [TestMethod]
        public void HasSpeedManager()
        {
            Assert.IsNotNull(_outpost.GetComponent<SpeedManager>());
        }

        [TestMethod]
        public void HasPositionManager()
        {
            Assert.IsNotNull(_outpost.GetComponent<PositionManager>());
        }

        [TestMethod]
        public void HasSpecialistManager()
        {
            Assert.IsNotNull(_outpost.GetComponent<SpecialistManager>());
        }

        [TestMethod]
        public void HasIdentityManager()
        {
            Assert.IsNotNull(_outpost.GetComponent<IdentityManager>());
        }

        [TestMethod]
        public void HasShieldManager()
        {
            Assert.IsNotNull(_outpost.GetComponent<ShieldManager>());
        }

        [TestMethod]
        public void HasSubLauncher()
        {
            Assert.IsNotNull(_outpost.GetComponent<SubLauncher>());
        }

        [TestMethod]
        public void HasVisionManager()
        {
            Assert.IsNotNull(_outpost.GetComponent<VisionManager>());
        }

        [TestMethod]
        public void GetPosition()
        {
            Assert.AreEqual(_outpostLocation.X, _outpost.GetComponent<PositionManager>().GetInitialPosition().X);
            Assert.AreEqual(_outpostLocation.Y, _outpost.GetComponent<PositionManager>().GetInitialPosition().Y);
        }

        [TestMethod]
        public void GetTargetLocation()
        {
            // Outpost target location should always be the outpost's location
            Assert.AreEqual(_outpostLocation.X, _outpost.GetComponent<PositionManager>().GetInterceptionPosition(new RftVector(_map, 0, 0), 0.25f).X);
            Assert.AreEqual(_outpostLocation.Y, _outpost.GetComponent<PositionManager>().GetInterceptionPosition(new RftVector(_map, 0, 0), 0.25f).Y);

            Assert.AreEqual(_outpostLocation.X, _outpost.GetComponent<PositionManager>().GetInterceptionPosition(new RftVector(_map, 100, 100), 1).X);
            Assert.AreEqual(_outpostLocation.Y, _outpost.GetComponent<PositionManager>().GetInterceptionPosition(new RftVector(_map, 100, 100), 1).Y);

            Assert.AreEqual(_outpostLocation.X, _outpost.GetComponent<PositionManager>().GetInterceptionPosition(new RftVector(_map, 999, 999), 999).X);
            Assert.AreEqual(_outpostLocation.Y, _outpost.GetComponent<PositionManager>().GetInterceptionPosition(new RftVector(_map, 999, 999), 999).Y);
        }

        [TestMethod]
        public void CanRemoveDrillers()
        {
            Outpost outpost = new Mine("0", new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            int initialDrillers = outpost.GetComponent<DrillerCarrier>().GetDrillerCount();
            outpost.GetComponent<DrillerCarrier>().AlterDrillers(-5);
            Assert.AreEqual(initialDrillers - 5, outpost.GetComponent<DrillerCarrier>().GetDrillerCount());
        }

        [TestMethod]
        public void CanAddDrillers()
        {
            Outpost outpost = new Mine("0", new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            int initialDrillers = outpost.GetComponent<DrillerCarrier>().GetDrillerCount();
            outpost.GetComponent<DrillerCarrier>().AlterDrillers(40);
            Assert.AreEqual(initialDrillers + 40, outpost.GetComponent<DrillerCarrier>().GetDrillerCount());
        }

        [TestMethod]
        public void CanSetDrillerCount()
        {
            Outpost outpost = new Mine("0", new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            outpost.GetComponent<DrillerCarrier>().SetDrillerCount(420);
            Assert.AreEqual(420, outpost.GetComponent<DrillerCarrier>().GetDrillerCount());
        }

        [TestMethod]
        public void CanLaunchSubs()
        {
            Game game = new Game(_testUtils.GetDefaultGameConfiguration(_playersInGame));
            game.TimeMachine.GetState().GetOutposts().Add(_outpost);
            game.TimeMachine.GetState().GetOutposts().Add(_outpost2);

            int initialDrillers = _outpost.GetComponent<DrillerCarrier>().GetDrillerCount();
            _outpost.GetComponent<SubLauncher>().LaunchSub(game.TimeMachine, new LaunchEvent(new GameRoomEvent()
                {
                    GameEventData = new GameEventData()
                    {
                        OccursAtTick = 10,
                        EventDataType = EventDataType.LaunchEventData,
                        SerializedEventData = JsonConvert.SerializeObject(new LaunchEventData()
                        {
                            DestinationId = _outpost.GetComponent<IdentityManager>().GetId(),
                            DrillerCount = 10,
                            SourceId = _outpost2.GetComponent<IdentityManager>().GetId(),
                        }),
                    },
                    Id = "123",
                    RoomId = "",
                }));

            Assert.AreEqual(initialDrillers - 10, _outpost.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(1, game.TimeMachine.GetState().GetSubList().Count);
        }

        [TestMethod]
        public void CanUndoSubLaunch()
        {
            Game game = new Game(_testUtils.GetDefaultGameConfiguration(_playersInGame));
            game.TimeMachine.GetState().GetOutposts().Add(_outpost);
            game.TimeMachine.GetState().GetOutposts().Add(_outpost2);

            var launchEvent = new LaunchEvent(new GameRoomEvent()
            {
                GameEventData = new GameEventData()
                {
                    OccursAtTick = 10,
                    EventDataType = EventDataType.LaunchEventData,
                    SerializedEventData = JsonConvert.SerializeObject(new LaunchEventData()
                    {
                        DestinationId = _outpost2.GetComponent<IdentityManager>().GetId(),
                        DrillerCount = 10,
                        SourceId = _outpost.GetComponent<IdentityManager>().GetId(),
                    }),
                },
                Id = "123",
            });

            int initialDrillers = _outpost.GetComponent<DrillerCarrier>().GetDrillerCount();
            launchEvent.ForwardAction(game.TimeMachine);

            Assert.AreEqual(initialDrillers - 10, _outpost.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(1, game.TimeMachine.GetState().GetSubList().Count);

            launchEvent.BackwardAction(game.TimeMachine);

            Assert.AreEqual(initialDrillers, _outpost.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(0, game.TimeMachine.GetState().GetSubList().Count);
        }

        [TestMethod]
        public void CanRemoveShields()
        {
            Outpost outpost = new Mine("0", new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            outpost.GetComponent<ShieldManager>().SetShields(10);
            int initialShields = outpost.GetComponent<ShieldManager>().GetShields();
            outpost.GetComponent<ShieldManager>().AlterShields(-5);
            Assert.AreEqual(initialShields - 5, outpost.GetComponent<ShieldManager>().GetShields());
        }

        [TestMethod]
        public void CanAddShields()
        {
            Outpost outpost = new Mine("0", new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            int initialShield = outpost.GetComponent<ShieldManager>().GetShields();
            outpost.GetComponent<ShieldManager>().AlterShields(1);
            Assert.AreEqual(initialShield + 1, outpost.GetComponent<ShieldManager>().GetShields());
        }

        [TestMethod]
        public void CanSetShields()
        {
            Outpost outpost = new Mine("0", new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            outpost.GetComponent<ShieldManager>().SetShields(1);
            Assert.AreEqual(1, outpost.GetComponent<ShieldManager>().GetShields());
        }

        [TestMethod]
        public void ShieldCapacityWorks()
        {
            Outpost outpost = new Mine("0", new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            outpost.GetComponent<ShieldManager>().SetShieldCapacity(100);
            outpost.GetComponent<ShieldManager>().SetShields(5);
            outpost.GetComponent<ShieldManager>().AlterShields(100);

            Assert.AreEqual(outpost.GetComponent<ShieldManager>().GetShieldCapacity(), outpost.GetComponent<ShieldManager>().GetShields());

            outpost.GetComponent<ShieldManager>().SetShields(105);
            Assert.AreEqual(outpost.GetComponent<ShieldManager>().GetShieldCapacity(), outpost.GetComponent<ShieldManager>().GetShields());
        }

        [TestMethod]
        public void CannotHaveNegativeShield()
        {
            Outpost outpost = new Mine("0", new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            outpost.GetComponent<ShieldManager>().SetShields(10);
            outpost.GetComponent<ShieldManager>().AlterShields(-15);
            Assert.AreEqual(0, outpost.GetComponent<ShieldManager>().GetShields());
        }

        [TestMethod]
        public void CanToggleShields()
        {
            Outpost outpost = new Mine("0",new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            bool initialState = outpost.GetComponent<ShieldManager>().IsShieldActive();
            outpost.GetComponent<ShieldManager>().ToggleShield();
            Assert.AreEqual(!initialState, outpost.GetComponent<ShieldManager>().IsShieldActive());
        }

        [TestMethod]
        public void CanSeeLocationInVision()
        {
            Outpost outpost = new Mine("0",new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            Outpost outpost2 = new Mine("1",new RftVector(_map, Constants.BaseOutpostVisionRadius - 1, 0), _playersInGame[0], _timeMachine);
            Assert.IsTrue(outpost.GetComponent<VisionManager>().IsInVisionRange(outpost2.GetComponent<PositionManager>()));
        }

        [TestMethod]
        public void CannotSeeLocationOutOfVision()
        {

            Outpost outpost = new Mine("0",new RftVector(_map, 0, 0), _playersInGame[0], _timeMachine);
            Outpost outpost2 = new Mine("1",new RftVector(_map, Constants.BaseOutpostVisionRadius + 1, 0), _playersInGame[0], _timeMachine);
            Assert.IsFalse(outpost.GetComponent<VisionManager>().IsInVisionRange(outpost2.GetComponent<PositionManager>()));
        }
    }
}

repo_name: Subterfuge-Revived/Remake-Core

repo_language: C#

mime_type: text/plain


text:
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Subterfuge.Remake.Core.Generation;
using Subterfuge.Remake.Core.Timing;

namespace Subterfuge.Remake.Test
{
    [TestClass]
    public class NameGeneratorTest
    {
        private NameGenerator _generator;

        [TestInitialize]
        public void Setup()
        {
            _generator = new NameGenerator(new SeededRandom(1234));
        }

        [TestMethod]
        public void GeneratesRandomNames()
        {
            string name1 = _generator.GetRandomName();
            string name2 = _generator.GetRandomName();
            Assert.IsTrue(name1.Equals(name2) == false);
        }

        [TestMethod]
        public void NoDuplicatedNames()
        {
            List<string> strings = new List<string>();
            while (_generator.HasNames())
            {
                strings.Add(_generator.GetRandomName());
            }

            // Ensure no duplicates.
            Assert.AreEqual(strings.Count, strings.Distinct().Count());
        }

        [TestMethod]
        public void IfNoNamesLeftNoDuplicatesGenerated()
        {
            List<string> strings = new List<string>();
            while (_generator.HasNames())
            {
                strings.Add(_generator.GetRandomName());
            }

            // Generate 10000 more names.
            for (int i = 0; i < 10000; i++)
            {
                strings.Add(_generator.GetRandomName());
            }

            // Ensure no duplicates.
            Assert.AreEqual(strings.Count, strings.Distinct().Count());
        }

        [TestMethod]
        public void AllNamesStartCaptolizedOthersLower()
        {
            string name;
            while (_generator.HasNames())
            {
                name = _generator.GetRandomName();
                Assert.IsTrue(Char.IsUpper(name, 0));
            }

            // Generate 10000 more names.
            for (int i = 0; i < 10000; i++)
            {
                name = _generator.GetRandomName();
                Assert.IsTrue(Char.IsUpper(name, 0));
            }
        }

    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using Subterfuge.Remake.Api.Network;
using Subterfuge.Remake.Core.Players;

namespace Subterfuge.Remake.Test
{
    public class TestUtils
    {
        public GameConfiguration GetDefaultGameConfiguration(List<Player> players)
        {
            GameConfiguration config = new GameConfiguration()
            {
                Id = "1",
                RoomStatus = RoomStatus.Open,
                Creator = new User() { Id = "1", Username = "1"},
                GameSettings = new GameSettings()
                {
                    IsAnonymous = false,
                    Goal = Goal.Domination,
                    MinutesPerTick = 15,
                    IsRanked = false,
                    MaxPlayers = players.Count
                },
                MapConfiguration = new MapConfiguration()
                {
                    Seed = 123123,
                    DormantsPerPlayer = 6,
                    MaximumOutpostDistance = 180,
                    MinimumOutpostDistance = 30,
                    OutpostsPerPlayer = 3,
                    OutpostDistribution = new OutpostDistribution()
                    {
                        FactoryWeight = 0.33f,
                        GeneratorWeight = 0.33f,
                        WatchtowerWeight = 0.33f,
                    }
                },
                RoomName = "Room",
                TimeCreated = DateTime.UtcNow,
                TimeStarted = DateTime.MinValue,
                PlayersInLobby = players.Select(it => it.PlayerInstance.ToUser()).ToList(),
            };
            return config;
        }
    }
}


text:
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Subterfuge.Remake.Api.Network;
using Subterfuge.Remake.Core;
using Subterfuge.Remake.Core.Entities;
using Subterfuge.Remake.Core.Entities.Components;
using Subterfuge.Remake.Core.Entities.Positions;
using Subterfuge.Remake.Core.Players;
using Subterfuge.Remake.Core.Timing;
using Subterfuge.Remake.Core.Topologies;

namespace Subterfuge.Remake.Test
{
    [TestClass]
    public class SubTest
    {
	    Rft _map;
        RftVector _location;
        Outpost _outpost;
        GameTick _tick;
        Sub _sub;

        private List<Player> playerInGame = new List<Player>()
        {
            new Player(new SimpleUser() { Id = "1" })
        };

        [TestInitialize]
        public void Setup()
        {
	        _map = new Rft(3000, 3000);
            _location = new RftVector(_map, 0, 0);
            var tm = new TimeMachine(new GameState(playerInGame));

            _outpost = new Generator("0", _location, playerInGame[0], tm);
            _tick = new GameTick(10);
            _sub = new Sub("0", _outpost, _outpost, _tick, 0, playerInGame[0], tm);
        }

        [TestMethod]
        public void HasDrillerCarrier()
        {
            Assert.IsNotNull(_sub.GetComponent<DrillerCarrier>());
        }

        [TestMethod]
        public void HasSpeedManager()
        {
            Assert.IsNotNull(_sub.GetComponent<SpeedManager>());
        }

        [TestMethod]
        public void HasPositionManager()
        {
            Assert.IsNotNull(_sub.GetComponent<PositionManager>());
        }

        [TestMethod]
        public void HasSpecialistManager()
        {
            Assert.IsNotNull(_sub.GetComponent<SpecialistManager>());
        }

        [TestMethod]
        public void HasIdentityManager()
        {
            Assert.IsNotNull(_sub.GetComponent<IdentityManager>());
        }

        [TestMethod]
        public void HasShieldManager()
        {
            Assert.IsNotNull(_sub.GetComponent<ShieldManager>());
        }

        [TestMethod]
        public void HasSubLauncher()
        {
            Assert.IsNotNull(_sub.GetComponent<SubLauncher>());
        }

        [TestMethod]
        public void HasVisionManager()
        {
            Assert.IsNotNull(_sub.GetComponent<VisionManager>());
        }
    }
}


text:
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Subterfuge.Remake.Api.Network;
using Subterfuge.Remake.Core;
using Subterfuge.Remake.Core.Entities;
using Subterfuge.Remake.Core.Entities.Components;
using Subterfuge.Remake.Core.Entities.Positions;
using Subterfuge.Remake.Core.Players;
using Subterfuge.Remake.Core.Timing;
using Subterfuge.Remake.Core.Topologies;

namespace Subterfuge.Remake.Test.Core.Components
{
    [TestClass]
    public class PositionManagerTest
    {
        private Mock<IEntity> _mockDestinationEntity;
        private Mock<IEntity> _mockChaserEntity;
        private Mock<IEntity> _mockChaserChaserEntity;

        private List<Player> players = new List<Player>()
        {
            new Player(new SimpleUser() { Id = "1" }),
        };
        private TimeMachine _timeMachine;

        private void MockDestinationPositionManagerEntity(
            float speed,
            RftVector initialLocation,
            IEntity destination = null,
            int launchTick = 0
        )
        {
            _mockDestinationEntity = new Mock<IEntity>();
            _mockDestinationEntity.Setup(it => it.GetComponent<SpeedManager>())
                .Returns(new SpeedManager(_mockDestinationEntity.Object, speed));
            _mockDestinationEntity.Setup(it => it.GetComponent<PositionManager>())
                .Returns(new PositionManager(_mockDestinationEntity.Object, EntityAtPosition(initialLocation), destination, new GameTick(launchTick), _timeMachine));
        }

        private void MockChaserPositionManagerEntity(
            float speed,
            RftVector initialLocation,
            int launchTick = 0
        )
        {
            _mockChaserEntity = new Mock<IEntity>();
            _mockChaserEntity.Setup(it => it.GetComponent<SpeedManager>())
                .Returns(new SpeedManager(_mockChaserEntity.Object, speed));
            _mockChaserEntity.Setup(it => it.GetComponent<PositionManager>())
                .Returns(new PositionManager(_mockChaserEntity.Object, EntityAtPosition(initialLocation), _mockDestinationEntity.Object, new GameTick(launchTick), _timeMachine));
        }

        private void MockChasersChaserPositionManagerEntity(
            float speed,
            RftVector initialLocation,
            int launchTick = 0
        )
        {
            _mockChaserChaserEntity = new Mock<IEntity>();
            _mockChaserChaserEntity.Setup(it => it.GetComponent<SpeedManager>())
                .Returns(new SpeedManager(_mockChaserChaserEntity.Object, speed));
            _mockChaserChaserEntity.Setup(it => it.GetComponent<PositionManager>())
                .Returns(new PositionManager(_mockChaserChaserEntity.Object, EntityAtPosition(initialLocation), _mockChaserEntity.Object, new GameTick(launchTick), _timeMachine));
        }

        [TestInitialize]
        public void Setup()
        {
            RftVector.Map = new Rft(1000, 1000);
            _timeMachine = new TimeMachine(new GameState((players)));

        }

        [TestMethod]
        public void CanInstantiateAPositionManager()
        {
            MockDestinationPositionManagerEntity(0.0f, new RftVector(1, 0));
        }

        [TestMethod]
        public void PositionOfNonMovingPositionManagerAtAnyTickIsTheInitialLocation()
        {
            var initialLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, initialLocation);
            var positionManager = _mockDestinationEntity.Object.GetComponent<PositionManager>();
            Assert.AreEqual(0, positionManager.GetSpawnTick().GetTick());
            Assert.AreEqual(initialLocation.X, positionManager.CurrentLocation.X);
            Assert.AreEqual(initialLocation.Y, positionManager.CurrentLocation.Y);

            _timeMachine.Advance(14);
            Assert.AreEqual(initialLocation.X, positionManager.CurrentLocation.X);
            Assert.AreEqual(initialLocation.Y, positionManager.CurrentLocation.Y);

            _timeMachine.Advance(144);
            Assert.AreEqual(initialLocation.X, positionManager.CurrentLocation.X);
            Assert.AreEqual(initialLocation.Y, positionManager.CurrentLocation.Y);
            _timeMachine.Advance(463);
            Assert.AreEqual(initialLocation.X, positionManager.CurrentLocation.X);
            Assert.AreEqual(initialLocation.Y, positionManager.CurrentLocation.Y);
            _timeMachine.Advance(6875);
            Assert.AreEqual(initialLocation.X, positionManager.CurrentLocation.X);
            Assert.AreEqual(initialLocation.Y, positionManager.CurrentLocation.Y);
        }

        [TestMethod]
        public void TheDirectionOfANonMovingPositionIsAZeroVector()
        {
            var initialLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, initialLocation);
            var positionManager = _mockDestinationEntity.Object.GetComponent<PositionManager>();
            Assert.AreEqual(0, positionManager.GetDirection().X);
            Assert.AreEqual(0, positionManager.GetDirection().Y);
        }

        [TestMethod]
        public void TheDestinationOfANonMovingPositionIsNull()
        {
            var initialLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, initialLocation);
            var positionManager = _mockDestinationEntity.Object.GetComponent<PositionManager>();
            Assert.IsNull(positionManager.GetDestination());
        }

        [TestMethod]
        public void APositionWithANullDestinationHaANullExpectedArrival()
        {
            var initialLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, initialLocation);
            var positionManager = _mockDestinationEntity.Object.GetComponent<PositionManager>();

            Assert.IsNull(positionManager.GetExpectedArrival());
        }

        [TestMethod]
        public void ExpectedDestinationOfNonMovingPositionIsItsInitialLocation()
        {
            var initialLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, initialLocation);
            var positionManager = _mockDestinationEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(initialLocation.X, positionManager.GetExpectedDestination().X);
            Assert.AreEqual(initialLocation.Y, positionManager.GetExpectedDestination().Y);
        }

        [TestMethod]
        public void TheInterceptionPointOfANonMovingPositionIsItsInitialLocation()
        {
            var initialLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, initialLocation);
            var positionManager = _mockDestinationEntity.Object.GetComponent<PositionManager>();
            Assert.AreEqual(0, positionManager.GetSpawnTick().GetTick());
            Assert.AreEqual(initialLocation.X, positionManager.GetInterceptionPosition(new RftVector(100, 0), 1.0f).X);
            Assert.AreEqual(initialLocation.Y, positionManager.GetInterceptionPosition(new RftVector(100, 0), 1.0f).Y);
        }

        [TestMethod]
        public void AMovingEntityCanTargetAStaticPosition()
        {
            var initialLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, initialLocation);

            var chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
        }

        [TestMethod]
        public void AMovingEntitysDestinationLocationIsTheSameLocationAsTheStaticPosition()
        {
            var destinationLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            var chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(destinationLocation.X, chaserPositionManager.GetExpectedDestination().X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.GetExpectedDestination().Y);

            // Test Two
            destinationLocation = new RftVector(75, 4);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            chaserLocation = new RftVector(56, 76);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(destinationLocation.X, chaserPositionManager.GetExpectedDestination().X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.GetExpectedDestination().Y);
        }

        [TestMethod]
        public void AChaserStartingAtZeroZeroHasDirectionSetToTheDestinationLocation()
        {
            var destinationLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            var chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(destinationLocation.X, chaserPositionManager.GetDirection().X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.GetDirection().Y);

            // Test Two
            destinationLocation = new RftVector(54, -13);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(destinationLocation.X, chaserPositionManager.GetDirection().X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.GetDirection().Y);
        }

        [TestMethod]
        public void AChasersOfSpeedOneHasExpectedArrivalOfOneTickMorePerDistanceUnitToItsDestination()
        {
            // Test One, 1 unit away at speed 1 should take 1 tick
            var destinationLocation = new RftVector(1, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            var chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(1, chaserPositionManager.GetExpectedArrival().GetTick());

            // Test Two, 100 units away at speed 1 should take 100 ticks
            destinationLocation = new RftVector(100, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(100, chaserPositionManager.GetExpectedArrival().GetTick());
        }

        [TestMethod]
        public void AChasersSpeedEffectsTheArrivalTime()
        {
            // Test One, At speed 1, 100 units takes 100 ticks
            var destinationLocation = new RftVector(100, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            var chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(100, chaserPositionManager.GetExpectedArrival().GetTick());

            // Test Two, At speed 2, 100 units takes 50 ticks
            destinationLocation = new RftVector(100, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(2.0f, chaserLocation);
            chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(50, chaserPositionManager.GetExpectedArrival().GetTick());

            // Test Two, At speed 4, 100 units takes 25 ticks
            destinationLocation = new RftVector(100, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(4.0f, chaserLocation);
            chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(25, chaserPositionManager.GetExpectedArrival().GetTick());

            // Test Three, At speed 10, 100 units takes 10 ticks
            destinationLocation = new RftVector(100, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(10.0f, chaserLocation);
            chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(10, chaserPositionManager.GetExpectedArrival().GetTick());
        }

        [TestMethod]
        public void CanGetChasersPositionAtAnyTickDuringTravel()
        {
            // Test One, 100 units over 100 ticks. Halfway is 50
            var destinationLocation = new RftVector(100, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            var chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            // Ensure interpolation works along the line
            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(100, chaserPositionManager.GetExpectedArrival().GetTick());
            for (var x = 0; x <= 100; x++)
            {
                Assert.AreEqual(x, chaserPositionManager.CurrentLocation.X);
                Assert.AreEqual(0, chaserPositionManager.CurrentLocation.Y);
                _timeMachine.Advance(1);
            }

            _timeMachine.GoTo(new GameTick(0));

            // Test Two, 100 units over 50 ticks.
            destinationLocation = new RftVector(100, 0);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            chaserLocation = new RftVector(0, 0);
            MockChaserPositionManagerEntity(2.0f, chaserLocation);
            chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(50, chaserPositionManager.GetExpectedArrival().GetTick());
            for (var x = 0; x <= 50; x++)
            {
                Assert.AreEqual(x*2, chaserPositionManager.CurrentLocation.X);
                Assert.AreEqual(0, chaserPositionManager.CurrentLocation.Y);
                _timeMachine.Advance(1);
            }

            _timeMachine.GoTo(new GameTick(0));

            // Test Three, random distance.
            destinationLocation = new RftVector(131, 121);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            chaserLocation = new RftVector(0, 0);
            var speed = 1.2f;
            MockChaserPositionManagerEntity(speed, chaserLocation);
            chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            var totalDistance = destinationLocation.Length();
            var normalizedDirection = destinationLocation.Normalize();
            var expectedTicks = Math.Floor(totalDistance / speed);
            var lastTick = (int)Math.Floor(totalDistance / speed);

            Assert.AreEqual(_mockDestinationEntity.Object, chaserPositionManager.GetDestination());
            Assert.AreEqual(expectedTicks, chaserPositionManager.GetExpectedArrival().GetTick());
            Assert.AreEqual(normalizedDirection.X, chaserPositionManager.GetDirection().Normalize().X);
            Assert.AreEqual(normalizedDirection.Y, chaserPositionManager.GetDirection().Normalize().Y);
            for (var x = 0; x <= expectedTicks; x++)
            {
                Assert.AreEqual((normalizedDirection * x * speed).X, chaserPositionManager.CurrentLocation.X, 0.01);
                Assert.AreEqual((normalizedDirection * x * speed).Y, chaserPositionManager.CurrentLocation.Y, 0.01);
                _timeMachine.Advance(1);
            }
            Assert.AreEqual(destinationLocation.X, chaserPositionManager.CurrentLocation.X, speed/2);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.CurrentLocation.Y, speed/2);
        }

        [TestMethod]
        public void ChaserCanChaseAChaser()
        {
            var destinationLocation = new RftVector(1, 1);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            var chaserLocation = new RftVector(-1, 1);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();

            var chasersChaserInitialPosition = new RftVector(0, 0);
            MockChasersChaserPositionManagerEntity(1.0f, chasersChaserInitialPosition);
            var chaserChaserPositionManager = _mockChaserChaserEntity.Object.GetComponent<PositionManager>();
            Assert.AreEqual(_mockChaserEntity.Object, chaserChaserPositionManager.GetDestination());
        }

        [TestMethod]
        public void ChaserOfChaserHasCorrectInterceptionPoint()
        {
            var destinationLocation = new RftVector(100, 100);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            var chaserLocation = new RftVector(-100, 100);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();
            // 200 units total.
            Assert.AreEqual(200, chaserPositionManager.GetExpectedArrival().GetTick());
            Assert.AreEqual(destinationLocation.X, chaserPositionManager.GetExpectedDestination().X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.GetExpectedDestination().Y);

            _timeMachine.Advance(100);
            // At tick 100, this unit will be at (0, 100)
            Assert.AreEqual(0, chaserPositionManager.CurrentLocation.X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.CurrentLocation.Y);
            _timeMachine.Rewind(100);

            // Therefore, if a chaser starts at (0, 0), 100 ticks lets the chaser intercept this sub at (0, 100).

            var chasersChaserInitialPosition = new RftVector(0, 0);
            MockChasersChaserPositionManagerEntity(1.0f, chasersChaserInitialPosition);
            var chaserChaserPositionManager = _mockChaserChaserEntity.Object.GetComponent<PositionManager>();

            Assert.IsTrue(_mockChaserEntity.Object.GetComponent<SpeedManager>().GetSpeed() > 0.001);
            Assert.AreEqual(_mockChaserEntity.Object, chaserChaserPositionManager.GetDestination());

            Assert.AreEqual(100, chaserChaserPositionManager.GetExpectedArrival().GetTick());
            Assert.AreEqual(0, chaserChaserPositionManager.GetExpectedDestination().X);
            Assert.AreEqual(100, chaserChaserPositionManager.GetExpectedDestination().Y);
            Assert.AreEqual(0, chaserChaserPositionManager.GetDirection().X);
            Assert.AreEqual(100, chaserChaserPositionManager.GetDirection().Y);
        }

        [TestMethod]
        public void ChaserOfChasersSpeedEffectsTheInterceptionPoint()
        {
            var destinationLocation = new RftVector(100, 200);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            var chaserLocation = new RftVector(-100, 200);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();
            // 200 units total.
            Assert.AreEqual(200, chaserPositionManager.GetExpectedArrival().GetTick());
            Assert.AreEqual(destinationLocation.X, chaserPositionManager.GetExpectedDestination().X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.GetExpectedDestination().Y);

            _timeMachine.Advance(100);
            // At tick 100, this unit will be at (0, 200)
            Assert.AreEqual(0, chaserPositionManager.CurrentLocation.X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.CurrentLocation.Y);
            _timeMachine.Rewind(100);

            // Therefore, if a chaser starts at (0, 0), with speed 2 it can intercept this sub at (0, 200) in 100 ticks.

            var chasersChaserInitialPosition = new RftVector(0, 0);
            MockChasersChaserPositionManagerEntity(2.0f, chasersChaserInitialPosition);
            var chaserChaserPositionManager = _mockChaserChaserEntity.Object.GetComponent<PositionManager>();

            Assert.IsTrue(_mockChaserEntity.Object.GetComponent<SpeedManager>().GetSpeed() > 0.001);
            Assert.AreEqual(_mockChaserEntity.Object, chaserChaserPositionManager.GetDestination());

            Assert.AreEqual(100, chaserChaserPositionManager.GetExpectedArrival().GetTick());
            Assert.AreEqual(0, chaserChaserPositionManager.GetExpectedDestination().X);
            Assert.AreEqual(200, chaserChaserPositionManager.GetExpectedDestination().Y);
            Assert.AreEqual(0, chaserChaserPositionManager.GetDirection().X);
            Assert.AreEqual(200, chaserChaserPositionManager.GetDirection().Y);
        }

        [TestMethod]
        public void ChaserCanChaseFromBehindIfItIsFaster()
        {
            var destinationLocation = new RftVector(100, 200);
            MockDestinationPositionManagerEntity(0.0f, destinationLocation);

            var chaserLocation = new RftVector(-100, 200);
            MockChaserPositionManagerEntity(1.0f, chaserLocation);
            var chaserPositionManager = _mockChaserEntity.Object.GetComponent<PositionManager>();
            // 200 units total.
            Assert.AreEqual(200, chaserPositionManager.GetExpectedArrival().GetTick());
            Assert.AreEqual(destinationLocation.X, chaserPositionManager.GetExpectedDestination().X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.GetExpectedDestination().Y);

            _timeMachine.Advance(100);
            // At tick 100, this unit will be at (0, 200)
            Assert.AreEqual(0, chaserPositionManager.CurrentLocation.X);
            Assert.AreEqual(destinationLocation.Y, chaserPositionManager.CurrentLocation.Y);
            _timeMachine.Rewind(100);

            // Therefore, if a chaser starts at the same position but a bit behind at double speed, it can intercept this sub at (0, 200) in 100 ticks.
            var chasersChaserInitialPosition = new RftVector(-200, 200);
            MockChasersChaserPositionManagerEntity(2.0f, chasersChaserInitialPosition);
            var chaserChaserPositionManager = _mockChaserChaserEntity.Object.GetComponent<PositionManager>();

            Assert.IsTrue(_mockChaserEntity.Object.GetComponent<SpeedManager>().GetSpeed() > 0.001);
            Assert.AreEqual(_mockChaserEntity.Object, chaserChaserPositionManager.GetDestination());

            Assert.AreEqual(100, chaserChaserPositionManager.GetExpectedArrival().GetTick());
            Assert.AreEqual(0, chaserChaserPositionManager.GetExpectedDestination().X);
            Assert.AreEqual(200, chaserChaserPositionManager.GetExpectedDestination().Y);
            Assert.AreEqual(200, chaserChaserPositionManager.GetDirection().X);
            Assert.AreEqual(0, chaserChaserPositionManager.GetDirection().Y);
        }

        private IEntity EntityAtPosition(RftVector position)
        {
            return new Generator(Guid.NewGuid().ToString(), position, _timeMachine);
        }
    }
}


text:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Subterfuge.Remake.Core.Entities;
using Subterfuge.Remake.Core.Entities.Components;

namespace Subterfuge.Remake.Test.Core.Components
{
    [TestClass]
    public class IdentityManagerTest
    {
        private Mock<IEntity> _mockEntity;

        private void MockIdentityManagerEntity(
            string id,
            string name = null
        )
        {
            _mockEntity = new Mock<IEntity>();
            _mockEntity.Setup(it => it.GetComponent<IdentityManager>())
                .Returns(new IdentityManager(_mockEntity.Object, id, name));
        }

        private void MockIdentityManagerEntityWithoutId(
            string name = null
        )
        {
            _mockEntity = new Mock<IEntity>();
            _mockEntity.Setup(it => it.GetComponent<IdentityManager>())
                .Returns(new IdentityManager(_mockEntity.Object, Guid.NewGuid().ToString(), name));
        }

        [TestMethod]
        public void CanInitializeIdentityManager()
        {
            MockIdentityManagerEntityWithoutId();
            Assert.IsNotNull(_mockEntity.Object.GetComponent<IdentityManager>());
        }

        [TestMethod]
        public void GuidIsGeneratedIfNotSet()
        {
            MockIdentityManagerEntityWithoutId();
            Assert.IsNotNull(_mockEntity.Object.GetComponent<IdentityManager>());
            Assert.IsNotNull(_mockEntity.Object.GetComponent<IdentityManager>().GetId());
        }

        [TestMethod]
        public void NameCanBeNull()
        {
            MockIdentityManagerEntityWithoutId();
            Assert.IsNotNull(_mockEntity.Object.GetComponent<IdentityManager>());
            Assert.IsNull(_mockEntity.Object.GetComponent<IdentityManager>().GetName());
        }

        [TestMethod]
        public void CanSetCustomName()
        {
            var name = "CustomName";
            MockIdentityManagerEntityWithoutId(name);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<IdentityManager>());
            Assert.AreEqual(name, _mockEntity.Object.GetComponent<IdentityManager>().GetName());
        }

        [TestMethod]
        public void CanSetCustomId()
        {
            var id = Guid.NewGuid().ToString();
            var name = "CustomName";
            MockIdentityManagerEntity(id, name);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<IdentityManager>());
            Assert.AreEqual(id, _mockEntity.Object.GetComponent<IdentityManager>().GetId());
            Assert.AreEqual(name, _mockEntity.Object.GetComponent<IdentityManager>().GetName());
        }

        [TestMethod]
        public void CanSetNameAfterCreation()
        {
            var id = Guid.NewGuid().ToString();
            var name = "CustomName";
            MockIdentityManagerEntity(id, name);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<IdentityManager>());
            Assert.AreEqual(name, _mockEntity.Object.GetComponent<IdentityManager>().GetName());

            var newName = "NewName";
            _mockEntity.Object.GetComponent<IdentityManager>().SetName(newName);
            Assert.AreEqual(newName, _mockEntity.Object.GetComponent<IdentityManager>().GetName());
        }
    }
}


text:
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Newtonsoft.Json;
using Subterfuge.Remake.Api.Network;
using Subterfuge.Remake.Core;
using Subterfuge.Remake.Core.Entities;
using Subterfuge.Remake.Core.Entities.Components;
using Subterfuge.Remake.Core.Entities.Positions;
using Subterfuge.Remake.Core.GameEvents.EventPublishers;
using Subterfuge.Remake.Core.GameEvents.PlayerTriggeredEvents;
using Subterfuge.Remake.Core.Players;
using Subterfuge.Remake.Core.Timing;
using Subterfuge.Remake.Core.Topologies;

namespace Subterfuge.Remake.Test.Core.Components
{
    [TestClass]
    public class SubLauncherTest
    {
        private Mock<IEntity> _mockEntity;
        private Player initialOwner = new Player(new SimpleUser(){ Id = "1" });

        private List<Player> players;
        private TimeMachine _timeMachine;

        public void MockSubLauncherEntity(
            int initialDrillers,
            Player owner,
            int specialistCapacity
        )
        {
            _mockEntity = new Mock<IEntity>();
            _mockEntity.Setup(it => it.GetComponent<DrillerCarrier>())
                .Returns(new DrillerCarrier(_mockEntity.Object, initialDrillers, owner));
            _mockEntity.Setup(it => it.GetComponent<SpecialistManager>())
                .Returns(new SpecialistManager(_mockEntity.Object, specialistCapacity));
            _mockEntity.Setup(it => it.GetComponent<SubLauncher>())
                .Returns(new SubLauncher(_mockEntity.Object));
        }

        [TestInitialize]
        public void Setup()
        {
            players = new List<Player>()
            {
                initialOwner
            };
            _timeMachine = new TimeMachine(new GameState(players));
        }

        [TestMethod]
        public void CanInitializeSubLauncher()
        {
            MockSubLauncherEntity(10, initialOwner, 3);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SubLauncher>());
        }

        [TestMethod]
        public void CanLaunchASub()
        {
            MockSubLauncherEntity(10, initialOwner, 3);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SubLauncher>());

            var launchEventData = new LaunchEventData()
            {
                DestinationId = "1",
                DrillerCount = 5,
                SourceId = "2"
            };
            var launchEvent = new LaunchEvent(new GameRoomEvent()
            {
                GameEventData = new GameEventData()
                {
                    OccursAtTick = 1,
                    EventDataType = EventDataType.LaunchEventData,
                    SerializedEventData = JsonConvert.SerializeObject(launchEventData),
                },
                Id = "asdf",
                IssuedBy = initialOwner.PlayerInstance,
                RoomId = "1",
                TimeIssued = DateTime.FromFileTimeUtc(1234123412341234),
            });

            RftVector.Map = new Rft(100, 100);
            var destination = new Generator(launchEventData.DestinationId, new RftVector(0, 0), _timeMachine);
            var source = new Generator(launchEventData.SourceId, new RftVector(0, 0), _timeMachine);

            _timeMachine.GetState().GetOutposts().Add(destination);
            _timeMachine.GetState().GetOutposts().Add(source);

            var launchedSub = _mockEntity.Object.GetComponent<SubLauncher>().LaunchSub(_timeMachine, launchEvent);

            // Verify the sub was added to the state
            Assert.IsNotNull(launchedSub);
            Assert.AreEqual(destination, launchedSub.GetComponent<PositionManager>().GetDestination());
            Assert.AreEqual(launchEventData.DrillerCount, launchedSub.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(initialOwner, launchedSub.GetComponent<DrillerCarrier>().GetOwner());
            Assert.AreEqual(0, launchedSub.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
        }

        [TestMethod]
        public void CanUndoASubLaunch()
        {
            MockSubLauncherEntity(10, initialOwner, 3);

            var launchEventData = new LaunchEventData()
            {
                DestinationId = "1",
                DrillerCount = 5,
                SourceId = "2"
            };
            var launchEvent = new LaunchEvent(new GameRoomEvent()
            {
                GameEventData = new GameEventData()
                {
                    OccursAtTick = 1,
                    EventDataType = EventDataType.LaunchEventData,
                    SerializedEventData = JsonConvert.SerializeObject(launchEventData),
                },
                Id = "asdf",
                IssuedBy = initialOwner.PlayerInstance,
                RoomId = "1",
                TimeIssued = DateTime.FromFileTimeUtc(1234123412341234),
            });

            RftVector.Map = new Rft(100, 100);
            var destination = new Generator(launchEventData.DestinationId, new RftVector(0, 0), _timeMachine);
            var source = new Generator(launchEventData.SourceId, new RftVector(0, 0), initialOwner, _timeMachine);
            var initialDrillerCount = source.GetComponent<DrillerCarrier>().GetDrillerCount();

            OnSubLaunchEventArgs subLaunchEventData = null;
            OnSubLaunchEventArgs undoSubLaunch = null;
            source.GetComponent<SubLauncher>().OnSubLaunched += (sender, args) =>
            {
                if (args.Direction == TimeMachineDirection.FORWARD)
                {
                    subLaunchEventData = args;
                }
                else
                {
                    undoSubLaunch = args;
                }
            };

            _timeMachine.GetState().GetOutposts().Add(destination);
            _timeMachine.GetState().GetOutposts().Add(source);

            var launchedSub = source.GetComponent<SubLauncher>().LaunchSub(_timeMachine, launchEvent);

            Assert.IsNotNull(subLaunchEventData);
            Assert.AreEqual(destination, subLaunchEventData.Destination);
            Assert.AreEqual(source, subLaunchEventData.Source);

            Assert.IsNotNull(subLaunchEventData.LaunchedSub);

            // Verify the sub was added to the state
            Assert.IsNotNull(launchedSub);
            Assert.AreEqual(launchEventData.DrillerCount, subLaunchEventData.LaunchedSub.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(initialOwner, subLaunchEventData.LaunchedSub.GetComponent<DrillerCarrier>().GetOwner());
            Assert.AreEqual(initialDrillerCount - launchEvent.GetEventData().DrillerCount, source.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(0, subLaunchEventData.LaunchedSub.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            source.GetComponent<SubLauncher>().UndoLaunch(_timeMachine, launchEvent);

            // Verify the sub that was launched, is removed from the state, and the outposts have their original driller counts.
            Assert.IsNotNull(undoSubLaunch);
            Assert.AreEqual(initialDrillerCount, source.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(initialOwner, subLaunchEventData.LaunchedSub.GetComponent<DrillerCarrier>().GetOwner());
            Assert.AreEqual(0, subLaunchEventData.LaunchedSub.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
        }

        // Event Handler Tests
        [TestMethod]
        public void LaunchingASubTriggersAnOnLaunchEvent()
        {
            MockSubLauncherEntity(10, initialOwner, 3);

            var mockGameState = new Mock<IGameState>();
            var launchEventData = new LaunchEventData()
            {
                DestinationId = "1",
                DrillerCount = 5,
                SourceId = "2"
            };
            var launchEvent = new LaunchEvent(new GameRoomEvent()
            {
                GameEventData = new GameEventData()
                {
                    OccursAtTick = 1,
                    EventDataType = EventDataType.LaunchEventData,
                    SerializedEventData = JsonConvert.SerializeObject(launchEventData),
                },
                Id = "asdf",
                IssuedBy = initialOwner.PlayerInstance,
                RoomId = "1",
                TimeIssued = DateTime.FromFileTimeUtc(1234123412341234),
            });

            RftVector.Map = new Rft(100, 100);
            var destination = new Generator(launchEventData.DestinationId, new RftVector(0, 0), _timeMachine);
            var source = new Generator(launchEventData.SourceId, new RftVector(0, 0), initialOwner, _timeMachine);

            _timeMachine.GetState().GetOutposts().Add(destination);
            _timeMachine.GetState().GetOutposts().Add(source);

            OnSubLaunchEventArgs subLaunchEventData = null;
            source.GetComponent<SubLauncher>().OnSubLaunched += (source, launchArgs) =>
            {
                if (launchArgs.Direction == TimeMachineDirection.FORWARD)
                {
                    subLaunchEventData = launchArgs;
                }
            };

            var sub = source.GetComponent<SubLauncher>().LaunchSub(_timeMachine, launchEvent);

            Assert.IsNotNull(sub);
            Assert.AreEqual(destination, sub.GetComponent<PositionManager>().GetDestination());
            Assert.AreEqual(launchEventData.DrillerCount, sub.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(initialOwner, sub.GetComponent<DrillerCarrier>().GetOwner());
            Assert.AreEqual(0, sub.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            // Verify event data
            Assert.IsNotNull(subLaunchEventData);
            Assert.AreEqual(destination, subLaunchEventData.Destination);
            Assert.AreEqual(source, subLaunchEventData.Source);
            Assert.IsNotNull(subLaunchEventData.LaunchedSub);
            Assert.AreEqual(launchEventData.DrillerCount,
                subLaunchEventData.LaunchedSub.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(initialOwner, subLaunchEventData.LaunchedSub.GetComponent<DrillerCarrier>().GetOwner());
            Assert.AreEqual(0, subLaunchEventData.LaunchedSub.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
        }

        [TestMethod]
        public void UndoingALaunchTriggersAnUndoLaunchEvent()
        {
            MockSubLauncherEntity(10, initialOwner, 3);

            var mockGameState = new Mock<IGameState>();
            var launchEventData = new LaunchEventData()
            {
                DestinationId = "1",
                DrillerCount = 5,
                SourceId = "2"
            };
            var launchEvent = new LaunchEvent(new GameRoomEvent()
            {
                GameEventData = new GameEventData()
                {
                    OccursAtTick = 1,
                    EventDataType = EventDataType.LaunchEventData,
                    SerializedEventData = JsonConvert.SerializeObject(launchEventData),
                },
                Id = "asdf",
                IssuedBy = initialOwner.PlayerInstance,
                RoomId = "1",
                TimeIssued = DateTime.FromFileTimeUtc(1234123412341234),
            });

            RftVector.Map = new Rft(100, 100);
            var destination = new Generator(launchEventData.DestinationId, new RftVector(0, 0), _timeMachine);
            var source = new Generator(launchEventData.SourceId, new RftVector(0, 0), initialOwner, _timeMachine);

            _timeMachine.GetState().GetOutposts().Add(destination);
            _timeMachine.GetState().GetOutposts().Add(source);

            OnSubLaunchEventArgs subLaunchEventData = null;
            OnSubLaunchEventArgs undoSubLaunch = null;
            source.GetComponent<SubLauncher>().OnSubLaunched += (sender, args) =>
            {
                if (args.Direction == TimeMachineDirection.FORWARD)
                {
                    subLaunchEventData = args;
                }
                else
                {
                    undoSubLaunch = args;
                }
            };

            var launchedSub = source.GetComponent<SubLauncher>().LaunchSub(_timeMachine, launchEvent);
            // Verify the sub was added to the state
            Assert.IsNotNull(launchedSub);
            Assert.AreEqual(destination, launchedSub.GetComponent<PositionManager>().GetDestination());
            Assert.AreEqual(launchEventData.DrillerCount, launchedSub.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(initialOwner, launchedSub.GetComponent<DrillerCarrier>().GetOwner());
            Assert.AreEqual(0, launchedSub.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            // Verify event data
            Assert.IsNotNull(subLaunchEventData);
            Assert.AreEqual(destination, subLaunchEventData.Destination);
            Assert.AreEqual(source, subLaunchEventData.Source);
            Assert.IsNotNull(subLaunchEventData.LaunchedSub);
            Assert.AreEqual(launchEventData.DrillerCount, subLaunchEventData.LaunchedSub.GetComponent<DrillerCarrier>().GetDrillerCount());
            Assert.AreEqual(initialOwner, subLaunchEventData.LaunchedSub.GetComponent<DrillerCarrier>().GetOwner());
            Assert.AreEqual(0, subLaunchEventData.LaunchedSub.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            source.GetComponent<SubLauncher>().UndoLaunch(_timeMachine, launchEvent);

            // Verify the sub that was launched is removed from the state
            // Verify event data
            Assert.IsNotNull(undoSubLaunch);
            Assert.AreEqual(subLaunchEventData.LaunchedSub, undoSubLaunch.LaunchedSub);
            Assert.AreEqual(subLaunchEventData.Source, undoSubLaunch.Source);
            Assert.AreEqual(subLaunchEventData.LaunchEvent, undoSubLaunch.LaunchEvent);
        }
    }
}


text:
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Subterfuge.Remake.Api.Network;
using Subterfuge.Remake.Core;
using Subterfuge.Remake.Core.Entities;
using Subterfuge.Remake.Core.Entities.Components;
using Subterfuge.Remake.Core.Entities.Specialists;
using Subterfuge.Remake.Core.Entities.Specialists.Specialists;
using Subterfuge.Remake.Core.GameEvents.EventPublishers;
using Subterfuge.Remake.Core.Players;
using Subterfuge.Remake.Core.Timing;

namespace Subterfuge.Remake.Test.Core.Components
{
    [TestClass]
    public class SpecialistManagerTest
    {
        private Mock<IEntity> _mockEntity;
        private Mock<IEntity> _mockSecondEntity;

        private Player playerOne = new Player(new SimpleUser() { Id = "1" });
        private Player playerTwo = new Player(new SimpleUser() { Id = "2" });

        private List<Player> players;
        private TimeMachine _timeMachine;

        private void MockSpecialistManagerEntity(
            int specialistCapacity = 3
        )
        {
            _mockEntity = new Mock<IEntity>();
            var specialistManager = new SpecialistManager(_mockEntity.Object, specialistCapacity);
            specialistManager.AllowHireFromLocation();

            _mockEntity.Setup(it => it.GetComponent<SpecialistManager>())
                .Returns(specialistManager);
        }

        private void MockSecondSpecialistManagerEntity(
            int specialistCapacity = 3
        )
        {
            _mockSecondEntity = new Mock<IEntity>();
            var specialistManager = new SpecialistManager(_mockSecondEntity.Object, specialistCapacity);
            specialistManager.AllowHireFromLocation();
            _mockSecondEntity.Setup(it => it.GetComponent<SpecialistManager>())
                .Returns(specialistManager);
        }

        [TestInitialize]
        public void Setup()
        {
            players = new List<Player>()
            {
                new Player(new SimpleUser() { Id = "1" })
            };
            _timeMachine = new TimeMachine(new GameState(players));
        }

        [TestMethod]
        public void CanInitializeSpecialistManager()
        {
            MockSpecialistManagerEntity();
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
        }

        [TestMethod]
        public void CanInitializeSpecialistManagerWithCapacity()
        {
            var initialCapacity = 5;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
        }

        [TestMethod]
        public void SpecialistManagerWithNoSpecialistsReturnsEmptyList()
        {
            var initialCapacity = 5;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Count);
        }

        [TestMethod]
        public void SpecialistManagerWithCapacityHasCanAddNewSpecialistsTrue()
        {
            var initialCapacity = 5;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.AreEqual(true, _mockEntity.Object.GetComponent<SpecialistManager>().CanAddSpecialists());
        }

        [TestMethod]
        public void NoCapacityToAddSpecialistIfZeroCapacity()
        {
            var initialCapacity = 0;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.AreEqual(false, _mockEntity.Object.GetComponent<SpecialistManager>().CanAddSpecialists());
        }

        [TestMethod]
        public void CanAddSpecialistToCarrier()
        {
            var initialCapacity = 1;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialist = new NoOpSpecialist(playerOne);
            bool result = _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialist, _timeMachine);
            Assert.IsTrue(result);

            Assert.AreEqual(1, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialist));
        }

        [TestMethod]
        public void CannotAddSpecialistToCarrierIfNoRoom()
        {
            var initialCapacity = 0;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialist = new NoOpSpecialist(playerOne);
            bool result = _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialist, _timeMachine);
            Assert.IsFalse(result);

            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialist));
        }

        [TestMethod]
        public void CanAddListOfSpecialistsToCarrier()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            var specialists = new List<Specialist>();
            specialists.Add(specialistOne);
            specialists.Add(specialistTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
        }

        [TestMethod]
        public void IfCarrierIsFullWhileAddingListOfSpecialistsOnlySomeGetAdded()
        {
            var initialCapacity = 1;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            var specialists = new List<Specialist>();
            specialists.Add(specialistOne);
            specialists.Add(specialistTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(1, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
        }

        [TestMethod]
        public void CannotRemoveASpecialistIfNotInCarrier()
        {
            var initialCapacity = 1;
            MockSpecialistManagerEntity(initialCapacity);
            MockSecondSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialist = new NoOpSpecialist(playerOne);
            bool removeResult = _mockEntity.Object.GetComponent<SpecialistManager>().TransferSpecialistsById(
                _mockSecondEntity.Object.GetComponent<SpecialistManager>(),
                new List<string>() { specialist.GetId() },
                _timeMachine
            );
            Assert.IsTrue(removeResult);
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.AreEqual(0, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
        }

        [TestMethod]
        public void CanRemoveListOfSpecialistsToCarrier()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            var specialists = new List<Specialist>();
            specialists.Add(specialistOne);
            specialists.Add(specialistTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));

            _mockEntity.Object.GetComponent<SpecialistManager>().KillAll();
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
        }

        [TestMethod]
        public void RemovingAListOfSpecialistsOnlyRemovesTheOnesInTheCarrier()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            var specialists = new List<Specialist>();
            specialists.Add(specialistOne);
            specialists.Add(specialistTwo);

            bool addOperation = _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            Assert.AreEqual(true, addOperation);

            Assert.AreEqual(1, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));

            _mockEntity.Object.GetComponent<SpecialistManager>().KillAll();
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
        }

        [TestMethod]
        public void CanSetTheCapacity()
        {
            var initialCapacity = 5;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());

            var capacityDelta = 6;
            _mockEntity.Object.GetComponent<SpecialistManager>().AlterCapacity(capacityDelta);
            Assert.AreEqual(initialCapacity + capacityDelta, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
        }

        [TestMethod]
        public void CanTransferSpecialistsFromOneCarrierToAnotherIfItHasCapacity()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            MockSecondSpecialistManagerEntity(2);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.IsNotNull(_mockSecondEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(initialCapacity, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.AreEqual(0, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            var specialists = new List<Specialist>();
            specialists.Add(specialistOne);
            specialists.Add(specialistTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));

            var transferResult = _mockEntity.Object.GetComponent<SpecialistManager>()
                .TransferSpecialistsTo(_mockSecondEntity.Object.GetComponent<SpecialistManager>(), _timeMachine);

            Assert.IsTrue(transferResult);
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
            Assert.AreEqual(2, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockSecondEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockSecondEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
        }

        [TestMethod]
        public void CannotTransferSpecialistsIfTheSecondCarrierDoesNotHaveCapacity()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            MockSecondSpecialistManagerEntity(0);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.IsNotNull(_mockSecondEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.AreEqual(0, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            var specialists = new List<Specialist>();
            specialists.Add(specialistOne);
            specialists.Add(specialistTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));

            var transferResult = _mockEntity.Object.GetComponent<SpecialistManager>()
                .TransferSpecialistsTo(_mockSecondEntity.Object.GetComponent<SpecialistManager>(), _timeMachine);

            Assert.IsFalse(transferResult);
            Assert.AreEqual(0, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsFalse(_mockSecondEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsFalse(_mockSecondEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
        }

        [TestMethod]
        public void CanTransferSpecialistsByIdFromOneCarrierToAnotherIfItHasCapacity()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            MockSecondSpecialistManagerEntity(2);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.IsNotNull(_mockSecondEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(initialCapacity, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.AreEqual(0, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            var specialists = new List<Specialist>();
            specialists.Add(specialistOne);
            specialists.Add(specialistTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));

            var listOfIds = specialists.Select(it => it.GetId()).ToList();

            var transferResult = _mockEntity.Object.GetComponent<SpecialistManager>()
                .TransferSpecialistsById(_mockSecondEntity.Object.GetComponent<SpecialistManager>(), listOfIds, _timeMachine);

            Assert.IsTrue(transferResult);
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsFalse(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
            Assert.AreEqual(2, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockSecondEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockSecondEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
        }

        [TestMethod]
        public void CannotTransferSpecialistsByIdFromOneCarrierToAnotherIfNoCapacity()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            MockSecondSpecialistManagerEntity(0);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.IsNotNull(_mockSecondEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.AreEqual(0, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            var specialists = new List<Specialist>();
            specialists.Add(specialistOne);
            specialists.Add(specialistTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));

            var listOfIds = specialists.Select(it => it.GetId()).ToList();

            var transferResult = _mockEntity.Object.GetComponent<SpecialistManager>()
                .TransferSpecialistsById(_mockSecondEntity.Object.GetComponent<SpecialistManager>(), listOfIds, _timeMachine);

            Assert.IsFalse(transferResult);
            Assert.AreEqual(0, _mockSecondEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsFalse(_mockSecondEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsFalse(_mockSecondEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
        }

        [TestMethod]
        public void CanCaptureAllSpecialistsInACarrier()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));

            _mockEntity.Object.GetComponent<SpecialistManager>().CaptureAllForward(null, null);
            Assert.IsTrue(specialistOne.IsCaptured());
            Assert.IsTrue(specialistTwo.IsCaptured());
        }

        [TestMethod]
        public void CanAddTwoSpecialistsOwnedByDifferentPlayersToACarrier()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));
        }

        [TestMethod]
        public void CanGetAllSpecialistsOwnedByASpecificPlayer()
        {
            var initialCapacity = 2;
            MockSpecialistManagerEntity(initialCapacity);
            Assert.IsNotNull(_mockEntity.Object.GetComponent<SpecialistManager>());
            Assert.AreEqual(initialCapacity, _mockEntity.Object.GetComponent<SpecialistManager>().GetCapacity());
            Assert.AreEqual(0, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());

            var specialistOne = new NoOpSpecialist(playerOne);
            var specialistTwo = new NoOpSpecialist(playerTwo);

            var specialists = new List<Specialist>();
            specialists.Add(specialistOne);
            specialists.Add(specialistTwo);

            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistOne, _timeMachine);
            _mockEntity.Object.GetComponent<SpecialistManager>().HireSpecialist(specialistTwo, _timeMachine);

            Assert.AreEqual(2, _mockEntity.Object.GetComponent<SpecialistManager>().GetUncapturedSpecialistCount());
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistOne));
            Assert.IsTrue(_mockEntity.Object.GetComponent<SpecialistManager>().GetSpecialists().Contains(specialistTwo));

            List<Specialist> playerOneSpecs =
                _mockEntity.Object.GetComponent<SpecialistManager>().GetPlayerSpecialists(playerOne);
            Assert.AreEqual(1, playerOneSpecs.Count);
            Assert.IsTrue(playerOneSpecs.Contains(specialistOne));
        }
    }
}


text:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Subterfuge.Remake.Core.Entities;
using Subterfuge.Remake.Core.Entities.Components;

namespace Subterfuge.Remake.Test.Core.Components
{
    [TestClass]
    public class EntityComponentTest
    {
        class ReturnSevenComponent : EntityComponent
        {
            public ReturnSevenComponent(Entity parent) : base(parent) { }

            public int Return()
            {
                return 7;
            }
        }
        class TestReturnIntComponent : EntityComponent
        {
            private int returnMe;

            public TestReturnIntComponent(Entity parent, int returnMe) : base(parent)
            {
                this.returnMe = returnMe;
            }

            public int Return()
            {
                return returnMe;
            }
        }

        private class TestEntity : Entity
        {
            public TestEntity(int returnInt)
            {
                AddComponent(new TestReturnIntComponent(this, returnInt));
            }
        }

        private class DuplicateComponentEntity : Entity
        {
            public DuplicateComponentEntity(int firstReturn, int secondReturn)
            {
                AddComponent(new TestReturnIntComponent(this, firstReturn));
                AddComponent(new TestReturnIntComponent(this, secondReturn));
            }
        }

        private class ManyComponentEntity : Entity
        {
            public ManyComponentEntity(int returnValue)
            {
                AddComponent(new TestReturnIntComponent(this, returnValue));
                AddComponent(new ReturnSevenComponent(this));
            }
        }

        class TestNullComponent : Entity { }

        [TestMethod]
        public void CanAddComponentsToAnEntity()
        {
            var returnValue = 7;
            var testEntity = new TestEntity(returnValue);
            Assert.IsTrue(testEntity.HasComponent<TestReturnIntComponent>());
            Assert.IsNotNull(testEntity.GetComponent<TestReturnIntComponent>());
            Assert.AreEqual(returnValue, testEntity.GetComponent<TestReturnIntComponent>().Return());
        }

        [TestMethod]
        public void ComponentCanReferenceTheParentEntity()
        {
            var returnValue = 7;
            var testEntity = new TestEntity(returnValue);
            Assert.IsTrue(testEntity.HasComponent<TestReturnIntComponent>());
            Assert.IsNotNull(testEntity.GetComponent<TestReturnIntComponent>());
            Assert.AreEqual(testEntity, testEntity.GetComponent<TestReturnIntComponent>().Parent);
        }

        [TestMethod]
        public void AttemptingToGetAComponentThatDoesntExistReturnsNull()
        {
            var testEntity = new TestNullComponent();
            Assert.IsFalse(testEntity.HasComponent<TestReturnIntComponent>());
            var exception = Assert.ThrowsException<ComponentDoesNotExistException>(() =>
            {
                testEntity.GetComponent<TestReturnIntComponent>();
            });
        }

        [TestMethod]
        public void TwoComponentsOfTheSameTypeOverwrite()
        {
            var testEntity = new DuplicateComponentEntity(1, 2);
            Assert.IsTrue(testEntity.HasComponent<TestReturnIntComponent>());
            Assert.IsNotNull(testEntity.GetComponent<TestReturnIntComponent>());
            Assert.AreEqual(2, testEntity.GetComponent<TestReturnIntComponent>().Return());
        }

        [TestMethod]
        public void CanGetMultipleComponentsFromEntity()
        {
            var testEntity = new ManyComponentEntity(1);
            Assert.IsTrue(testEntity.HasComponent<TestReturnIntComponent>());
            Assert.IsNotNull(testEntity.GetComponent<TestReturnIntComponent>());
            Assert.AreEqual(1, testEntity.GetComponent<TestReturnIntComponent>().Return());

            // Assert.IsTrue(testEntity.HasComponent<ReturnSevenComponent>());
            Assert.IsNotNull(testEntity.GetComponent<ReturnSevenComponent>());
            Assert.AreEqual(7, testEntity.GetComponent<ReturnSevenComponent>().Return());
        }
    }
}