Пример #1
0
        public void GetStravaActivityWithAllParams_CorrectActivityHistoryReturned()
        {
            sut = MakeSut();
            var tokenAsJson = sut.GetStravaAuthenticationToken();

            tokenAsJson.Value.Should().NotBeNull();
            var stravaAuthToken = JsonConvert.DeserializeObject <StravaAuthenticationToken>((string)tokenAsJson.Value);

            stravaAuthToken.access_token.Should().NotBeNullOrEmpty();

            var startDate = DateTime.UtcNow.AddDays(-1);
            var endDate   = DateTime.UtcNow.AddDays(1);

            var activityHistory = sut.GetStravaRecentActivities(stravaAuthToken.access_token, startDate, endDate);

            activityHistory.Value.Should().NotBeNull();
            var activityHistoryExtracted = JsonConvert.SerializeObject(activityHistory.Value);
            var actualActivityHistory    = JsonConvert.DeserializeObject <List <StravaActivity> >(activityHistoryExtracted);

            actualActivityHistory.Count.Should().Be(2);

            var alternativeActivityHistory          = sut.GetStravaRecentActivities(stravaAuthToken.access_token, startDate.AddDays(7), endDate.AddDays(-7));
            var alternativeActivityHistoryExtracted = JsonConvert.SerializeObject(alternativeActivityHistory.Value);
            var alternativeActualActivityHistory    = JsonConvert.DeserializeObject <List <StravaActivity> >(alternativeActivityHistoryExtracted);

            alternativeActualActivityHistory.Count.Should().Be(0);
        }
Пример #2
0
        public void GetStravaAuthenticationToken_AuthenticationTokenReturned()
        {
            sut = MakeSut();
            var tokenAsJson = sut.GetStravaAuthenticationToken();

            tokenAsJson.Value.Should().NotBeNull();
            var stravaAuthToken = JsonConvert.DeserializeObject <StravaAuthenticationToken>((string)tokenAsJson.Value);

            stravaAuthToken.access_token.Should().NotBeNullOrEmpty();
        }
        /// <inheritdoc/>
        public void GetRecentStravaActivities()
        {
            var authToken                = externalAPIGateway.GetStravaAuthenticationToken().Value;
            var actualToken              = JsonConvert.DeserializeObject <StravaAuthenticationToken>((string)authToken);
            var searchresult             = externalAPIGateway.GetStravaRecentActivities(actualToken.access_token);
            var activityHistoryContainer = (List <StravaActivity>)searchresult.Value;

            foreach (var activity in activityHistoryContainer)
            {
                searchResults.Add(activity);
            }
        }
Пример #4
0
        public void GetStravaActivityHistory_ActivityHistoryReturned()
        {
            sut = MakeSut();
            var tokenAsJson = sut.GetStravaAuthenticationToken();

            tokenAsJson.Value.Should().NotBeNull();
            var stravaAuthToken = JsonConvert.DeserializeObject <StravaAuthenticationToken>((string)tokenAsJson.Value);

            stravaAuthToken.access_token.Should().NotBeNullOrEmpty();

            var activityHistory = sut.GetStravaRecentActivities(stravaAuthToken.access_token);

            activityHistory.Value.Should().NotBeNull();
            var activityHistoryExtracted = JsonConvert.SerializeObject(activityHistory.Value);
            var actualActivityHistory    = JsonConvert.DeserializeObject <List <StravaActivity> >(activityHistoryExtracted);

            actualActivityHistory.Count.Should().Be(2);
            actualActivityHistory[0].average_speed.Should().Be(12.35);
        }