Ejemplo n.º 1
0
        public void GetTracker_UserGetsSomeonesTracker_DidNotGetTracker()
        {
            var someonesTracker = EntityMaker.CreateSomeTracker(Guid.NewGuid(), _mockTrackerRepository);

            var askedTracker = _trackerService.GetTracker(_userId, someonesTracker.Id);

            Assert.IsFalse(askedTracker.IsSome);
        }
Ejemplo n.º 2
0
        public void GetUserTrackers_UserGetsOwnTrackers_GotTrackers()
        {
            var tracker = EntityMaker.CreateSomeTracker(_userId, _mockTrackerRepository);

            var trackers = _trackerService.GetUserTrackers(_userId);

            Assert.AreEqual(tracker.Title, trackers.ElementAt(0).Title);
        }
Ejemplo n.º 3
0
        public void GetTracker_UserGetsOwnTracker_GotTracker()
        {
            var userTracker = EntityMaker.CreateSomeTracker(_userId, _mockTrackerRepository);

            var askedTracker = _trackerService.GetTracker(_userId, userTracker.Id);

            Assert.IsTrue(askedTracker.IsSome);
            Assert.AreEqual(userTracker.Title, askedTracker.ValueUnsafe().Title);
        }
Ejemplo n.º 4
0
        public void DeleteTracker_UserDeletesOwnTracker_TrackerWasDeleted()
        {
            var userTracker = EntityMaker.CreateSomeTracker(_userId, _mockTrackerRepository);

            _trackerService.DeleteTracker(_userId, userTracker.Id);

            var trackers = _mockTrackerRepository.GetAll();

            Assert.AreEqual(0, trackers.Count);
        }
Ejemplo n.º 5
0
        public void DeleteTracker_UserDeletesSomeonesTracker_TrackerWasNotDeleted()
        {
            var someonesTracker = EntityMaker.CreateSomeTracker(_someonesId, _mockTrackerRepository);

            _trackerService.DeleteTracker(_userId, someonesTracker.Id);

            var trackers = _mockTrackerRepository.GetAll();

            Assert.AreEqual(1, trackers.Count);
            Assert.AreEqual(someonesTracker.Title, trackers.ElementAt(0).Title);
        }
Ejemplo n.º 6
0
        public void EditTracker_UserEditsSomeonesTracker_TrackerWasNotEdited()
        {
            var someonesTracker    = EntityMaker.CreateSomeTracker(_someonesId, _mockTrackerRepository);
            var trackerEditingForm = _fixture.Create <TrackerForm>();

            _trackerService.EditTracker(_userId, someonesTracker.Id, trackerEditingForm);

            var trackers = _mockTrackerRepository.GetAll();

            Assert.AreEqual(someonesTracker.Title, trackers.ElementAt(0).Title);
        }
Ejemplo n.º 7
0
        public void BiggestDayOverallStatsFact_TooFewEvents_FactIsNone()
        {
            var tracker = EntityMaker.CreateSomeTracker(Guid.NewGuid(), _mockTrackerRepository);

            EntityMaker.CreateSomeEvent(tracker.Id, _mockEventRepository);

            var statsFact = new BiggestDayOverallStatsFact()
                            .Apply(_mockEventRepository.GetAll());

            Assert.IsTrue(statsFact.IsNone);
        }
Ejemplo n.º 8
0
        public void LongestBreakStatsFact_OnlyOneEvent_FactIsNone()
        {
            var tracker = EntityMaker.CreateSomeTracker(Guid.NewGuid(), _mockTrackerRepository);

            EntityMaker.CreateSomeEvent(tracker.Id, _mockEventRepository);

            var statsFact = new LongestBreakStatsFact()
                            .Apply(_mockEventRepository.GetAll());

            Assert.IsTrue(statsFact.IsNone);
        }
Ejemplo n.º 9
0
        public void BiggestDayOverallStatsFact_TwoEventsToday_CorrectEventsCountAndDay()
        {
            var tracker = EntityMaker.CreateSomeTracker(Guid.NewGuid(), _mockTrackerRepository);

            EntityMaker.CreateSomeEvent(tracker.Id, _mockEventRepository);
            EntityMaker.CreateSomeEvent(tracker.Id, _mockEventRepository);

            var statsFact = new BiggestDayOverallStatsFact()
                            .Apply(_mockEventRepository.GetAll());

            Assert.AreEqual(2, ((BiggestDayOverallStatsFact)statsFact.ValueUnsafe()).EventsCount);
            Assert.AreEqual(DateTime.Now.Date,
                            ((BiggestDayOverallStatsFact)statsFact.ValueUnsafe()).BiggestDay);
        }
Ejemplo n.º 10
0
        public void AddCommentToEvent_UserAddsCommentToOwnEventWithCorrectFormAndEventNotExists_CommentNotAdded()
        {
            var userId  = Guid.NewGuid();
            var tracker = EntityMaker.CreateSomeTracker(userId, _mockTrackerRepository);

            tracker.Customizations.Add(CustomizationType.Comment);
            _mockTrackerRepository.Update(tracker);
            var form = _fixture.Create <CommentForm>();

            _customizationService.AddCommentToEvent(userId, Guid.NewGuid(), form);

            var comments = _mockCommentRepository.GetAll();

            Assert.AreEqual(0, comments.Count);
        }
Ejemplo n.º 11
0
        public void AddCommentToEvent_UserAddsCommentToOwnEventWithNullFormAndEventExists_CommentNotAdded()
        {
            var userId  = Guid.NewGuid();
            var tracker = EntityMaker.CreateSomeTracker(userId, _mockTrackerRepository);

            tracker.Customizations.Add(CustomizationType.Comment);
            _mockTrackerRepository.Update(tracker);
            var @event = EntityMaker.CreateSomeEvent(tracker.Id, _mockEventRepository);

            _customizationService.AddCommentToEvent(userId, @event.Id, null);

            var comments = _mockCommentRepository.GetAll();

            Assert.AreEqual(0, comments.Count);
        }
Ejemplo n.º 12
0
        public void BestTrackerEventStatsFact_OneEvent_CorrectBestEventRatingAndTitle()
        {
            var tracker          = EntityMaker.CreateSomeTracker(Guid.NewGuid(), _mockTrackerRepository);
            var eventsWithRating = new Dictionary <Event, int>();
            var event1           = EntityMaker.CreateSomeEvent(tracker.Id, _mockEventRepository);

            eventsWithRating.Add(event1, 5);

            var statsFact = new BestTrackerEventStatsFact()
                            .Apply(eventsWithRating);

            Assert.AreEqual(5, ((BestTrackerEventStatsFact)statsFact.ValueUnsafe()).Rating);
            Assert.AreEqual(event1.Title,
                            ((BestTrackerEventStatsFact)statsFact.ValueUnsafe()).Event.Title);
        }
        public void SetUp()
        {
            _fixture               = new Fixture();
            _mockUserRepository    = new RepositoryMock <User>();
            _mockTrackerRepository = new RepositoryMock <Tracker>();
            _mockEventRepository   = new RepositoryMock <Event>();

            _userOne = EntityMaker.CreateSomeUser(_mockUserRepository, "userOne");
            _userTwo = EntityMaker.CreateSomeUser(_mockUserRepository, "userTwo");

            _trackerUserOne = EntityMaker.CreateSomeTracker(_userOne.Id, _mockTrackerRepository);
            _trackerUserTwo = EntityMaker.CreateSomeTracker(_userTwo.Id, _mockTrackerRepository);

            _eventService = new EventService(_mockEventRepository, _mockTrackerRepository);
        }
Ejemplo n.º 14
0
        public void AddCommentToEvent_UserAddsCommentButNoCommentCustomizationTypeInTracker_CommentNotAdded()
        {
            var userId  = Guid.NewGuid();
            var tracker = EntityMaker.CreateSomeTracker(userId, _mockTrackerRepository);

            tracker.Customizations.Add(CustomizationType.Photo);
            _mockTrackerRepository.Update(tracker);
            var @event = EntityMaker.CreateSomeEvent(tracker.Id, _mockEventRepository);
            var form   = _fixture.Create <CommentForm>();

            _customizationService.AddCommentToEvent(userId, @event.Id, form);

            var comments = _mockCommentRepository.GetAll();

            Assert.AreEqual(0, comments.Count);
        }
Ejemplo n.º 15
0
        public void BestTrackerEventStatsFact_TwoEventsWithSameRating_FactIsNone()
        {
            var tracker          = EntityMaker.CreateSomeTracker(Guid.NewGuid(), _mockTrackerRepository);
            var eventsWithRating = new Dictionary <Event, int>();
            var event1           = EntityMaker.CreateSomeEvent(tracker.Id, _mockEventRepository);

            eventsWithRating.Add(event1, 5);
            var event2 = EntityMaker.CreateSomeEvent(tracker.Id, _mockEventRepository);

            eventsWithRating.Add(event2, 5);

            var statsFact = new BestTrackerEventStatsFact()
                            .Apply(eventsWithRating);

            Assert.IsTrue(statsFact.IsNone);
        }
Ejemplo n.º 16
0
        public void LongestBreakStatsFact_TwoEventsWithThreeDaysBreak_CorrectBreak()
        {
            var tracker = EntityMaker.CreateSomeTracker(Guid.NewGuid(), _mockTrackerRepository);
            var date1   = new DateTime(2020, 1, 1, 1, 0, 0);
            var date2   = new DateTime(2020, 1, 4, 2, 0, 0);
            var event1  = new Event(Guid.NewGuid(), tracker.Id, "Event1", date1, date1);
            var event2  = new Event(Guid.NewGuid(), tracker.Id, "Event2", date2, date2);

            _mockEventRepository.Save(event1);
            _mockEventRepository.Save(event2);

            var statsFact = new LongestBreakStatsFact()
                            .Apply(_mockEventRepository.GetAll());

            Assert.AreEqual(3, ((LongestBreakStatsFact)statsFact).Break.Days);
        }