async Task <OneOf <Success, Banned> > IPostService.AddThread(Guid postId, Guid threadId, Guid boardId, string subject, TripCodedName name, string comment, bool isSage, IIpHash ipAddress, Option <File> file, CancellationToken cancellationToken) { if (await this.bannedIpRepository.IsBanned(ipAddress, cancellationToken)) { return(new Banned()); } var thread = new Thread(threadId, boardId, subject); await threadRepository.Add(thread).ConfigureAwait(false); var post = new Domain.Post(postId, threadId, DateTime.UtcNow, name.Val, comment, isSage, ipAddress.Val); await this.postRepository.Add(post).ConfigureAwait(false); await file.MapToTask(some => this.fileRepository.Add(some)); return(new Success()); }
public void GetOrderedThreads() { var boardId = Guid.NewGuid(); this.postRepository.Setup(a => a.GetAll()).Returns(new Post[] { }.AsQueryable()); this.boardRepository.Setup(a => a.GetByKey("bee", ct)).ReturnsT(Option.Some(new Board(boardId, "b", "bbb"))); var thread = new Thread(Guid.NewGuid(), boardId, "subject"); this.threadRepository.Setup(a => a.GetAll()). Returns(new TestAsyncEnumerable <Thread>(new List <Thread> { thread })); var r = ts.GetOrderedThreads("bee", Option.None <string>(), 100, 1, ct).Result; r.Should().NotBeNull(); repo.VerifyAll(); }