Exemple #1
0
        public void GetTroopObject_WhenCalledTwice_ReturnsSameInstance(
            [Frozen] ITroopStub stub,
            StationedTroopObjectInitializer troopInitializer)
        {
            stub.State.Returns(TroopState.Stationed);
            stub.Station.Troops.RemoveStationed(Arg.Any <ushort>()).Returns(true);

            ITroopObject troopObject;

            troopInitializer.GetTroopObject(out troopObject).Should().Be(Error.Ok);
            ITroopObject troopObject2;

            troopInitializer.GetTroopObject(out troopObject2).Should().Be(Error.Ok);

            troopObject.Should().BeSameAs(troopObject2);
        }
Exemple #2
0
        public void GetTroopObject_WhenStubIsNotStationed_ReturnsError(
            [Frozen] ITroopStub stub,
            StationedTroopObjectInitializer troopInitializer)
        {
            stub.State.Returns(TroopState.BattleStationed);

            ITroopObject troopObject;

            troopInitializer.GetTroopObject(out troopObject).Should().Be(Error.TroopNotStationed);
            troopObject.Should().BeNull();
        }
Exemple #3
0
        public void GetTroopObject_WhenAbleToRetreat_AddsNewTroopObjectToWorld(
            [Frozen] ITroopStub stub,
            [Frozen] IWorld world,
            StationedTroopObjectInitializer troopInitializer)
        {
            stub.State.Returns(TroopState.Stationed);
            stub.Station.Troops.RemoveStationed(Arg.Any <ushort>()).Returns(true);

            ITroopObject troopObject;

            troopInitializer.GetTroopObject(out troopObject).Should().Be(Error.Ok);
            world.Regions.Received(1).Add(troopObject);
        }
Exemple #4
0
        public void GetTroopObject_WhenCannotRemoveFromStationedCity_ReturnsError(
            [Frozen] ITroopStub stub,
            StationedTroopObjectInitializer troopInitializer)
        {
            stub.StationTroopId = 100;
            stub.State.Returns(TroopState.Stationed);
            stub.Station.Troops.RemoveStationed(100).Returns(false);

            ITroopObject troopObject;

            troopInitializer.GetTroopObject(out troopObject).Should().Be(Error.TroopNotStationed);
            troopObject.Should().BeNull();
        }
Exemple #5
0
        public void GetTroopObject_WhenAbleToRetreat_CreatesTroopObjectFromCity(
            [Frozen] ITroopStub stub,
            StationedTroopObjectInitializer troopInitializer)
        {
            stub.State.Returns(TroopState.Stationed);

            stub.Station.Troops.RemoveStationed(Arg.Any <ushort>()).Returns(true);

            stub.Station.PrimaryPosition.Returns(new Position(10, 20));

            ITroopObject troopObject;

            troopInitializer.GetTroopObject(out troopObject).Should().Be(Error.Ok);
            troopObject.Should().NotBeNull();
            stub.City.Received(1).CreateTroopObject(stub, 10, 21);
        }