private IActionProvider BuildAction(IEnumerable <VillageModel> villages)
        {
            var villageRepoMock = new Mock <IVillageRepository>();

            villageRepoMock.Setup(x => x.GetVillages(FakeDataProvider.TravianUserName))
            .Returns(Task.FromResult(villages));

            var buildingRepo = BuildingsProviderFake.GetBuildingRepository();

            var buildingPlanRepo = BuildingPlanProviderFake.GetBuildingRepository();

            return(new ActionProvider(_unitRepo, villageRepoMock.Object, buildingRepo, buildingPlanRepo, _mapper));
        }
Esempio n. 2
0
        public async Task TestBuildScenario()
        {
            var village = new Village
            {
                Name = "Unexpected_Town_11"
            };

            var buildingRepo = BuildingsProviderFake.GetBuildingRepository();
            var buildings    = (await buildingRepo.GetAllBuildings()).ToList();
            var woodcutter   = buildings.First(x => x.Name == "woodcutter");
            var action       = new BuildAction
            {
                Action       = GameActionType.BUILD,
                BuildingId   = woodcutter.BuildingId,
                BuildingSlot = "buildingSlot14",
                Village      = village
            };

            var scenario = new BuildScenario(provider, action);
            BaseScenarioResult result = new BaseScenarioResult();

            //Assert.DoesNotThrow(() =>
            //{
            //    result = scenario.Execute(new ScenarioContext { Player = player, Actions = new List<BuildAction>() });
            //});

            //Assert.AreEqual(0, result.Errors.Count);

            action = new BuildAction
            {
                Action       = GameActionType.BUILD,
                BuildingId   = buildings.First(x => x.Name == "warehouse").BuildingId,
                BuildingSlot = "a30",
                Village      = village
            };

            scenario = new BuildScenario(provider, action);
            result   = new BaseScenarioResult();
            //Assert.DoesNotThrow(() =>
            //{
            //    result = scenario.Execute(new ScenarioContext { Player = player, Actions = new List<BuildAction>() });
            //});

            //Assert.AreEqual(0, result.Errors.Count);

            var sawmill = buildings.First(x => x.Name == "granary");

            action = new BuildAction
            {
                Action       = GameActionType.BUILD,
                BuildingId   = sawmill.BuildingId,
                BuildingSlot = "aid21",//sawmill.PrefferedBuildingSlot,
                Village      = village
            };

            scenario = new BuildScenario(provider, action);
            result   = new BaseScenarioResult();
            Assert.DoesNotThrow(() =>
            {
                result = scenario.Execute(new ScenarioContext {
                    Player = player, Actions = new List <BuildAction>()
                });
            });

            Assert.AreEqual(0, result.Errors.Count);
        }