Exemple #1
0
        public async Task GetTransitionsAsync_WithEditPermissions_SuccessfullyReads()
        {
            // Arrange
            var permissionsRepository = CreatePermissionsRepositoryMock(new[] { 1 }, 1, RolePermissions.Edit);
            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.Actor
                }
            });
            cxn.SetupQueryAsync("GetTransitionsForState",
                                new Dictionary <string, object>
            {
                { "workflowId", 1 },
                { "stateId", 1 },
                { "userId", 1 }
            },
                                new List <SqlWorkflowTransition>
            {
                new SqlWorkflowTransition
                {
                    WorkflowEventId   = 1,
                    ToStateId         = 2,
                    ToStateName       = "A",
                    FromStateId       = 1,
                    WorkflowEventName = "TA"
                },
                new SqlWorkflowTransition
                {
                    WorkflowEventId   = 2,
                    ToStateId         = 3,
                    ToStateName       = "B",
                    FromStateId       = 1,
                    WorkflowEventName = "TB"
                },
                new SqlWorkflowTransition
                {
                    WorkflowEventId   = 3,
                    ToStateId         = 4,
                    ToStateName       = "C",
                    FromStateId       = 1,
                    WorkflowEventName = "TC"
                }
            });
            // Act
            var result = (await repository.GetTransitionsAsync(1, 1, 1, 1));

            Assert.IsTrue(result.Count == 3, "Transitions could not be retrieved");
        }
Exemple #2
0
        public async Task GetTransitionsAsync_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);
        }
Exemple #3
0
        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);
        }