public void Add() { var postId = Guid.NewGuid(); var threadId = Guid.NewGuid(); var ip = new IpUnHashed("127.0.0.1"); this.fileRepository.Setup(a => a.GetImageCount(threadId, ct)).ReturnsT(1); this.postRepository.Setup(a => a.GetThreadPostCount(threadId, ct)).ReturnsT(1); this.bannedIpRepository.Setup(a => a.IsBanned(ip, ct)).ReturnsT(false); this.postRepository.Setup(a => a.Add(It.IsAny <Domain.Post>())).Returns(Task.CompletedTask); this.ps.Add(postId, threadId, new TripCodedName("Matt"), "comment", false, ip, Option.None <File>(), ct).Wait(); this.repo.VerifyAll(); }
public void AddFailTooManyImages() { var postId = Guid.NewGuid(); var threadId = Guid.NewGuid(); var ip = new IpUnHashed("127.0.0.1"); this.fileRepository.Setup(a => a.GetImageCount(threadId, ct)).ReturnsT(200); this.bannedIpRepository.Setup(a => a.IsBanned(ip, ct)).ReturnsT(false); var r = this.ps.Add(postId, threadId, new TripCodedName("Matt"), "comment", false, ip, Option.None <File>(), ct).Result; r.AsT2.Should().NotBeNull(); this.repo.VerifyAll(); }
public void NotAddThreadWhenBanned() { var postId = Guid.NewGuid(); var threadId = Guid.NewGuid(); var boardId = Guid.NewGuid(); var ip = new IpUnHashed("127.0.0.1"); this.bannedIpRepository.Setup(a => a.IsBanned(ip, ct)).ReturnsT(true); var r = this.ps.AddThread(postId, threadId, boardId, "subject", new TripCodedName("Matt"), "comment", false, ip, Option.None <File>(), ct).Result; r.IsT1.Should().BeTrue(); this.repo.VerifyAll(); }
public void AddThread() { var postId = Guid.NewGuid(); var threadId = Guid.NewGuid(); var boardId = Guid.NewGuid(); var ip = new IpUnHashed("127.0.0.1"); this.bannedIpRepository.Setup(a => a.IsBanned(ip, ct)).ReturnsT(false); this.postRepository.Setup(a => a.Add(It.IsAny <Domain.Post>())).Returns(Task.CompletedTask); this.threadRepository.Setup(a => a.Add(It.IsAny <Domain.Thread>())).Returns(Task.CompletedTask); var r = this.ps.AddThread(postId, threadId, boardId, "subject", new TripCodedName("Matt"), "comment", false, ip, Option.None <File>(), ct).Result; r.IsT0.Should().BeTrue(); this.repo.VerifyAll(); }