public void GetNewNotificationsFor_AllNotificationsRead_ShouldNotBeReturned()
        {
            var gig = new Gig {
                Artist = new ApplicationUser()
                {
                    Id = "2", Name = "TestArtist"
                }, Id = 1
            };
            var notification = Notification.GigCreated(gig);
            var userId       = "1";
            var user         = new ApplicationUser()
            {
                Id = userId
            };


            var userNotification = new UserNotification(user, notification);

            userNotification.Read();

            _mockUserNotifications.SetSource(new[] { userNotification });

            var result = _repository.GetNewNotificationsFor(userId);

            result.Should().BeEmpty();
        }
예제 #2
0
        public void Read_WhenCalled_ShouldSetIsReadToTrue()
        {
            var userNotification = new UserNotification();

            userNotification.Read();

            userNotification.IsRead.Should().Be(true);
        }
예제 #3
0
        public void Read_WhenCalled_ShouldSetIsReadToTrue()
        {
            var userNotification = new UserNotification(new ApplicationUser(), new Notification());

            userNotification.Read();

            userNotification.IsRead.Should().BeTrue();
        }
예제 #4
0
        public void Read_WhenCalled_IsReadTrue()
        {
            var userNotification = new UserNotification(
                new ApplicationUser(),
                Notification.AppointmentCreated(new Appointment()));

            userNotification.Read();

            userNotification.IsRead.Should().Be(true);
        }
        public void GetNewNotificationsFor_NotificationIsRead_ShouldNotBeReturned()
        {
            var notification     = Notification.GigCanceled(new Gig());
            var user             = new ApplicationUser();
            var userNotification = new UserNotification(user, notification);

            userNotification.Read();

            _mockUserNotification.SetSource(new[] { userNotification });

            var result = _repository.GetUserNotifications(user.Id);

            result.Should().BeEmpty();
        }
예제 #6
0
        public void GetNewNotificationFor_NotificationIsRead_ShouldNotReturn()
        {
            var notification = Notification.GigCanceled(new Gig());
            var user         = new ApplicationUser {
                Id = "1"
            };
            var userNotification = new UserNotification(user, notification);

            userNotification.Read();
            _mockNotifications.SetSource(new[] { userNotification });

            var notifications = _repository.GetNewNotificationsFor(user.Id);

            notifications.Should().BeEmpty();
        }
        public void GetUnreadNotifications_NotificationIsRead_ShouldNotBeReturned()
        {
            var user = new ApplicationUser {
                Id = "1"
            };
            var userNotification = new UserNotification(user, Notification.GigCreated(new Gig()));

            userNotification.Read();

            _mockUserNotifications.SetSource(new[] { userNotification });

            var notifications = _repository.GetUnreadNotifications(user.Id);

            notifications.Should().BeEmpty();
        }
        public void GetNewNotificationNumFor_NotificationIsRead_ShouldNotBeReturned()
        {
            var notification = Notification.GigCancelled(new Gig());
            var user         = new ApplicationUser {
                Id = "1"
            };
            var userNotification = new UserNotification(user, notification);

            userNotification.Read();

            _mockUserNotifications.SetSource(new UserNotification[] { userNotification });

            var result = _repository.GetNewNotificationNumFor(user.Id);

            result.ShouldBeEquivalentTo(0);
        }
        public void GetUnreadNotificationsFor_NotificationsForTheGivenUserIsRead_ShouldNotBeReturned()
        {
            var notification = Notification.GigCancelled(new Gig());
            var user         = new ApplicationUser {
                Id = "1"
            };
            var userNotification = new UserNotification(user, notification);

            userNotification.Read();

            _mockUserNotifications.SetSource(new UserNotification[] { userNotification });

            var result = _repository.GetUnreadNotificationsFor(user.Id);

            result.Should().BeEmpty();
        }
예제 #10
0
        public void GetNewNotificationsFor_NotificationIsRead_ShouldNotBeReturned()
        {
            var notification = Notification.EventCanceled(new Event());
            // Install-Package Microsoft.AspNet.Identity.EntityFramework
            var user = new ApplicationUser {
                Id = "1"
            };
            var userNotification = new UserNotification(user, notification);

            userNotification.Read();

            _mockNotifications.SetSource(new[] { userNotification });
            var notifications = _repository.GetNewNotificationsFor(user.Id);

            notifications.Should().BeEmpty();
        }
        public void GetNewNotificationsFor_NotificationRead_ShouldNotReturn()
        {
            var user             = new ApplicationUser();
            var notification     = Notification.AppointmentCreated(new Appointment());
            var userNotification = new UserNotification(user, notification);

            userNotification.Read();

            _mockNotification.SetSource(new[] { userNotification });

            _mockContext.SetupGet(c => c.UserNotifications).Returns(_mockNotification.Object);

            var result = _repository.GetNewNotificationsFor(user.Id);

            result.Should().BeEmpty();
        }
예제 #12
0
        public void GetNewNotificationsFor_AllNotificationsAreRead_ShouldNotBeReturn()
        {
            var notification = Notification.GigCreated(new Gig());
            var user         = new ApplicationUser()
            {
                Id = _userId, Email = "*****@*****.**"
            };
            var userNotification = new UserNotification(user, notification);

            userNotification.Read();

            _mockNotifications.SetSource(new[] { notification });
            _mockUserNotifications.SetSource(new[] { userNotification });

            var result = _repository.GetNewNotificationsFor(_userId);

            result.Should().BeEmpty();
        }
예제 #13
0
        public void GetNewNotificationsFor_NotificationIsRead_ShouldNotBeReturned()
        {
            var notification = Notification.GigCanceled(new Gig());
            var user         = new ApplicationUser()
            {
                Id = "1231"
            };
            var userNotification = new UserNotification(user, notification);

            userNotification.Read();

            _mockUserNotification.SetSource(new[] { userNotification });
            _mockContext.Setup(r => r.UserNotifications).Returns(_mockUserNotification.Object);

            var notifications = _notificationRepository.GetNewNotificationsFor(user.Id);

            notifications.Should().BeEmpty();
        }
        public void GetUserNotificationFor_ValidIdRead_ShouldntReturn()
        {
            var user = new ApplicationUser()
            {
                Id = "1"
            };

            var userNotification = new UserNotification(user, Notification.AppointmentCreated(new Appointment()));

            userNotification.Read();

            _mockUserNotification.SetSource(new[] { userNotification });

            _mockContext.SetupGet(c => c.UserNotifications).Returns(_mockUserNotification.Object);

            var result = _repository.GetUserNotificationsFor(user.Id);

            result.Count().Should().Be(0);
        }
예제 #15
0
        public void GetNewNotificationsFor_NotificationIsRead_ShouldNotBeReturned()
        {
            // Setup - create a notification
            var notification = Notification.CoopCanceled(new Coop());             // the notification obj
            var user         = new ApplicationUser {
                Id = "1"
            };                                                               // the user associated with the notification obj
            var userNotification = new UserNotification(user, notification); // the user's notification

            userNotification.Read();                                         // set the user's notification to read

            // Setup - use extension method to populate mock DbSet with this Notification object
            _mockNotifications.SetSource(new[] { userNotification });

            // Act - try to get notification
            var notifications = _repository.GetNewNotificationsFor(user.Id);

            // Assert - notifications should be empty
            notifications.Should().BeEmpty();
        }