public void UpdateUserFactsWhenUserHasNoUpdatedTrackers_FactsInRepositoryNotUpdated() { var generalFact = CreateGeneralFact(); _multipleFactsRepository.CreateUserGeneralFacts(_tracker.CreatorId, new[] { generalFact }); var specificFact = CreateSpecificFact(); _singleFactsRepository.CreateTrackerSpecificFacts(_tracker.Id, _tracker.CreatorId, new[] { specificFact }); _tracker.IsUpdated = false; _trackerRepository.UpdateTracker(_tracker); _statisticGenerator.UpdateUserFacts(_tracker.CreatorId); var loadedGeneralFact = _multipleFactsRepository.ReadUserGeneralFacts(_tracker.CreatorId); var loadedSpecificFact = _singleFactsRepository.ReadTrackerSpecificFacts(_tracker.CreatorId, _tracker.Id); Assert.AreEqual(generalFact.GetHashCode(), loadedGeneralFact.First().GetHashCode()); Assert.AreEqual(specificFact.GetHashCode(), loadedSpecificFact.First().GetHashCode()); }
public void GetMultipleTrackersFactsGoodCase_ReturnFacts() { var multipleTrackerFact = CreateGeneralFact(); _trackerRepository.SaveTracker(_tracker); _multipleFactsRepository.CreateUserGeneralFacts(_tracker.CreatorId, new [] { multipleTrackerFact }); var facts = _statisticsService.GetMultipleTrackersFacts(_tracker.CreatorId); Assert.AreEqual(multipleTrackerFact.GetHashCode(), facts.First().GetHashCode()); }
private void UpdateUserGeneralFacts(Guid userId, IEnumerable <EventTracker> userTrackers) { var trackersWithEvents = new List <TrackerWithItsEvents>(); foreach (var tracker in userTrackers) { var events = _eventRepository.LoadAllTrackerEvents(tracker.Id); trackersWithEvents.Add(new TrackerWithItsEvents(tracker, events)); } var updatedFacts = _generalFactProvider.GetFacts(trackersWithEvents); _multipleFactsRepository.CreateUserGeneralFacts(userId, updatedFacts); }