コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: IssueAccess.cs プロジェクト: SeriousM/BugTracker
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }