public GetNotifications ( int userInfoId ) : IEnumerable |
||
userInfoId | int | Integer value to get notifications |
Résultat | IEnumerable |
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."); }
public void GetNotificationsTest() { var mockRepository = MockRepository.GenerateMock<IGameSchoolEntities>(); var notificationService = new NotificationService(); notificationService.SetDatasource(mockRepository); int userInfoId = 1; var list = CreateNotificationList(userInfoId, 20); var userData = new FakeObjectSet<UserInfo>(); var userInfo = new UserInfo(); userInfo.Fullname = "Davíð Einarsson"; userInfo.Email = "*****@*****.**"; userInfo.StatusId = 1; userInfo.Username = "******"; userInfo.UserInfoId = userInfoId; userInfo.Password = "******"; userData.AddObject(userInfo); mockRepository.Expect(x => x.UserInfoes).Return(userData); mockRepository.Expect(x => x.Notifications).Return(list); var actualList = notificationService.GetNotifications(userInfoId); Assert.AreEqual(list.Count(), actualList.Count()); mockRepository.VerifyAllExpectations(); }