Ru.GameSchool.BusinessLayer.Services.NotificationService.GetNotifications C# (CSharp) Method

GetNotifications() public method

Returns a collection of notification objects that are related to a given userinfo instance id, if the userinfoid is equal to or larger then 1.
public GetNotifications ( int userInfoId ) : IEnumerable
userInfoId int Integer value to get notifications
return IEnumerable
        public IEnumerable<Notification> GetNotifications(int userInfoId)
        {
            if (userInfoId <= 0)
                return null;

            if (GameSchoolEntities.UserInfoes.Where(x => x.UserInfoId == userInfoId).Count() != 1)
                throw new GameSchoolException(string.Format("User does not exist. UserInfoId = {0}", userInfoId));

            var list = GameSchoolEntities.Notifications.Where(n => n.UserInfoId == userInfoId);

            return list.OrderByDescending(x=>x.NotificationId);
        }

Usage Example

        public void GetNotifications_NotValidUser_Test()
        {
            var mockRepository = MockRepository.GenerateMock<IGameSchoolEntities>();
            var notificationService = new NotificationService();
            notificationService.SetDatasource(mockRepository);

            int userInfoId = 1;

            var list = CreateNotificationList(userInfoId, 20);

            mockRepository.Expect(x => x.UserInfoes).Return(new FakeObjectSet<UserInfo>());
            mockRepository.Expect(x => x.Notifications).Return(list);

            notificationService.GetNotifications(userInfoId);

            mockRepository.VerifyAllExpectations();

            Assert.Fail("The unit test should never get here.");
        }
All Usage Examples Of Ru.GameSchool.BusinessLayer.Services.NotificationService::GetNotifications