public void Should_return_null_when_get_community_using_id_2_is_not_found() { var communityRepo = Substitute.For <ICommunityRepository>(); communityRepo.GetCommunity(Arg.Is(2)).Returns(Task.FromResult <CommunityModel>(null)); var communityService = new CommunityService(communityRepo); var result = communityService.GetCommunity(2).Result; result.Should().BeNull(); }
protected override async Task OnInitializedAsync() { Community = await CommunityService.GetCommunity(CommunityId); LoadDeveloper(); if (Community.Posts.Count() != 0) { Post = Community.Posts.FirstOrDefault(); Developer = Developers.FirstOrDefault(); } Courses = await CourseService.GetCourses(); }
protected async override Task OnInitializedAsync() { LoadDeveloper(); Community = await CommunityService.GetCommunity(CommunityId); AllPosts = Community.Posts.OrderByDescending(d => d.Time); Title = Community.Name + " Posts"; if (AllPosts == null || AllPosts.Count() == 0) { AllPosts = (await CommunityService.GetAllPosts()).ToList().OrderByDescending(d => d.Time); Title = "All Posts"; } PostsCount = AllPosts.Count(); PageCount = PostsCount / 9; Posts = AllPosts.Skip(PageNumber * PageSize).Take(PageSize); }
public async void AddPostDialog_OnDialogClose() { LoadDeveloper(); Community = await CommunityService.GetCommunity(CommunityId); if (Community.Posts.Count() != 0) { Post = Community.Posts.OrderByDescending(d => d.Time).FirstOrDefault(); Developer = Developers.FirstOrDefault(); } if (Post != null && Post.Image != null && Post.Image.Contains("wwwroot")) { Logo = Post.Image.Split("wwwroot"); Path = Post.Image.Split("wwwroot"); } StateHasChanged(); }
protected override async Task OnInitializedAsync() { Community = await CommunityService.GetCommunity(CommunityId); LoadDeveloper(); if (Community.Posts.Count() != 0) { Post = Community.Posts.OrderByDescending(d => d.Time).FirstOrDefault(); Developer = Developers.FirstOrDefault(); } if (Post != null && Post.Image != null && Post.Image.Contains("wwwroot")) { Logo = Post.Image.Split("wwwroot"); Path = Post.Image.Split("wwwroot"); } Courses = (await CourseService.GetCourses()).ToList().TakeLast(3); }
public void Should_return_community_with_id_2_when_get_community_using_id_2() { var communities = _fixture.Build <CommunityModel>() .CreateMany(5); var communityWithIdTwo = _fixture.Build <CommunityModel>() .With(x => x.Id, 2) .Create(); communities.ToList().Add(communityWithIdTwo); var communityRepo = Substitute.For <ICommunityRepository>(); communityRepo.GetCommunity(Arg.Is(2)).Returns(communityWithIdTwo); var communityService = new CommunityService(communityRepo); var result = communityService.GetCommunity(2).Result; result.Should().BeOfType <CommunityModel>(); result.Name.Should().Be(communityWithIdTwo.Name); }
protected override async Task OnInitializedAsync() { var community = await CommunityService.GetCommunity(CommunityId); Developers = community.Developers; }