public async Task TestBaseScenario() { // test data should be loaded from a local file var player = new Player { }; var login = new Mock <IScenario>(); login.Setup(x => x.Execute(It.IsAny <ScenarioContext>())) .Returns(new BaseScenarioResult()); var watch = new Mock <IScenario>(); watch.Setup(x => x.Execute(It.IsAny <ScenarioContext>())) .Returns(new BaseScenarioResult()); var check = new Mock <IScenario>(); check.Setup(x => x.Execute(It.IsAny <ScenarioContext>())) .Returns(new BaseScenarioResult()); var provider = new Mock <IWebDriverProvider>(); Mock <IScenarioFactory> factory = new Mock <IScenarioFactory>(); var logger = new Mock <ILogger <GameplayApi> >(); factory.Setup(x => x.GetScenario <WatchScenario>()).Returns(watch.Object); factory.Setup(x => x.GetScenario <CheckReportsScenario>()).Returns(check.Object); var executor = new ScenarioExecutor(); var api = new GameplayApi(executor, factory.Object, logger.Object); await api.Watch(player); login.Verify(x => x.Execute(It.IsAny <ScenarioContext>()), Times.Once); }
public ScenarioRunner(ScenarioExecutor scenarioExecutor, IMetadataProvider metadataProvider, IScenarioProgressNotifier progressNotifier, Func <Exception, ExecutionStatus> exceptionToStatusMapper) { _scenarioExecutor = scenarioExecutor; _metadataProvider = metadataProvider; _progressNotifier = progressNotifier; _exceptionToStatusMapper = exceptionToStatusMapper; }
public ScenarioRunner(ScenarioExecutor scenarioExecutor, IMetadataProvider metadataProvider, IScenarioProgressNotifier progressNotifier, ExceptionProcessor exceptionProcessor) { _scenarioExecutor = scenarioExecutor; _metadataProvider = metadataProvider; _progressNotifier = progressNotifier; _exceptionProcessor = exceptionProcessor; }
static BDTestServiceProvider() { InitialiseBDTest(); var scenarioRetryManager = new ScenarioRetryManager(); ScenarioExecutor = new ScenarioExecutor(scenarioRetryManager); }
public FeatureRunner(Type featureType, IntegrationContext integrationContext) { _featureType = featureType; _integrationContext = integrationContext; _featureResult = new FeatureResult(_integrationContext.MetadataProvider.GetFeatureInfo(featureType)); _scenarioExecutor = new ScenarioExecutor(new ExtendableExecutor(integrationContext.ExecutionExtensions)); _scenarioExecutor.ScenarioExecuted += _featureResult.AddScenario; integrationContext.FeatureProgressNotifier.NotifyFeatureStart(_featureResult.Info); }
public void TestRunMultipleScenariosAtOnce() { var user1 = new Player { UserName = "******" }; var user2 = new Player { UserName = "******" }; var user3 = new Player { UserName = "******" }; var results = new List <string>(); Func <ScenarioContext, BaseScenarioResult> execute = inp => { Task.Delay(1000 + new Random().Next(2000)).Wait(); results.Add(inp.Player.UserName); return(new BaseScenarioResult { Messages = new List <string> { inp.Player.UserName } }); }; var watch = new Mock <IScenario>(); var updateUserInfo = new Mock <IScenario>(); watch.Setup(x => x.Execute(It.IsAny <ScenarioContext>())) .Returns(execute); var check = new Mock <IScenario>(); var provider = new Mock <IWebDriverProvider>(); var factory = new Mock <IScenarioFactory>(); factory.Setup(x => x.GetScenario <WatchScenario>()).Returns(watch.Object); factory.Setup(x => x.GetScenario <CheckReportsScenario>()).Returns(check.Object); factory.Setup(x => x.GetScenario <UpdateUserInfoScenario>()).Returns(updateUserInfo.Object); var executor = new ScenarioExecutor(); var logger = new Mock <ILogger <GameplayApi> >(); var api = new GameplayApi(executor, factory.Object, logger.Object); var tasks = Task.WhenAll(api.Watch(user1), api.Watch(user3), api.Watch(user2)); tasks.Wait(); Assert.AreEqual(3, results.Count); Assert.AreEqual("user1", results[0]); Assert.AreEqual("user3", results[1]); Assert.AreEqual("user2", results[2]); }
public async Task TestWatchScenario() { var factory = new ScenarioFactory(provider); var executor = new ScenarioExecutor(); var api = new GameplayApi(executor, factory, logger.Object); BaseScenarioResult result = await api.Watch(player); Assert.IsTrue(result.IsUserUnderAttack); Assert.IsTrue(result.Success); }
public async Task TestCheckReportsScenario() { var factory = new ScenarioFactory(provider); var executor = new ScenarioExecutor(); var api = new GameplayApi(executor, factory, logger.Object); BaseScenarioResult result = await api.Watch(player); Assert.IsTrue(result.IsUserUnderAttack); Assert.IsTrue(result.Success); Assert.AreEqual("No scan events found", result.Messages.FirstOrDefault()); }
public async Task TestIncomingAttackScenario() { var factory = new ScenarioFactory(provider); var executor = new ScenarioExecutor(); var api = new GameplayApi(executor, factory, logger.Object); BaseScenarioResult result = await api.Scan(player, false); Assert.IsTrue(result.IsUserUnderAttack); Assert.IsTrue(result.Villages.Count > 0); Assert.IsNotNull(result.Villages.FirstOrDefault()); Assert.IsTrue(result.Villages.FirstOrDefault().IsUnderAttack); Assert.IsTrue(result.Villages.FirstOrDefault().Attacks.Any()); }
public void TestPrepareToAttackScenarios() { var factory = new ScenarioFactory(provider); var executor = new ScenarioExecutor(); var api = new GameplayApi(executor, factory, logger.Object); var village = new Village { Name = "Unex_Test_Village" }; var to = new Village { CoordinateX = -46, CoordinateY = 33 }; var actions = new List <GameAction> { new SendResourcesAction { Village = village, To = to, Action = GameActionType.SEND_RESOURCES }, new TrainArmyAction() { Village = village, Action = GameActionType.TRAIN_ARMY, UnitsToTrain = new Dictionary <string, int> { { "Фаланга", 1 } } }, new SendArmyAction() { Village = village, To = to, Action = GameActionType.SEND_ARMY, UnitsToSend = new Dictionary <string, int> { { "Фаланга", 1 } }, Type = SendArmyType.RAID } }; Assert.DoesNotThrow(() => api.RunScenarioWithActions(player, actions).Wait()); }
public ScenarioExecutorTests() { _sut = new ScenarioExecutor(_featureFileRepository.Object); }