public async Task GetVersionControlArtifactInfoAsync_Success() { // Arrange const int userId = 1; var session = new Session { UserId = userId }; const int itemId = 10; var vcArtifactInfo = new VersionControlArtifactInfo(); var mockArtifactVersionsRepository = new Mock <IArtifactVersionsRepository>(); mockArtifactVersionsRepository.Setup(r => r.GetVersionControlArtifactInfoAsync(itemId, null, userId)).ReturnsAsync(vcArtifactInfo); var artifactVersionsController = new ArtifactVersionsController(mockArtifactVersionsRepository.Object, null) { Request = new HttpRequestMessage() }; artifactVersionsController.Request.Properties[ServiceConstants.SessionProperty] = session; // Act var result = await artifactVersionsController.GetVersionControlArtifactInfoAsync(itemId, null); // Assert Assert.AreSame(vcArtifactInfo, result); }
public async Task GetArtifactHistory_Success() { // Arrange const int artifactId = 1; const int projectId = 10; var itemInfo = new ItemInfo { ProjectId = projectId, ArtifactId = artifactId, ItemId = artifactId }; var permisionDictionary = new Dictionary <int, RolePermissions>(); var resultSet = new ArtifactHistoryResultSet { ArtifactId = artifactId }; permisionDictionary.Add(artifactId, RolePermissions.Read); _artifactPermissionsRepositoryMock.Setup(m => m.GetItemInfo(artifactId, _session.UserId, true, int.MaxValue)).ReturnsAsync(itemInfo); _artifactPermissionsRepositoryMock.Setup(m => m.GetArtifactPermissions(It.IsAny <IEnumerable <int> >(), _session.UserId, false, int.MaxValue, true, null)).ReturnsAsync(permisionDictionary); _artifactVersionsRepositoryMock.Setup(m => m.GetArtifactVersions(artifactId, DEFAULT_LIMIT, DEFAULT_OFFSET, null, false, _session.UserId, true)).ReturnsAsync(resultSet); var controller = new ArtifactVersionsController(_artifactVersionsRepositoryMock.Object, _artifactPermissionsRepositoryMock.Object) { Request = new HttpRequestMessage() }; controller.Request.Properties[ServiceConstants.SessionProperty] = _session; // Act var result = await controller.GetArtifactHistory(artifactId); // Assert Assert.IsNotNull(result); Assert.AreEqual(artifactId, result.ArtifactId); }