public async Task GetByIdShouldReturnCorrectPost() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext); var applicationUser = new EfDeletableEntityRepository <ApplicationUser>(dbContext); var pictureRepository = new EfRepository <UserProfilePicture>(dbContext); var repositoryComment = new EfDeletableEntityRepository <NewsFeedComment>(dbContext); var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var post = new NewsFeedPost { Id = 1, Content = "test", UserId = "1", }; await repositoryNewsFeedPost.AddAsync(post); await repositoryNewsFeedPost.SaveChangesAsync(); var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository); AutoMapperConfig.RegisterMappings(typeof(GetByIdTestViewModel).GetTypeInfo().Assembly); var postResult = await service.GetByIdAsync <GetByIdTestViewModel>(post.Id); Assert.Equal(post.Id, postResult.Id); }
public async Task CreateCoverPictureAsyncShouldCreateCorrectly() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext); var applicationUser = new EfDeletableEntityRepository <ApplicationUser>(dbContext); var pictureRepository = new EfRepository <UserProfilePicture>(dbContext); var repositoryComment = new EfDeletableEntityRepository <NewsFeedComment>(dbContext); var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var userPicture = new UserCoverPicture { PictureURL = "mountain.jpg", ApplicationUserId = "1", }; var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository); var createResult = service.CreateCoverPictureAsync(userPicture.ApplicationUserId, userPicture.PictureURL); Assert.Equal(1, coverPictureRepository.All().Count()); }
public async Task GetAllNewsFeedPostPerPageShouldReturnCorrectCount() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext); var applicationUser = new EfDeletableEntityRepository <ApplicationUser>(dbContext); var pictureRepository = new EfRepository <UserProfilePicture>(dbContext); var repositoryComment = new EfDeletableEntityRepository <NewsFeedComment>(dbContext); var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var posts = this.NewsFeedPostSeeder(5, DateTime.UtcNow); foreach (var post in posts) { await repositoryNewsFeedPost.AddAsync(post); } await repositoryNewsFeedPost.SaveChangesAsync(); var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository); AutoMapperConfig.RegisterMappings(typeof(GetAllNewsFeedPostPerPageTestViewModel).GetTypeInfo().Assembly); var postResult = service.GetAllSocialPosts <GetAllNewsFeedPostPerPageTestViewModel>(1); Assert.Equal(4, postResult.Count()); }
public async Task <List <BlogDescription> > FetchBlog(string url) { var blogList = new List <BlogDescription>(); var newsFeedService = new NewsFeedService(url); var syndicationItems = await newsFeedService.GetNewsFeed(); foreach (var syndicationItem in syndicationItems) { var description = syndicationItem.Description.Substring(0, Math.Min(200, syndicationItem.Description.Length)); var time = syndicationItem.Published; var uri = syndicationItem.Links.FirstOrDefault()?.Uri; if (time < syndicationItem.LastUpdated) { time = syndicationItem.LastUpdated; } blogList.Add(new BlogDescription() { Title = syndicationItem.Title, Description = description, Time = time.DateTime, Url = uri?.AbsoluteUri }); } return(blogList); }
public ActionResult NewsFeed(int id) { NewsFeedService newsFeedService = new NewsFeedService(); var items = newsFeedService.GetNewsFeedItems(id); return(View(items)); }
public void GetPostsCountByUserShouldReturnCorrectCount() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext); var applicationUser = new EfDeletableEntityRepository <ApplicationUser>(dbContext); var pictureRepository = new EfRepository <UserProfilePicture>(dbContext); var repositoryComment = new EfDeletableEntityRepository <NewsFeedComment>(dbContext); var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var post = new NewsFeedPost { Content = "test", UserId = "1", }; var secondPost = new NewsFeedPost { Content = "testTwo", UserId = "1", }; var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository); var postResult = service.CreateAsync(post.Content, post.UserId); var secondPostResult = service.CreateAsync(secondPost.Content, secondPost.UserId); var postCount = service.GetPostsCountByUser(post.UserId); Assert.Equal(2, postCount); }
public ActionResult Index() { ViewBag.Message = "Your application description page."; NewsFeedService newsFeedService = new NewsFeedService(); var newsFeedAboDto = newsFeedService.GetNewsFeeds(); return(View(newsFeedAboDto)); }
/// <summary> /// Initializes a new instance of the <see cref="EmailScheduler"/> class. /// </summary> public EmailScheduler(NewsFeedService newsFeedService, UserService userService, IUsersContextFactory usersContextFactory, NewsLetterNotification notification) : base(Name) { this.newsFeedService = newsFeedService; this.userService = userService; this.usersContextFactory = usersContextFactory; this.notification = notification; }
public void HavingACurrentCultureDifferentThanEnglishShouldNotThrows() { CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("es-AR"); NewsFeedService newsFeedService = new NewsFeedService(); Thread.CurrentThread.CurrentCulture = currentCulture; }
public void CreateClass_ObjectConstructing_ObjectConstructedOK() { //Arrange //Act var target = new NewsFeedService(_discordMock, _settings, _webClient); //Assert Assert.NotNull(target); }
public void SelectElementText_SelectingCssElement_ElementContentReturned() { //Arrange var targetContent = "Target content"; var target = new NewsFeedService(_discordMock, _settings, _webClient); var html = $"<div>Test<ul><li>Nest</li><li>Bar</li></ul><footer>{targetContent}</footer></div>"; //Act var selectedContent = target.SelectElementText(html, "footer"); //Assert Assert.Equal(targetContent, selectedContent); }
static void Main(string[] args) { var newsFeedService = new NewsFeedService(); var feeds = newsFeedService.GetNewsFeeds(); foreach (var feed in feeds) { var rss = FeedLoader(feed.FeedUrl); var parser = new RdfParser(); var newsfeedItem = parser.Parse(feed, rss); newsFeedService.StoreFeedItems(newsfeedItem); newsFeedService.UpdateAbo(feed); } }
public void GetNewContent_ExtractingNewContent_NewContentReturned() { //Arrange var target = new NewsFeedService(_discordMock, _settings, _webClient); //Act var content = target.GetNewsItem(); //Assert Assert.NotNull(content); Assert.Equal("Fresh Prince", content.Header); Assert.Equal("https://www.vg.no/test/img/fresh.jpg", content.ImageUrl); Assert.Equal("This is a story all about how my life got flipped right upside down.", content.Text); Assert.Equal("https://www.vg.no/test", content.LinkUrl); }
public void RaiseChangeEvent_HandlingChangeEvent_ChangeEventHandled() { //Arrange var target = new NewsFeedService(_discordMock, _settings, _webClient); //Act // ((MockWebClientWrapper)_webClient.UpsertUrlContent("https://www.vg.no", _newsListPage.Replace("Value to check", "Changed value")); Thread.Sleep(_settings.CheckInterval + 100); var channelMock = _discordMock.GetChannel(1); var message = ((IMessageChannel)channelMock).GetMessageAsync(1).GetAwaiter().GetResult(); //Assert Assert.NotNull(message); Assert.Equal(1, message.Embeds.Count); }
public async Task UserInfoUpdateShouldWorkCorrectly() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext); var applicationUser = new EfDeletableEntityRepository <ApplicationUser>(dbContext); var pictureRepository = new EfRepository <UserProfilePicture>(dbContext); var repositoryComment = new EfDeletableEntityRepository <NewsFeedComment>(dbContext); var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var user = new ApplicationUser { Id = "1", FirstName = "Ventsi", LastName = "Ignatov", Email = "*****@*****.**", UserName = "******", BirthDay = DateTime.UtcNow, Town = "Barcelona", }; var userWithUpdatedInfo = new ApplicationUser { Id = "1", FirstName = "Ventsislav", LastName = "Ignatov", Email = "*****@*****.**", UserName = "******", BirthDay = DateTime.UtcNow, Town = "Madrid", }; await applicationUser.AddAsync(user); await applicationUser.SaveChangesAsync(); var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository); var result = service.EditProfileAsync(userWithUpdatedInfo, user.Id); }
public async Task GetLastCoverPictureShouldReturnLastPicture() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext); var applicationUser = new EfDeletableEntityRepository <ApplicationUser>(dbContext); var pictureRepository = new EfRepository <UserProfilePicture>(dbContext); var repositoryComment = new EfDeletableEntityRepository <NewsFeedComment>(dbContext); var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var firstUserPicture = new UserCoverPicture { PictureURL = "mountain.jpg", ApplicationUserId = "1", }; var secondUserPicture = new UserCoverPicture { PictureURL = "mountain2.jpg", ApplicationUserId = "1", }; await coverPictureRepository.AddAsync(firstUserPicture); await coverPictureRepository.AddAsync(secondUserPicture); await coverPictureRepository.SaveChangesAsync(); var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository); var result = await service.LastCoverPictureAsync("1"); var resultWhenIsNull = await service.LastCoverPictureAsync("2"); Assert.Equal(secondUserPicture.PictureURL, result); Assert.Null(resultWhenIsNull); }
public void BuildDiscordEmbed_BuildingFromNewsItem_DiscordEmbedReturned() { //Arrange var target = new NewsFeedService(_discordMock, _settings, _webClient); var newsItem = new NewsItem { Header = "Test header", LinkUrl = "https://www.neon.gg/", Text = "Neon is a guild on Karazhan EU. We are brand new, and looking for members to clear the first wing in ICC. We only do 10 man raiding and stuff.", ImageUrl = "https://www.neon.gg/exampleimage.png" }; //Act var embed = target.BuildDiscordEmbed(newsItem); //Assert Assert.NotNull(embed); Assert.Equal(newsItem.Header, embed.Title); Assert.Equal(newsItem.ImageUrl, embed.Image.ToString()); Assert.Equal(newsItem.LinkUrl, embed.Url); Assert.Equal(newsItem.Text, embed.Description); }
public async Task GetFriendsForUserShouldReturnCorrectCount() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext); var applicationUser = new EfDeletableEntityRepository <ApplicationUser>(dbContext); var pictureRepository = new EfRepository <UserProfilePicture>(dbContext); var repositoryComment = new EfDeletableEntityRepository <NewsFeedComment>(dbContext); var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var firstFiend = new Friend { SenderId = "1", ReceiverId = "2", }; var secondFriend = new Friend { SenderId = "1", ReceiverId = "4", }; await friendRepository.AddAsync(firstFiend); await friendRepository.AddAsync(secondFriend); await friendRepository.SaveChangesAsync(); var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository); var result = await service.GetFriendCountAsync(firstFiend.SenderId); Assert.Equal(2, result); }
public async Task GetAllCoverPicturesAsyncShouldReturnCorrectCount() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repositoryNewsFeedPost = new EfDeletableEntityRepository <NewsFeedPost>(dbContext); var applicationUser = new EfDeletableEntityRepository <ApplicationUser>(dbContext); var pictureRepository = new EfRepository <UserProfilePicture>(dbContext); var repositoryComment = new EfDeletableEntityRepository <NewsFeedComment>(dbContext); var coverPictureRepository = new EfRepository <UserCoverPicture>(dbContext); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var userPicture = new UserCoverPicture { PictureURL = "mountain.jpg", ApplicationUserId = "1", }; var secondUserPicture = new UserCoverPicture { PictureURL = "mountainTwo.jpg", ApplicationUserId = "1", }; var service = new NewsFeedService(repositoryNewsFeedPost, applicationUser, pictureRepository, repositoryComment, coverPictureRepository, friendRepository); var firstPictureResult = service.CreateCoverPictureAsync(userPicture.ApplicationUserId, userPicture.PictureURL); var secondPictureResult = service.CreateCoverPictureAsync(secondUserPicture.ApplicationUserId, secondUserPicture.PictureURL); AutoMapperConfig.RegisterMappings(typeof(GetAllCoverPictureForUserViewModel).GetTypeInfo().Assembly); var resultCount = await service.GetAllCoverPicturesAsync <GetAllCoverPictureForUserViewModel>(userPicture.ApplicationUserId); Assert.Equal(2, resultCount.Count()); }
public HomeController(ILogger <HomeController> logger, NewsFeedService newsService) { _logger = logger; _newsService = newsService; }
public object Get(bool?onlySubscribed, int?providerId) { NewsFeedService service = new NewsFeedService(); return(service.getNewsFeeds(onlySubscribed, providerId)); }
public FeedController(NewsFeedService newsService) { _newsService = newsService; }
public NewsViewComponent(NewsFeedService newsService) { this.newsService = newsService; }
public NewsFeedFragment() { newsFeedService = new NewsFeedService(); }