Пример #1
0
 /// <summary>
 /// Adds running history from feature files to the backend DB.
 /// </summary>
 /// <param name="listOfRunningHistory"> Running history to add. </param>
 public void AddFitBitRunningHistory(List <Activities> listOfRunningHistory)
 {
     using var context = new DataRetrievalContext(contextOptions);
     context.FitBitActivityItems.RemoveRange(context.FitBitActivityItems);
     context.FitBitActivityItems.AddRange(listOfRunningHistory);
     context.SaveChanges();
 }
Пример #2
0
 /// <summary>
 /// Adds listening history from feature files to the backend DB.
 /// </summary>
 /// <param name="listOfListeningHistory"> Listening history to add. </param>
 public void AddSpotifyListeningHistory(List <PlayHistoryItem> listOfListeningHistory)
 {
     using var context = new DataRetrievalContext(contextOptions);
     context.PlayHistoryItems.RemoveRange(context.PlayHistoryItems);
     context.PlayHistoryItems.AddRange(listOfListeningHistory);
     context.SaveChanges();
 }
Пример #3
0
 /// <summary>
 /// Adds listening history from feature files to the backend DB.
 /// </summary>
 /// <param name="listOfListeningHistory">Listening history to add.</param>
 public void AddLastFMListeningHistory(List <LastTrack> listOfListeningHistory)
 {
     using var context = new DataRetrievalContext(contextOptions);
     context.LastTracks.RemoveRange(context.LastTracks);
     context.LastTracks.AddRange(listOfListeningHistory);
     context.SaveChanges();
 }
 protected void RegisterFitBitHistory(List <FakeResponseServer.Models.FitBit.Activities> fitBitHistory)
 {
     using var context = new DataRetrievalContext(contextOptions);
     context.FitBitActivityItems.RemoveRange(context.FitBitActivityItems);
     context.FitBitActivityItems.AddRange(fitBitHistory);
     context.SaveChanges();
 }
 protected void RegisterLastFMTracks(List <FakeResponseServer.Models.LastFM.LastTrack> trackHistory)
 {
     using var context = new DataRetrievalContext(contextOptions);
     context.LastTracks.RemoveRange(context.LastTracks);
     context.LastTracks.AddRange(trackHistory);
     context.SaveChanges();
 }
 protected void RegisterActivityHistory(List <FakeResponseServer.Models.Strava.Activity> activityHistory)
 {
     using var context = new DataRetrievalContext(contextOptions);
     context.ActivityHistoryItems.RemoveRange(context.ActivityHistoryItems);
     context.ActivityHistoryItems.AddRange(activityHistory);
     context.SaveChanges();
 }
 protected void RegisterMusicHistory(List <FakeResponseServer.Models.Spotify.PlayHistoryItem> playHistory)
 {
     using var context = new DataRetrievalContext(contextOptions);
     context.PlayHistoryItems.RemoveRange(context.PlayHistoryItems);
     context.PlayHistoryItems.AddRange(playHistory);
     context.SaveChanges();
 }
        public void SetUp()
        {
            contextOptions = new DbContextOptionsBuilder <DataRetrievalContext>()
                             .UseInMemoryDatabase("StravaActivityControllerDatabase")
                             .Options;

            using var context = new DataRetrievalContext(contextOptions);
            var now_UTC   = DateTime.UtcNow;
            var now_local = DateTime.Now;

            activity1.start_date          = now_UTC;
            activity1.start_date_local    = now_local;
            activity2.start_date          = now_UTC;
            activity2.start_date_local    = now_local;
            DTOActivity1.start_date       = now_UTC;
            DTOActivity1.start_date_local = now_local;
            DTOActivity2.start_date       = now_UTC;
            DTOActivity2.start_date_local = now_local;

            activityHistory.Add(DTOActivity1);
            activityHistory.Add(DTOActivity2);

            context.ActivityHistoryItems.Add(activity1);
            context.ActivityHistoryItems.Add(activity2);
            context.SaveChanges();
        }
Пример #9
0
        public void SetUp()
        {
            contextOptions = new DbContextOptionsBuilder <DataRetrievalContext>()
                             .UseInMemoryDatabase("SpotifyMusicControllerTestDatabase")
                             .Options;

            using var context = new DataRetrievalContext(contextOptions);
            var now = DateTime.UtcNow;

            item1.PlayedAt    = now.AddDays(-2);
            item2.PlayedAt    = now.AddDays(-3);
            item3.PlayedAt    = now;
            DTOItem1.PlayedAt = now.AddDays(-2);
            DTOItem2.PlayedAt = now.AddDays(-3);
            DTOItem3.PlayedAt = now;

            listeningHistory.Add(DTOItem1);
            listeningHistory.Add(DTOItem2);
            listeningHistory.Add(DTOItem3);

            context.PlayHistoryItems.Add(item1);
            context.PlayHistoryItems.Add(item2);
            context.PlayHistoryItems.Add(item3);

            context.SaveChanges();
        }
        public void SetUp()
        {
            contextOptions = new DbContextOptionsBuilder <DataRetrievalContext>()
                             .UseInMemoryDatabase("FitBitActivityControllerDatabase")
                             .Options;

            using var context = new DataRetrievalContext(contextOptions);
            var now_UTC = DateTime.UtcNow;

            ContextFitBitActivity1.LastModified      = now_UTC;
            ContextFitBitActivity1.OriginalStartTime = now_UTC;
            ContextFitBitActivity1.StartTime         = now_UTC;

            ContextFitBitActivity2.LastModified      = now_UTC;
            ContextFitBitActivity2.OriginalStartTime = now_UTC;
            ContextFitBitActivity2.StartTime         = now_UTC;

            DTOFitBitActivity1.LastModified      = now_UTC;
            DTOFitBitActivity1.OriginalStartTime = now_UTC;
            DTOFitBitActivity1.StartTime         = now_UTC;

            DTOFitBitActivity2.LastModified      = now_UTC;
            DTOFitBitActivity2.OriginalStartTime = now_UTC;
            DTOFitBitActivity2.StartTime         = now_UTC;

            listOfActivities.Add(DTOFitBitActivity1);
            listOfActivities.Add(DTOFitBitActivity2);

            context.FitBitActivityItems.Add(ContextFitBitActivity1);
            context.FitBitActivityItems.Add(ContextFitBitActivity2);
            context.SaveChanges();
        }
Пример #11
0
        public void SetUpTests()
        {
            HttpClient httpClient;
            var        databaseRoot = new InMemoryDatabaseRoot();

            contextOptions = new DbContextOptionsBuilder <DataRetrievalContext>()
                             .UseInMemoryDatabase(DatabaseName, databaseRoot)
                             .Options;

            var webAppFactory = new InMemoryFactory <FakeResponseServer.Startup>(DatabaseName, databaseRoot);

            httpClient = webAppFactory.CreateClient(FakeServerAddress);
            var dataSource = new FakeDataRetrievalSource(new FakeResponseServer.Controllers.ExternalAPICaller(httpClient), FakeServerAddress);

            sut = new ExternalAPIGateway(dataSource);

            var externalAPICaller = new FakeResponseServer.Controllers.ExternalAPICaller(httpClient);

            var now_UTC   = DateTime.UtcNow;
            var now_local = DateTime.Now;
            var offset    = -2;

            foreach (var item in PlayHistoryItems)
            {
                item.PlayedAt = now_UTC.AddDays(offset);
                offset++;
            }

            foreach (var item in ActivityHistory)
            {
                item.start_date       = now_UTC;
                item.start_date_local = now_local;
            }

            foreach (var item in FitBitActivityItems)
            {
                item.StartTime         = now_UTC;
                item.OriginalStartTime = now_UTC;
                item.LastModified      = now_UTC;
            }

            offset = -1;
            foreach (var item in LastFMTrackItems)
            {
                item.TimePlayed = now_UTC.AddDays(offset);
                offset++;
            }

            using var context = new DataRetrievalContext(contextOptions);
            context.PlayHistoryItems.RemoveRange(context.PlayHistoryItems);
            context.PlayHistoryItems.AddRange(PlayHistoryItems);
            context.ActivityHistoryItems.RemoveRange(context.ActivityHistoryItems);
            context.ActivityHistoryItems.AddRange(ActivityHistory);
            context.FitBitActivityItems.RemoveRange(context.FitBitActivityItems);
            context.FitBitActivityItems.AddRange(FitBitActivityItems);
            context.LastTracks.RemoveRange(context.LastTracks);
            context.LastTracks.AddRange(LastFMTrackItems);
            context.SaveChanges();

            fakeDataRetrievalSource = new FakeDataRetrievalSource(externalAPICaller, FakeServerAddress);
            sut = MakeSut();
        }