Esempio n. 1
0
        public async Task HandleAction_NullTenant_ReturnsFalse()
        {
            var actionHelper = new GenerateTestsActionHelper();
            var result       = await actionHelper.HandleAction(null, new GenerateTestsMessage(), null);

            Assert.IsFalse(result, "Action should have failed for null tenant");
            _jobsRepoMock.Verify(t => t.AddJobMessage(It.IsAny <JobType>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int?>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
Esempio n. 2
0
        public async Task HandleAction_CreatesJob_ReturnsTrue()
        {
            // Arrange
            var actionHelper = new GenerateTestsActionHelper();
            var sqlUser      = new SqlUser
            {
                UserId = UserId,
                Login  = UserName
            };

            _generateActionsRepositoryMock.Setup(m => m.GetUser(It.IsAny <int>())).ReturnsAsync(sqlUser);
            _userRepoMock.Setup(t => t.GetExistingUsersByIdsAsync(It.IsAny <IEnumerable <int> >())).
            ReturnsAsync(new List <SqlUser>
            {
                sqlUser
            });

            _jobsRepoMock.Setup(t => t.AddJobMessage(JobType.GenerateProcessTests,
                                                     false,
                                                     It.IsAny <string>(),
                                                     null,
                                                     ProjectId,
                                                     It.IsAny <string>(),
                                                     UserId,
                                                     UserName,
                                                     It.IsAny <string>())).ReturnsAsync(2);

            // Act
            var result = await actionHelper.HandleAction(new TenantInformation
            {
                TenantId = Guid.NewGuid().ToString(),
                BlueprintConnectionString = "BlueprintConnectionString"
            },
                                                         new GenerateTestsMessage
            {
                ArtifactId = ArtifactId,
                UserId     = UserId,
                RevisionId = RevisionId,
                ProjectId  = ProjectId,
                UserName   = UserName
            },
                                                         _generateActionsRepositoryMock.Object);

            // Assert
            Assert.IsTrue(result, "Action should have succeeded");
            _jobsRepoMock.Verify(t => t.AddJobMessage(JobType.GenerateProcessTests, It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int?>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once);
        }
Esempio n. 3
0
        public async Task HandleAction_RevisionIdIsInvalid_ReturnsFalse()
        {
            // Arrange
            var actionHelper = new GenerateTestsActionHelper();

            // Act
            var result = await actionHelper.HandleAction(new TenantInformation
            {
                TenantId = Guid.NewGuid().ToString(),
                BlueprintConnectionString = "BlueprintConnectionString"
            },
                                                         new GenerateTestsMessage
            {
                ArtifactId = ArtifactId,
                ProjectId  = ProjectId,
                UserId     = UserId,
                UserName   = UserName
            },
                                                         _generateActionsRepositoryMock.Object);

            // Assert
            Assert.IsFalse(result, "Action should have failed for invalid message");
            _jobsRepoMock.Verify(t => t.AddJobMessage(It.IsAny <JobType>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int?>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }