public void Throws_ArgumentNullException_When_Called_With_StringEmpty_FolloweeId() { var mapperMock = new Mock <IMappingProvider>(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var repoMock = new Mock <IGenericRepository <Followee> >(); var twitterApiCallServiceMock = new Mock <ITwitterApiCallService>(); var dateTimeParserMock = new Mock <IDateTimeParser>(); var followees = new List <Followee> { new Followee { FolloweeId = "1", ScreenName = "justinT", Name = "Justin Trudeau" } }; mapperMock.Setup(x => x.MapTo <FolloweeDto>(followees[0])) .Returns(new FolloweeDto { FolloweeId = followees[0].FolloweeId }); repoMock.Setup(r => r.All).Returns(followees.AsQueryable()); unitOfWorkMock.Setup(u => u.Followees).Returns(repoMock.Object); var followeeService = new FolloweeService(unitOfWorkMock.Object, mapperMock.Object, twitterApiCallServiceMock.Object, dateTimeParserMock.Object); Assert.ThrowsException <ArgumentException>(() => followeeService.GetFolloweeById(string.Empty)); }
public void ReturnFollowee_WhenInvokedAnExistingInDbFolloweeId() { var mapperMock = new Mock <IMappingProvider>(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var repoMock = new Mock <IGenericRepository <Followee> >(); var twitterApiCallServiceMock = new Mock <ITwitterApiCallService>(); var dateTimeParserMock = new Mock <IDateTimeParser>(); var followees = new List <Followee> { new Followee { FolloweeId = "1", ScreenName = "justinT", Name = "Justin Trudeau" } }; mapperMock.Setup(x => x.MapTo <FolloweeDto>(followees[0])) .Returns(new FolloweeDto { FolloweeId = followees[0].FolloweeId }); repoMock.Setup(r => r.All).Returns(followees.AsQueryable()); unitOfWorkMock.Setup(u => u.Followees).Returns(repoMock.Object); var followeeService = new FolloweeService(unitOfWorkMock.Object, mapperMock.Object, twitterApiCallServiceMock.Object, dateTimeParserMock.Object); var cut = followeeService.GetFolloweeById("1"); Assert.AreEqual("1", cut.FolloweeId); }