Example #1
0
        public async Task <bool> PostHighscore(CategoryScoreModel model)
        {
            var client = new HttpClient();

            var json = JsonConvert.SerializeObject(model);

            HttpContent content = new StringContent(json);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var response =
                await client.PostAsync("https://asestudyhelper.azurewebsites.net/api/CategoryScores", content);

            return(response.IsSuccessStatusCode);
        }
Example #2
0
        public async Task <bool> PutHighscore(CategoryScoreModel model)
        {
            var client = new HttpClient();

            var json = JsonConvert.SerializeObject(model);

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Settings.AccessToken);

            HttpContent content = new StringContent(json);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var response =
                await client.PutAsync("https://asestudyhelper.azurewebsites.net/api/CategoryScores/" + model.Id,
                                      content);

            return(response.IsSuccessStatusCode);
        }
Example #3
0
        public void updateHighScore_TotalScoreLesserThanHighScore_HighScoreDescriptionUpdated()
        {
            CategoryScoreModel testModel = new CategoryScoreModel();

            testModel.Category  = uut_.CompletedQuiz.Category;
            testModel.HighScore = 1000;
            List <CategoryScoreModel> testList = new List <CategoryScoreModel>()
            {
                testModel
            };

            uut_.TotalScore = 100;

            fakeService_.GetHighScoreForCurrentUser().ReturnsForAnyArgs(testList);

            uut_.updateHighScore();

            Assert.That(uut_.HighScoreUpdatedDescription, Is.EqualTo(""));
        }
Example #4
0
        public void updateHighScore_TotalScoreGreaterThanHighScore_HighScoreDescriptionUpdated()
        {
            CategoryScoreModel testModel = new CategoryScoreModel();

            testModel.Category  = uut_.CompletedQuiz.Category;
            testModel.HighScore = 0;
            List <CategoryScoreModel> testList = new List <CategoryScoreModel>()
            {
                testModel
            };

            uut_.TotalScore = 1000;

            string comparisonString = $"Tillykke du har slået din egen highscore for {uut_.CompletedQuiz.Category} på {testModel.HighScore}";

            fakeService_.GetHighScoreForCurrentUser().ReturnsForAnyArgs(testList);

            uut_.updateHighScore();

            Assert.That(uut_.HighScoreUpdatedDescription, Is.EqualTo(comparisonString));
        }