public async Task GetTransitionForAssociatedStatesAsync_NotFoundArtifact_ThrowsException() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlWorkflowRepository(cxn.Object, new Mock <IArtifactPermissionsRepository>().Object); cxn.SetupQueryAsync("GetArtifactBasicDetails", new Dictionary <string, object> { { "userId", 1 }, { "itemId", 1 } }, new List <ArtifactBasicDetails>()); // Act await repository.GetTransitionsAsync(1, 1, 1, 1); }
public async Task GetCurrentState_WithEditPermissions_SuccessfullyReads() { // Arrange var permissionsRepository = CreatePermissionsRepositoryMock(new[] { 1 }, 1, RolePermissions.Edit | RolePermissions.Read); var cxn = new SqlConnectionWrapperMock(); var repository = new SqlWorkflowRepository(cxn.Object, permissionsRepository.Object); var artifactIdsTable = SqlConnectionWrapper.ToDataTable(new[] { 1 }, "Int32Collection", "Int32Value"); cxn.SetupQueryAsync("GetArtifactBasicDetails", new Dictionary <string, object> { { "userId", 1 }, { "itemId", 1 } }, new List <ArtifactBasicDetails> { new ArtifactBasicDetails { PrimitiveItemTypePredefined = (int)ItemTypePredefined.Actor } }); cxn.SetupQueryAsync("GetWorkflowStatesForArtifacts", new Dictionary <string, object> { { "userId", 1 }, { "artifactIds", artifactIdsTable }, { "revisionId", 2147483647 }, { "addDrafts", true } }, new List <SqlWorkFlowStateInformation> { new SqlWorkFlowStateInformation { WorkflowStateId = 1, WorkflowStateName = "A", WorkflowId = 1 } }); // Act var result = (await repository.GetStateForArtifactAsync(1, 1, int.MaxValue, true)); Assert.IsTrue(result != null, "Workflow State is null"); }
public async Task GetCustomProjectTypesAsync_ProjectNotFound() { // Arrange var projectId = 1; var userId = 2; SqlProjectMetaRepository.ProjectVersion[] result = { }; var cxn = new SqlConnectionWrapperMock(); var repository = new SqlProjectMetaRepository(cxn.Object); cxn.SetupQueryAsync <SqlProjectMetaRepository.ProjectVersion>("GetInstanceProjectById", new Dictionary <string, object> { { "projectId", projectId }, { "userId", userId } }, result); // Act await repository.GetCustomProjectTypesAsync(projectId, userId); // Assert }
public async Task GetUserByLoginAsync_QueryReturnsEmpty_ReturnsNull() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); string login = "******"; AuthenticationUser[] result = { }; cxn.SetupQueryAsync("GetUserByLogin", new Dictionary <string, object> { { "Login", login } }, result); // Act AuthenticationUser user = await repository.GetUserByLoginAsync(login); // Assert cxn.Verify(); Assert.IsNull(user); }
public async Task GetLoginUserByIdAsync_QueryReturnsEmpty_ReturnsNull() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); int userId = 5; LoginUser[] result = { }; cxn.SetupQueryAsync("GetLoginUserById", new Dictionary <string, object> { { "UserId", userId } }, result); // Act LoginUser user = await repository.GetLoginUserByIdAsync(userId); // Assert cxn.Verify(); Assert.IsNull(user); }
public async Task ExtendSession_SessionDoesNotExist_ReturnsNull() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlSessionsRepository(cxn.Object); var guid = new Guid("12345678901234567890123456789012"); Session[] result = { }; cxn.SetupQueryAsync("[AdminStore].ExtendSession", new Dictionary <string, object> { { "SessionId", guid } }, result); // Act Session session = await repository.ExtendSession(guid); // Assert cxn.Verify(); Assert.IsNull(session); }
public async Task GetUserSession_SessionDoesNotExist_ReturnsNull() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlSessionsRepository(cxn.Object); int uid = 5; Session[] result = { }; cxn.SetupQueryAsync("[AdminStore].GetUserSession", new Dictionary <string, object> { { "UserId", uid } }, result); // Act Session session = await repository.GetUserSession(uid); // Assert cxn.Verify(); Assert.IsNull(session); }
public async Task EndSession_TimeoutSessionDoesNotExist_ReturnsNull() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlSessionsRepository(cxn.Object); var guid = new Guid("00000000000000000000000000000000"); DateTime?timeoutTime = DateTime.UtcNow; var sessions = new Session[] { }; cxn.SetupQueryAsync("[AdminStore].EndSession", new Dictionary <string, object> { { "SessionId", guid }, { "TimeoutTime", timeoutTime } }, sessions); // Act Session result = await repository.EndSession(guid, timeoutTime); // Assert cxn.Verify(); Assert.IsNull(result); }
public async Task SelectSessions_SessionDoesNotExist_ReturnsEmpty() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlSessionsRepository(cxn.Object); int ps = 100; int pn = 1; Session[] result = { }; cxn.SetupQueryAsync("[AdminStore].SelectSessions", new Dictionary <string, object> { { "ps", ps }, { "pn", pn } }, result); // Act IEnumerable <Session> sessions = await repository.SelectSessions(ps, pn); // Assert cxn.Verify(); Assert.IsFalse(sessions.Any()); }
public async Task GetVersionControlArtifactInfoAsync_LatestDeleted() { // Arrange int userId = 1, itemId = 11, artifactId = 10, lockedByUserId = 2, latestDeletedByUserId = 3; SqlConnectionWrapperMock connectionWrapperMock = new SqlConnectionWrapperMock(); Mock <IArtifactRepository> artifactRepositoryMock = new Mock <IArtifactRepository>(); artifactRepositoryMock .Setup(m => m.GetArtifactBasicDetails(itemId, userId, null)) .ReturnsAsync(new ArtifactBasicDetails { ItemId = itemId, ArtifactId = artifactId, DraftDeleted = false, LatestDeleted = true, UserId = userId, LockedByUserId = lockedByUserId, LatestDeletedByUserId = latestDeletedByUserId }); Mock <IArtifactPermissionsRepository> artifactPermissionsRepositoryMock = new Mock <IArtifactPermissionsRepository>(); artifactPermissionsRepositoryMock.Setup(apr => apr.GetArtifactPermissions( It.IsAny <IEnumerable <int> >(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <bool>(), null)) .ReturnsAsync(new Dictionary <int, RolePermissions> { { artifactId, RolePermissions.Read } }); SqlArtifactVersionsRepository artifactVersionsRepository = new SqlArtifactVersionsRepository( connectionWrapperMock.Object, artifactRepositoryMock.Object, artifactPermissionsRepositoryMock.Object, _itemInfoRepositoryMock.Object); // Act VersionControlArtifactInfo artifactInfo = (await artifactVersionsRepository.GetVersionControlArtifactInfoAsync(itemId, null, userId)); // Assert connectionWrapperMock.Verify(); Assert.IsNotNull(artifactInfo.DeletedByUser); Assert.IsNotNull(artifactInfo.DeletedByUser.Id); Assert.IsTrue(artifactInfo.DeletedByUser.Id.Value == latestDeletedByUserId); }
public async Task EndSession_LogoutSessionExists_ReturnsFirst() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlSessionsRepository(cxn.Object); var guid = new Guid("12345678901234567890123456789012"); var sessions = new[] { new Session { SessionId = guid } }; cxn.SetupQueryAsync("[AdminStore].EndSession", new Dictionary <string, object> { { "SessionId", guid }, { "TimeoutTime", null } }, sessions); // Act Session result = await repository.EndSession(guid); // Assert cxn.Verify(); Assert.AreEqual(sessions[0], result); }
public async Task GetEffectiveUserLicenseAsync_QueryReturnsEmpty_ReturnsZero() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); var userId = 1; var userIds = new[] { userId }; var userIdTable = SqlConnectionWrapper.ToDataTable(userIds); var result = Enumerable.Empty <UserLicense>(); cxn.SetupQueryAsync("GetEffectiveUserLicense", new Dictionary <string, object> { { "UserIds", userIdTable } }, result); // Act var licenseType = await repository.GetEffectiveUserLicenseAsync(userId); // Assert cxn.Verify(); Assert.AreEqual(0, licenseType); }
public async Task GetUserSession_SessionExists_ReturnsFirst() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlSessionsRepository(cxn.Object); int uid = 1; Session[] result = { new Session { UserId = uid } }; cxn.SetupQueryAsync("[AdminStore].GetUserSession", new Dictionary <string, object> { { "UserId", uid } }, result); // Act Session session = await repository.GetUserSession(uid); // Assert cxn.Verify(); Assert.AreEqual(result.First(), session); }
public async Task GetLoginUserByIdAsync_QueryReturnsUser_ReturnsFirst() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); int userId = 1; LoginUser[] result = { new LoginUser { Id = userId } }; cxn.SetupQueryAsync("GetLoginUserById", new Dictionary <string, object> { { "UserId", userId } }, result); // Act LoginUser user = await repository.GetLoginUserByIdAsync(userId); // Assert cxn.Verify(); Assert.AreEqual(result.First(), user); }
public async Task GetUser_WeHaveThisUserInDb_QueryReturnUser() { // arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); var userId = 10; User[] returnResult = { new User { Id = 5 } }; cxn.SetupQueryAsync("GetUserDetails", new Dictionary <string, object> { { "UserId", userId } }, returnResult); // act var result = await repository.GetUserAsync(userId); // assert cxn.Verify(); Assert.AreEqual(returnResult.First(), result); }
public async Task GetLockedLicenses_QueryReturnsValue_ReturnsValue() { // Arrange const int userId = 1; const int licenseLevel = 3; const int lockTime = 1440; var cxn = new SqlConnectionWrapperMock(); var repository = new SqlLicensesRepository(cxn.Object); int result = 2; cxn.SetupExecuteScalarAsync(v => true, new Dictionary <string, object> { { "UserId", userId }, { "LicenseLevel", licenseLevel }, { "TimeDiff", -lockTime } }, result); // Act var count = await repository.GetLockedLicenses(userId, 3, 1440); // Assert cxn.Verify(); Assert.AreEqual(result, count); }
public async Task GetTransitionsAsync_IncorrectArtifactType_ThrowsException() { // Arrange var permissionsRepository = CreatePermissionsRepositoryMock(new[] { 1 }, 1, RolePermissions.None); var cxn = new SqlConnectionWrapperMock(); var repository = new SqlWorkflowRepository(cxn.Object, permissionsRepository.Object); cxn.SetupQueryAsync("GetArtifactBasicDetails", new Dictionary <string, object> { { "userId", 1 }, { "itemId", 1 } }, new List <ArtifactBasicDetails> { new ArtifactBasicDetails() { PrimitiveItemTypePredefined = (int)ItemTypePredefined.Project } }); // Act await repository.GetTransitionsAsync(1, 1, 1, 1); }
public async Task AddUserAsync_SuccessfulCreationOfGroup_ReturnCreatedUserId() { // Arrange var group = new GroupDto { Name = "GroupName", Email = "GroupEmail", Source = UserGroupSource.Database, LicenseType = LicenseType.Author }; var cxn = new SqlConnectionWrapperMock(); var repository = new SqlGroupRepository(cxn.Object); var groupId = 100; cxn.SetupExecuteScalarAsync("AddGroup", It.IsAny <Dictionary <string, object> >(), groupId); // Act await repository.AddGroupAsync(group, null); // Assert cxn.Verify(); }
private SqlArtifactVersionsRepository CreateSqlRepositoryMock(int userId, int artifactId, int baselineId, int revisionId, ItemInfo itemInfo, ISet <int> baselineArtifacts) { SqlConnectionWrapperMock connectionWrapperMock = new SqlConnectionWrapperMock(); Mock <IArtifactRepository> artifactRepositoryMock = new Mock <IArtifactRepository>(); artifactRepositoryMock .Setup(m => m.GetArtifactBasicDetails(artifactId, userId, null)) .ReturnsAsync(new ArtifactBasicDetails { ItemId = artifactId, ArtifactId = artifactId }); Mock <IArtifactPermissionsRepository> artifactPermissionsRepositoryMock = new Mock <IArtifactPermissionsRepository>(); artifactPermissionsRepositoryMock.Setup(apr => apr.GetArtifactPermissions( It.IsAny <IEnumerable <int> >(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <bool>(), null)) .ReturnsAsync(new Dictionary <int, RolePermissions> { { artifactId, RolePermissions.Read } }); _itemInfoRepositoryMock.Setup(iir => iir.GetRevisionId( artifactId, userId, null, baselineId)) .ReturnsAsync(revisionId); artifactPermissionsRepositoryMock.Setup(apr => apr.GetItemInfo( artifactId, userId, false, revisionId)) .ReturnsAsync(itemInfo); _itemInfoRepositoryMock.Setup(apr => apr.GetBaselineArtifacts( baselineId, userId, true, int.MaxValue)) .ReturnsAsync(baselineArtifacts); SqlArtifactVersionsRepository artifactVersionsRepository = new SqlArtifactVersionsRepository( connectionWrapperMock.Object, artifactRepositoryMock.Object, artifactPermissionsRepositoryMock.Object, _itemInfoRepositoryMock.Object); return(artifactVersionsRepository); }
public async Task GetFederatedAuthentication_QueryReturnsSettings_ReturnsFirst() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlSettingsRepository(cxn.Object); var xml = SerializationHelper.Serialize(new FederatedAuthenticationSettings.FASettings()); dynamic dbObject = new ExpandoObject(); dbObject.Settings = xml; dbObject.Certificate = null; var expectedFedAuthSettings = new FederatedAuthenticationSettings(xml, null); var result = new[] { dbObject }; cxn.SetupQueryAsync("GetFederatedAuthentications", null, result); // Act var settings = await repository.GetFederatedAuthenticationSettingsAsync(); // Assert cxn.Verify(); Assert.IsTrue(Equals(expectedFedAuthSettings, settings)); }
public void Initialize() { _userId = 1; _collectionId = 1; _expectedCollectionArtifacts = new List <ArtifactPropertyInfo> { new ArtifactPropertyInfo { PropertyName = "Name", PropertyTypeId = 80, PropertyTypePredefined = 4098, Prefix = "Prefix", ArtifactId = 7545, PrimitiveType = 0, ItemTypeId = 134, PredefinedType = 4107, FullTextValue = "Value_Name", ItemTypeIconId = 0 }, new ArtifactPropertyInfo { PropertyName = "Description", PropertyTypeId = 81, PropertyTypePredefined = 4099, Prefix = "Prefix", ArtifactId = 7551, PrimitiveType = 0, ItemTypeId = 132, PredefinedType = 4105, FullTextValue = "Value_Description", ItemTypeIconId = 0 } }; _cxn = new SqlConnectionWrapperMock(); _repository = new SqlCollectionsRepository(_cxn.Object); }
public async Task UpdateUserOnPasswordResetAsync_Success() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); var user = new AuthenticationUser { Login = "******", Id = 99, Password = "******", UserSalt = new Guid() }; cxn.SetupExecuteAsync( "AddCurrentUserPasswordToHistory", new Dictionary <string, object> { { "@userId", user.Id } }, 1); cxn.SetupExecuteAsync( "UpdateUserOnPasswordResetAsync", new Dictionary <string, object> { { "@Login", user.Login }, { "@Password", user.Password }, { "@UserSALT", user.UserSalt } }, 1); // Act await repository.UpdateUserOnPasswordResetAsync(user); // Assert cxn.Verify(); }
public async Task GetVersionControlArtifactInfoAsync_HasChangesLockedByMe() { // Arrange int userId = 1, itemId = 11, artifactId = 10; SqlConnectionWrapperMock connectionWrapperMock = new SqlConnectionWrapperMock(); Mock <IArtifactRepository> artifactRepositoryMock = new Mock <IArtifactRepository>(); artifactRepositoryMock .Setup(m => m.GetArtifactBasicDetails(itemId, userId, null)) .ReturnsAsync(new ArtifactBasicDetails { ItemId = itemId, ArtifactId = artifactId, HasDraftRelationships = false, UserId = userId, LockedByUserId = userId, }); Mock <IArtifactPermissionsRepository> artifactPermissionsRepositoryMock = new Mock <IArtifactPermissionsRepository>(); artifactPermissionsRepositoryMock.Setup(apr => apr.GetArtifactPermissions( It.IsAny <IEnumerable <int> >(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <bool>(), null)) .ReturnsAsync(new Dictionary <int, RolePermissions> { { artifactId, RolePermissions.Read } }); SqlArtifactVersionsRepository artifactVersionsRepository = new SqlArtifactVersionsRepository( connectionWrapperMock.Object, artifactRepositoryMock.Object, artifactPermissionsRepositoryMock.Object, _itemInfoRepositoryMock.Object); // Act VersionControlArtifactInfo artifactInfo = (await artifactVersionsRepository.GetVersionControlArtifactInfoAsync(itemId, null, userId)); // Assert connectionWrapperMock.Verify(); Assert.IsTrue(artifactInfo.HasChanges); }
public async Task UpdateUserAsync_SuccessfulUpdateOfUser_ReturnOk() { // Arrange var user = new User { Login = "******", FirstName = "FirstNameValueUpdate", LastName = "LastNameValueUpdate", DisplayName = "DisplayNameValueUpdate", Email = "*****@*****.**", Source = UserGroupSource.Database, AllowFallback = false, Enabled = true, ExpirePassword = true, Password = "******", UserSALT = Guid.NewGuid(), Title = "TitleValue", Department = "DepartmentvalueUpdate", GroupMembership = new int[] { 1 }, Guest = false, CurrentVersion = 1 }; var cxn = new SqlConnectionWrapperMock(); var repository = new SqlUserRepository(cxn.Object, cxn.Object); var errorId = 1; cxn.SetupExecuteAsync("UpdateUser", It.IsAny <Dictionary <string, object> >(), 1, new Dictionary <string, object> { { "ErrorCode", errorId } }); // Act await repository.UpdateUserAsync(user, null); // Assert cxn.Verify(); }
public async Task GetTransitionForAssociatedStatesAsync_ReturnsCorrectTransition_WhenMultipleTransitionsHaveTheSameDestinationState() { // Arrange const int transitionId = 123; const int userId = 1; const int workflowId = 2; const int fromStateId = 3; const int toStateId = 4; const int artifactId = 5; var artifactIds = new[] { artifactId }; var permissionsRepository = CreatePermissionsRepositoryMock(artifactIds, userId, RolePermissions.Edit); var cxn = new SqlConnectionWrapperMock(); var repository = new SqlWorkflowRepository(cxn.Object, permissionsRepository.Object); var artifactDetailsParameters = new Dictionary <string, object> { { "userId", userId }, { "itemId", artifactId } }; var artifactDetailsResult = new List <ArtifactBasicDetails> { new ArtifactBasicDetails { PrimitiveItemTypePredefined = (int)ItemTypePredefined.Actor } }; cxn.SetupQueryAsync("GetArtifactBasicDetails", artifactDetailsParameters, artifactDetailsResult); var expectedResult = new SqlWorkflowTransition { WorkflowEventId = transitionId, ToStateId = toStateId, FromStateId = fromStateId, WorkflowId = workflowId }; var unexpectedResult1 = new SqlWorkflowTransition { WorkflowEventId = transitionId - 1, ToStateId = toStateId, FromStateId = fromStateId, WorkflowId = workflowId }; var unexpectedResult2 = new SqlWorkflowTransition { WorkflowEventId = transitionId + 1, ToStateId = toStateId, FromStateId = fromStateId, WorkflowId = workflowId }; var transitionsResult = new List <SqlWorkflowTransition> { unexpectedResult1, expectedResult, unexpectedResult2 }; var transitionsParameters = new Dictionary <string, object> { { "workflowId", workflowId }, { "fromStateId", fromStateId }, { "toStateId", toStateId }, { "userId", userId } }; cxn.SetupQueryAsync("GetTransitionAssociatedWithStates", transitionsParameters, transitionsResult); // Act var result = await repository.GetTransitionForAssociatedStatesAsync(userId, artifactId, workflowId, fromStateId, toStateId, transitionId); // Assert Assert.AreEqual(transitionId, result.Id); Assert.AreEqual(workflowId, result.WorkflowId); Assert.AreEqual(fromStateId, result.FromState.Id); Assert.AreEqual(toStateId, result.ToState.Id); }
public void Initialize() { _cxn = new SqlConnectionWrapperMock(); _repository = new SqlProjectMetaRepository(_cxn.Object); }
public void initialize() { mockUserRepository = new SqlUserRepositoryMock(); cxn = new SqlConnectionWrapperMock(); }
public async Task GetArtifactVersions_WithDraftsAscending_Success() { // Arrange int artifactId = 1; int limit = 2; int offset = 0; int? userId = 1; bool asc = true; int sessionUserId = 1; var cxn = new SqlConnectionWrapperMock(); var repository = new SqlArtifactVersionsRepository(cxn.Object); var prm = new Dictionary <string, object> { { "artifactId", artifactId }, { "lim", limit }, { "offset", offset }, { "userId", userId.Value }, { "ascd", asc } }; cxn.SetupQueryAsync("DoesArtifactHavePublishedOrDraftVersion", new Dictionary <string, object> { { "artifactId", artifactId } }, new List <bool> { true }); cxn.SetupQueryAsync("IsArtifactDeleted", new Dictionary <string, object> { { "artifactId", artifactId } }, new List <bool> { false }); var testResult = new ArtifactHistoryVersion[] { new ArtifactHistoryVersion { VersionId = 1, UserId = 1, Timestamp = new DateTime() } }; cxn.SetupQueryAsync("GetArtifactVersions", prm, testResult); var artifactIdsTable = SqlConnectionWrapper.ToDataTable(new List <int> { artifactId }, "Int32Collection", "Int32Value"); var prm2 = new Dictionary <string, object> { { "userId", sessionUserId }, { "artifactIds", artifactIdsTable } }; cxn.SetupQueryAsync("GetArtifactsWithDraft", prm2, new int[] { artifactId }); var userIdsTable = SqlConnectionWrapper.ToDataTable(new List <int> { sessionUserId }, "Int32Collection", "Int32Value"); cxn.SetupQueryAsync("GetUserInfos", new Dictionary <string, object> { { "userIds", userIdsTable } }, new List <UserInfo> { new UserInfo { UserId = 1, DisplayName = "David", ImageId = 1 } }); // Act var actual = await repository.GetArtifactVersions(artifactId, limit, offset, userId, asc, sessionUserId, true); // Assert cxn.Verify(); Assert.AreEqual(actual.ArtifactId, 1); Assert.AreEqual(actual.ArtifactHistoryVersions.ToList().Count(), 2); Assert.AreEqual(actual.ArtifactHistoryVersions.ToList()[1].VersionId, int.MaxValue); Assert.AreEqual(actual.ArtifactHistoryVersions.ToList()[0].VersionId, 1); }
public async Task GetArtifactVersions_Should_Not_Return_Draft_Version_When_includeDrafts_Is_False() { // Arrange int artifactId = 1; int limit = 2; int offset = 0; int? userId = 1; bool asc = true; int sessionUserId = 1; bool includeDrafts = false; var cxn = new SqlConnectionWrapperMock(); var repository = new SqlArtifactVersionsRepository(cxn.Object); var artifactVersionParams = new Dictionary <string, object> { { "artifactId", artifactId }, { "lim", limit }, { "offset", offset }, { "userId", userId.Value }, { "ascd", asc } }; cxn.SetupQueryAsync("DoesArtifactHavePublishedOrDraftVersion", new Dictionary <string, object> { { "artifactId", artifactId } }, new List <bool> { true }); cxn.SetupQueryAsync("IsArtifactDeleted", new Dictionary <string, object> { { "artifactId", artifactId } }, new List <bool> { false }); var testResult = new[] { new ArtifactHistoryVersion { VersionId = 1, UserId = 1, Timestamp = new DateTime() } }; cxn.SetupQueryAsync("GetArtifactVersions", artifactVersionParams, testResult); var userIdsTable = SqlConnectionWrapper.ToDataTable(new List <int> { sessionUserId }); cxn.SetupQueryAsync("GetUserInfos", new Dictionary <string, object> { { "userIds", userIdsTable } }, new List <UserInfo> { new UserInfo { UserId = 1, DisplayName = "David", ImageId = 1 } }); // Act var actual = await repository.GetArtifactVersions(artifactId, limit, offset, userId, asc, sessionUserId, includeDrafts); // Assert cxn.Verify(); Assert.AreEqual(actual.ArtifactId, 1); Assert.AreEqual(actual.ArtifactHistoryVersions.Count(), 1); Assert.AreEqual(actual.ArtifactHistoryVersions.ToList()[0].VersionId, 1); }