public void Init()
 {
     _trackerRepository = new TrackerRepository();
     _eventRepository   = new EventRepository();
     _eventService      =
         new EventService(_eventRepository, _trackerRepository,
                          EventFiltrationDapperRepository()); //TODO replace by in memory repository
     _tracker = TestingMethods.CreateTrackerWithDefaultCustomization(Guid.NewGuid());
     _event   = TestingMethods.CreateEvent(_tracker.Id, _tracker.CreatorId);
 }
        public void GetAllTrackerEventsWhenTrackerHasNoEvents_ReturnsEmptyCollection()
        {
            var tracker = TestingMethods.CreateTrackerWithDefaultCustomization(Guid.NewGuid(), "Tracker");

            _trackerRepository.SaveTracker(tracker);
            const int expected = 0;

            var events = _eventService.GetAllTrackerEvents(tracker.CreatorId, tracker.Id);

            Assert.AreEqual(expected, events.Count);
        }
Exemple #3
0
        public void GetFactsFromTrackerWithoutEvents_ReturnsEmptyFactsCollection()
        {
            InitializeFactProviderWithCalculators();
            var       tracker = TestingMethods.CreateTrackerWithDefaultCustomization(Guid.NewGuid());
            var       emtyEventsCollection = new List <Event>();
            const int expected             = 0;

            var facts = _factProvider
                        .GetFacts(new [] { new TrackerWithItsEvents(tracker, emtyEventsCollection) });

            Assert.AreEqual(expected, facts.Count);
        }
Exemple #4
0
        public void GetAllUserTrackers_ReturnsUserTrackers()
        {
            var userId   = Guid.NewGuid();
            var tracker1 = TestingMethods.CreateTrackerWithDefaultCustomization(userId);
            var tracker2 = TestingMethods.CreateTrackerWithDefaultCustomization(userId);

            _trackerRepository.SaveTracker(tracker1);
            _trackerRepository.SaveTracker(tracker2);
            const int expected = 2;

            var actual = _trackerRepository.LoadAllUserTrackers(userId).Count();

            Assert.AreEqual(expected, actual);
        }
Exemple #5
0
        public void GetFactsFromTrackerWithEvents_ReturnsFacts()
        {
            InitializeFactProviderWithCalculators();
            var       tracker  = TestingMethods.CreateTrackerWithDefaultCustomization(Guid.NewGuid());
            var       event1   = TestingMethods.CreateEvent(tracker.Id, tracker.CreatorId);
            var       event2   = TestingMethods.CreateEvent(tracker.Id, tracker.CreatorId);
            const int expected = 2;

            var facts = _factProvider
                        .GetFacts(new [] { new TrackerWithItsEvents(tracker, new [] { event1, event2 }) });
            var firstFact  = facts.First();
            var secondFact = facts.Last();

            Assert.AreEqual(expected, facts.Count);
            Assert.AreEqual("Самая насыщенная событиями неделя", firstFact.FactName);
            Assert.AreEqual("Самый насыщенный событиями день", secondFact.FactName);
        }
Exemple #6
0
 public void Init()
 {
     _trackerRepository = new TrackerRepository();
     _trackerService    = new TrackerService(_trackerRepository);
     _tracker           = TestingMethods.CreateTrackerWithDefaultCustomization(Guid.NewGuid());
 }