public async void Execute_WithCorrectModel_Successful() { var issueId = Guid.NewGuid(); // arrange var issueEntity = new Issue { Id = issueId, UserId = Guid.NewGuid(), Title = "title", Content = "content", IsClosed = false }; this.issueAccessMock .Setup(x => x.Get(issueId)) .Returns(issueEntity); var command = this.commandRepository.GetIssueById(issueId); // act var commandResult = await this.CommandExecutor.ExecuteAsync(command); // assert CommandAssert.IsSuccessful(commandResult); Assert.IsTrue(commandResult.SuccessData.Id.Equals(issueId)); }
public Issue Add(Guid userId, string title, string content) { Check.IsNotNull(nameof(title), title); Check.IsNotNull(nameof(content), content); var issueId = Guid.NewGuid(); var issue = new Issue { Id = issueId, UserId = userId, Title = title, Content = content, IsClosed = false, ReportDate = DateTime.UtcNow }; this.database.Add(issueId, issue); return issue; }
public void GetAllByUserId_KnownUserId_ReturnsFilledList() { // arrange var userId = Guid.NewGuid(); var issue = new Issue { Id = Guid.NewGuid(), UserId = userId }; var issues = new ReadOnlyDictionary<Guid, Issue>(new Dictionary<Guid, Issue> { { issue.Id, issue } }); this.databaseMock.Setup(x => x.GetAll<Issue>()).Returns(issues); // act var allIssuesForUser = this.issueAccess.GetAllByUserId(userId); // assert Assert.IsNotNull(allIssuesForUser); Assert.IsNotEmpty(allIssuesForUser); }
public async void Execute_WithCorrectModel_Successful() { // arrange var issueModel = new IssueModel { UserId = Guid.NewGuid(), Title = "title", Content = "content" }; User existingUser = new User { Id = issueModel.UserId }; this.userAccessMock .Setup(x => x.TryGetById(issueModel.UserId)) .Returns(new Maybe<User>(existingUser)); Issue newIssue = new Issue { Id = Guid.NewGuid() }; this.issueAccessMock .Setup(x => x.Add(issueModel.UserId, issueModel.Title, issueModel.Content)) .Returns(newIssue); var command = this.commandRepository.CreateNewIssue(issueModel); // act var commandResult = await this.CommandExecutor.ExecuteAsync(command); // assert CommandAssert.IsSuccessful(commandResult); Assert.AreEqual(newIssue.Id, commandResult.SuccessData.Id); }