Example #1
0
 public void Initialize()
 {
     _artifactRepositoryMock        = new Mock <IArtifactRepository>();
     _artifactPermissionsRepository = new Mock <IArtifactPermissionsRepository>();
     cxn         = new SqlConnectionWrapperMock();
     repository  = new SqlArtifactRepository(cxn.Object);
     artifactIds = null;
     session     = new Session {
         UserId = userId
     };
 }
Example #2
0
        public async Task GetProcessArtifactInfo_GetProcessInfo_Success()
        {
            // Arrange
            artifactIds = new HashSet <int>()
            {
                1, 2, 3
            };
            List <ProcessInfoDto> processInfos = new List <ProcessInfoDto>()
            {
                new ProcessInfoDto()
                {
                    ItemId = 1, ProcessType = ProcessType.BusinessProcess
                },
                new ProcessInfoDto()
                {
                    ItemId = 2, ProcessType = ProcessType.UserToSystemProcess
                },
                new ProcessInfoDto()
                {
                    ItemId = 3, ProcessType = ProcessType.SystemToSystemProcess
                }
            };

            var permissionDict = new Dictionary <int, RolePermissions>()
            {
            };

            permissionDict.Add(key: 1, value: RolePermissions.Read);

            _artifactPermissionsRepository.Setup(q => q.GetArtifactPermissions(It.IsAny <IEnumerable <int> >(), session.UserId, false, Int32.MaxValue, true, null)).ReturnsAsync(permissionDict);

            _artifactRepositoryMock.Setup(r => r.GetProcessInformationAsync(artifactIds, session.UserId)).ReturnsAsync(processInfos);

            repository = new SqlArtifactRepository(cxn.Object, new SqlItemInfoRepository(new SqlConnectionWrapper("")), _artifactPermissionsRepository.Object);

            // Act
            await repository.GetProcessInformationAsync(artifactIds, session.UserId);

            // Assert
            cxn.Verify();
        }