protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue)); // Tooltip opened indefinitly until mouse is moved serviceProvider = Sidekick.Startup.InitializeServices(this); Legacy.Initialize(serviceProvider); Legacy.ViewLocator.Open <Windows.SplashScreen>(); await RunAutoUpdate(); EnsureSingleInstance(); await serviceProvider.GetService <IInitializer>().Initialize(); // Overlay. OverlayController.Initialize(); // League Overlay LeagueOverlayController.Initialize(); EventsHandler.Initialize(); // Price Prediction PredictionController.Initialize(); }
public void GetPrediction_With_Date_Supplied() { //Arrange //date is in September string date = "2020-09-14"; var controller = new PredictionController(MockWeatherEngine); //Act IHttpActionResult actionResult = controller.Get(date); var contentResult = actionResult as OkNegotiatedContentResult <RainfallResultViewModel>; //Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(MockRainfallResultViewModel1.MeanPrcp, contentResult.Content.MeanPrcp); Assert.AreEqual(MockRainfallResultViewModel1.StdDev, contentResult.Content.StdDev); //Arrange //date is in January date = "01-31-2021"; //Act actionResult = controller.Get(date); contentResult = actionResult as OkNegotiatedContentResult <RainfallResultViewModel>; //Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(MockRainfallResultViewModel2.MeanPrcp, contentResult.Content.MeanPrcp); Assert.AreEqual(MockRainfallResultViewModel2.StdDev, contentResult.Content.StdDev); }
public void SeparateEntriesForCreatedCards() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { "Alleycat" }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); opponent.KnownCards = CardList(new List <string> { "Alleycat" }); opponent.KnownCards[0].IsCreated = true; var info = GetPredictionInfo(controller); Assert.AreEqual(2, info.PredictedCards.Count); var originalCardInfo = info.PredictedCards[0]; Assert.AreEqual(0, originalCardInfo.NumPlayed); Assert.AreEqual(1, originalCardInfo.Card.Count); Assert.IsFalse(originalCardInfo.Card.IsCreated); var createdCardInfo = info.PredictedCards[1]; Assert.AreEqual(1, createdCardInfo.NumPlayed); Assert.AreEqual(1, createdCardInfo.Card.Count); Assert.IsTrue(createdCardInfo.Card.IsCreated); }
private PredictionInfo GetPredictionInfo(PredictionController controller) { PredictionInfo info = null; controller.OnPredictionUpdate.Add(p => info = p); controller.UpdatePrediction(); return(info); }
protected override void OnExit(ExitEventArgs e) { trayIcon?.Dispose(); serviceProvider.Dispose(); OverlayController.Dispose(); PredictionController.Dispose(); base.OnExit(e); }
public static List <double> CalculateAverageRMSE(string dirWithFiles, IEnumerable <IPredictionAlgorithm> algorithms, out double averagePredictionNum, out double averageActualPrice) { List <double> rmseValues = new List <double>(); List <List <double> > rmseLists = InitRmseLists(algorithms.Count()); string[] filesPath = System.IO.Directory.GetFiles(dirWithFiles); //IEnumerable<BasicDataset> predicted = PredictionController.Predict(filesPath[0], new MovingAverage, out IEnumerable<BasicDataset> datasets); int fileNum = 1; averagePredictionNum = 0; averageActualPrice = 0; foreach (string filePath in filesPath) { int alghNum = 0; try { foreach (IPredictionAlgorithm algorithm in algorithms) { IEnumerable <BasicDataset> predicted = PredictionController.Predict(filePath, algorithm, out IEnumerable <BasicDataset> datasets); datasets = datasets.OrderBy(a => a.Date); averagePredictionNum += predicted.Count(); ++fileNum; SplitSet(datasets, out IEnumerable <BasicDataset> trainingSet, out IEnumerable <BasicDataset> controlSet); averageActualPrice += controlSet.Select(a => (double)a.Close).Average(); double rmse = GetRMSEAnother(controlSet, predicted); rmseLists[alghNum++].Add(rmse); } } catch { } } foreach (List <double> rmseList in rmseLists) { rmseValues.Add(rmseList.Average()); } averagePredictionNum /= fileNum; averageActualPrice /= fileNum; return(rmseValues); }
public void CardPlayedNotInMetaDecksIsMarkedOffMeta() { var opponent = new MockOpponent("Hunter"); opponent.KnownCards = CardList(new List <string> { "Alleycat" }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); var info = GetPredictionInfo(controller); Assert.IsTrue(info.PredictedCards[0].OffMeta); }
public void OnOpponentHandDiscard_CallsOnPredictionUpdate() { var opponent = new MockOpponent("Hunter"); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); bool called = false; controller.OnPredictionUpdate.Add(prediction => called = true); controller.OnOpponentHandDiscard(null); Assert.IsTrue(called); }
public void CardPlayabilityAboveAvailableManaForNextTurn() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { "Deadly Shot" }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); var info = GetPredictionInfo(controller); Assert.AreEqual(PlayableType.AboveAvailableMana, info.PredictedCards[0].Playability); }
public void UpdatesWithNoDeckIfClassMismatch() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Mage", new List <string> { }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); var info = GetPredictionInfo(controller); Assert.AreEqual(0, info.NumPossibleDecks); }
public void GetPrediction_With_Invalid_Date_Supplied() { //Arrange string date = "2020-02-30"; var controller = new PredictionController(MockWeatherEngine); // Act IHttpActionResult actionResult = controller.Get(date); // Assert Assert.AreEqual(actionResult.ToString(), "System.Web.Http.Results.BadRequestErrorMessageResult"); Console.WriteLine(actionResult); }
public void UpdatesWithMetaDeck() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { "Deadly Shot" }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); var info = GetPredictionInfo(controller); Assert.AreEqual(1, info.NumPossibleDecks); }
public void OnOpponentDraw_SecondTimeDoesNotCallOnPredictionUpdate() { var opponent = new MockOpponent("Hunter"); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); controller.OnOpponentDraw(); bool called = false; controller.OnPredictionUpdate.Add(prediction => called = true); controller.OnOpponentDraw(); Assert.IsFalse(called); }
public void JoustedCardCanBeOffMeta() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { }); opponent.KnownCards = CardList(new List <string> { "Alleycat" }); opponent.KnownCards[0].Jousted = true; var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); var info = GetPredictionInfo(controller); Assert.IsTrue(info.PredictedCards[0].OffMeta); }
public void JoustedCardsAreAddedButPlayedCountIsZero() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { }); opponent.KnownCards = CardList(new List <string> { "Alleycat" }); opponent.KnownCards[0].Jousted = true; var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); var info = GetPredictionInfo(controller); Assert.AreEqual(0, info.PredictedCards[0].NumPlayed); }
public static void Process() { while (instance.pInputQueue.Count > 0) { DataMessage msg = instance.pInputQueue.Dequeue(); if (msg.dataType == DATAMESSAGE_TYPE.LATENCY_CHECK) { PredictionController.Instance().Process(msg as LatencyCheckMessage); } else { GameManager.RecieveMessage(msg); } } }
public void MarksCardsAlreadyPlayed() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { "Alleycat" }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); opponent.KnownCards = CardList(new List <string> { "Alleycat" }); var info = GetPredictionInfo(controller); Assert.AreEqual(1, info.PredictedCards[0].NumPlayed); }
public void UpdatesWithFullCardList() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { "Deadly Shot", "Alleycat", "Bear Trap" }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); var info = GetPredictionInfo(controller); CollectionAssert.AreEqual(CardList(new List <string> { "Deadly Shot", "Alleycat", "Bear Trap" }), CardsFromInfo(info)); }
public void BetShouldReturnViewWIthValidModel() { //Arrange var userManager = UserManagerMock.New; userManager.Setup(u => u.GetUserId(It.IsAny <ClaimsPrincipal>())) .Returns(userId); var predictionService = new Mock <IPredictionService>(); predictionService.Setup(p => p.GetActiveMatches(userId)) .Returns(new List <MatchServiceModel>() { firstMatch, secondMatch }.AsQueryable()); predictionService.Setup(r => r.GetActiveRoundNumber()). Returns(RoundNumber); predictionService.Setup(p => p.IsCurrentRoundPredicted(userId)) .Returns(false); var controller = new PredictionController(predictionService.Object, userManager.Object); Mapper.Initialize(); //Act var result = controller.Bet(); //Assert result.Should().BeOfType <ViewResult>(); var model = result.As <ViewResult>().Model; model.Should().BeOfType <ActiveRoundViewModel>(); var formModel = model.As <ActiveRoundViewModel>(); formModel.AlreadyPredicted.Should().Be(false); formModel.Matches.Count.Should().Be(1); formModel.StartedMatches.Count.Should().Be(1); formModel.Matches.First().HomeTeam.Should().Be(firstMatch.HomeTeam); formModel.Matches.First().AwayTeam.Should().Be(firstMatch.AwayTeam); formModel.StartedMatches.First().HomeTeam.Should().Be(secondMatch.HomeTeam); formModel.StartedMatches.First().AwayTeam.Should().Be(secondMatch.AwayTeam); formModel.RoundNumber.Should().Be(RoundNumber); }
public void SortEntriesByCreated() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { "Bear Trap" }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); opponent.KnownCards = CardList(new List <string> { "Bear Trap", "Bear Trap" }); opponent.KnownCards[0].IsCreated = true; var info = GetPredictionInfo(controller); Assert.IsFalse(info.PredictedCards[0].Card.IsCreated); }
public void SortEntriesByManaCost() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { "Alleycat" }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); opponent.KnownCards = CardList(new List <string> { "Bear Trap" }); opponent.KnownCards[0].IsCreated = true; var info = GetPredictionInfo(controller); Assert.AreEqual("Alleycat", info.PredictedCards[0].Card.Name); }
public void SecondOffMetaCardIncludedInPrediction() { AddMetaDeck("Hunter", new List <string> { "Alleycat" }); var opponent = new MockOpponent("Hunter"); opponent.KnownCards = CardList(new List <string> { "Alleycat" }, new List <int> { 2 }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); var info = GetPredictionInfo(controller); Assert.AreEqual(2, info.PredictedCards[0].Card.Count); }
public void GetPrediction_No_Date_Supplied() { //Arrange var controller = new PredictionController(MockWeatherEngine); // Act IHttpActionResult actionResult = controller.Get(); var contentResult = actionResult as OkNegotiatedContentResult <RainfallResultViewModel>; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); //since current date varies, we will just assert that we have some values for mean and std Assert.IsTrue(contentResult.Content.MeanPrcp > 0); Assert.IsTrue(contentResult.Content.StdDev > 0); }
public void AddsInCardsNotInMetaDecks() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); opponent.KnownCards = CardList(new List <string> { "Alleycat" }); var info = GetPredictionInfo(controller); CollectionAssert.AreEqual(CardList(new List <string> { "Alleycat" }), CardsFromInfo(info)); Assert.AreEqual(1, info.PredictedCards[0].NumPlayed); }
public void OnTurnStart_DoesNotUpdateAvailableManaOnOpponentTurn() { var opponent = new MockOpponent("Hunter"); opponent.Mana = 1; AddMetaDeck("Hunter", new List <string> { "Alleycat" }); AddMetaDeck("Hunter", new List <string> { "Alleycat", "Bear Trap" }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); opponent.Mana = 2; controller.OnTurnStart(ActivePlayer.Opponent); var info = GetPredictionInfo(controller); Assert.AreEqual(1, info.PredictedCards.Count); }
public void BetPostSuccessfulySavedScoreAndRedirectToGetBet() { // Arrange ActiveRoundViewModel model = GetActiveRoundViewModel(ResultEnum.DRAW); string successMessage = null; var tempData = new Mock <ITempDataDictionary>(); tempData .SetupSet(t => t[WebConstants.TempDataSuccessMessageKey] = It.IsAny <string>()) .Callback((string key, object message) => successMessage = message as string); var userManager = UserManagerMock.New; userManager.Setup(u => u.GetUserId(It.IsAny <ClaimsPrincipal>())) .Returns(userId); var predictionService = new Mock <IPredictionService>(); predictionService.Setup(p => p.GetCurrentActiveMatchesIds()) .Returns(new List <int>() { firstMatch.Id, secondMatch.Id }); predictionService.Setup(p => p.AddPrediction(null, null)); var controller = new PredictionController(predictionService.Object, userManager.Object); controller.TempData = tempData.Object; // Act var result = controller.Bet(model); // Assert result.Should().BeOfType <RedirectToActionResult>(); var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); redirectToActionResult.ControllerName.Should().Be(null); redirectToActionResult.ActionName.Should().BeEquivalentTo("Bet"); successMessage.Should().Be(MessageResources.msgSuccessfulPredictions); }
public void BetPostReturnViewWithModelWhenAnyNonPredictedMatch() { // Arrange string errorMessage = null; ActiveRoundViewModel model = GetActiveRoundViewModel(); var tempData = new Mock <ITempDataDictionary>(); tempData .SetupSet(t => t[WebConstants.TempDataErrorMessageKey] = It.IsAny <string>()) .Callback((string key, object message) => errorMessage = message as string); var controller = new PredictionController(null, null); controller.TempData = tempData.Object; // Act var result = controller.Bet(model); // Assert result.Should().BeOfType <ViewResult>(); var viewModel = result.As <ViewResult>().Model; viewModel.Should().BeOfType <ActiveRoundViewModel>(); var formModel = viewModel.As <ActiveRoundViewModel>(); formModel.AlreadyPredicted.Should().Be(false); formModel.Matches.Count.Should().Be(2); formModel.Matches.First().HomeTeam.Should().Be(firstMatch.HomeTeam); formModel.Matches.First().AwayTeam.Should().Be(firstMatch.AwayTeam); formModel.Matches.Last().HomeTeam.Should().Be(secondMatch.HomeTeam); formModel.Matches.Last().AwayTeam.Should().Be(secondMatch.AwayTeam); formModel.RoundNumber.Should().Be(RoundNumber); errorMessage.Should().Be(MessageResources.msgBetAllMatches); }
public void UpdatesWithMultipleCopies() { var opponent = new MockOpponent("Hunter"); AddMetaDeck("Hunter", new List <string> { "Alleycat", "Deadly Shot", "Bear Trap" }, new List <int> { 1, 2, 1 }); var controller = new PredictionController(opponent, _metaDecks.AsReadOnly()); var info = GetPredictionInfo(controller); var expectedCardList = CardList( new List <string> { "Alleycat", "Deadly Shot", "Bear Trap" }, new List <int> { 1, 2, 1 }); CollectionAssert.AreEqual(expectedCardList, CardsFromInfo(info)); }
private static IEnumerable <BasicDataset> GetPrediction(FileTransferRequest request) { IPredictionAlgorithm algorithm = ChosePredictionAlgorithm(request.SelectedAlgortihms); return(PredictionController.Predict(request.FileBytes, algorithm)); }