public ScoreController( IMediator mediator, GameScoreService gameScoreService, GameService gameService) { this.mediator = mediator; this.gameScoreService = gameScoreService; this.gameService = gameService; }
async Task StartUrhoApp() { if (game == null) { game = await urhoSurface.Show <SamplyGame>(new ApplicationOptions(assetsFolder : AssetsPath) { Height = 1024, Width = 576, Orientation = ApplicationOptions.OrientationType.Portrait, ResourcePackagesPaths = ResourcePacksPaths }); game.FinishedGame += Game_FinishedGame; game.NewStartMenu += Game_NewStartMenu; game.RemovedStartMenu += Game_RemovedStartMenu; game.StartMenu.ShowSettingsClicked += StartMenu_ShowSettingsClicked; GameScoreService.InitFromSettings(); await ShowTopScores(game.StartMenu); } }
public async void GameScoreService_Create_Should_CallExactlyOnce_GameScoreRepository_SaveChangesAsyncMethod() { // Arrange var fakeScoreGame = new GameScore() { UserId = Guid.NewGuid().ToString(), UserEmail = Guid.NewGuid().ToString(), HighScore = 42 }; var mockGameScoreRepository = new Mock <IDeletableEntityRepository <GameScore> >(); var gameScoreService = new GameScoreService(mockGameScoreRepository.Object); // Act await gameScoreService.Create(fakeScoreGame.UserId, fakeScoreGame.UserEmail, fakeScoreGame.HighScore); // Assert mockGameScoreRepository.Verify(x => x.SaveChangesAsync(), Times.Once); }
public async void GameScoreService_Create_Should_CreateNewGameScores() { // Arrange var fakeScoreGame = new GameScore() { UserId = Guid.NewGuid().ToString(), UserEmail = Guid.NewGuid().ToString(), HighScore = 42 }; var mockGameScoreRepository = new Mock <IDeletableEntityRepository <GameScore> >(); var gameScoreService = new GameScoreService(mockGameScoreRepository.Object); // Act var newScoreGame = await gameScoreService.Create(fakeScoreGame.UserId, fakeScoreGame.UserEmail, fakeScoreGame.HighScore); // Assert Assert.Equal(fakeScoreGame.UserId, newScoreGame.UserId); Assert.Equal(fakeScoreGame.UserEmail, newScoreGame.UserEmail); Assert.Equal(fakeScoreGame.HighScore, newScoreGame.HighScore); }
public void GameScoreService_GetAll_Should_ReturnAllGameScores() { // Arrange var fakeData = new List <GameScore>() { new GameScore(), new GameScore(), new GameScore() }.AsQueryable(); var mockGameScoreRepository = new Mock <IDeletableEntityRepository <GameScore> >(); mockGameScoreRepository.Setup(x => x.All()).Returns(fakeData); var gameScoreService = new GameScoreService(mockGameScoreRepository.Object); // Act var allGameScores = gameScoreService.GetAll(); // Assert Assert.Equal(fakeData.Count(), allGameScores.Count()); }
public GameResultService(GameScoreService gameScoreService, KnowledgeUpdateService knowledgeUpdateService) { this.gameScoreService = gameScoreService; this.knowledgeUpdateService = knowledgeUpdateService; }
public SettingsPage() { Label header = new Label { Text = "Ethereum Settings", FontSize = 25, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center }; var cancelButton = new Button() { Text = "Cancel", VerticalOptions = LayoutOptions.CenterAndExpand, }; privKeyEntry = new Entry { Keyboard = Keyboard.Text, Placeholder = "Enter private key", VerticalOptions = LayoutOptions.End, Text = Settings.PrivateKeySetting, }; var urlEntry = new Entry { Keyboard = Keyboard.Text, Placeholder = "Enter url", VerticalOptions = LayoutOptions.End, Text = Settings.UrlSetting }; var saveButton = new Button() { Text = "Save", VerticalOptions = LayoutOptions.Fill, }; cancelButton.Clicked += async(sender, e) => await Navigation.PopModalAsync(); saveButton.Clicked += async(sender, e) => { bool passed = true; try { GameScoreService.Init(privKeyEntry.Text, urlEntry.Text); } catch { await DisplayAlert("Error", "There is an error with your private key, please check it", "OK"); passed = false; } if (passed) { Settings.PrivateKeySetting = privKeyEntry.Text; Settings.UrlSetting = urlEntry.Text; SettingsChanged?.Invoke(); await Navigation.PopModalAsync(); } }; // Build the page. this.Content = new StackLayout { Children = { header, new Label { Text = "Private Key", VerticalOptions = LayoutOptions.End }, privKeyEntry, new Label { Text = "Url", VerticalOptions = LayoutOptions.End }, urlEntry, cancelButton, saveButton }, VerticalOptions = LayoutOptions.CenterAndExpand }; }