public void TestJobsControllerExecuteWithWildcard() { // Arrange Mock <ISchedulerCore> mockSchedulerCore = new Mock <ISchedulerCore>(); mockSchedulerCore.Setup(i => i.GetJobDetail(It.IsAny <Guid>())) .Returns(new JobDetailImpl("Job1", "Group1", typeof(NoOpJob))); _mockPermissionsHelper.Setup(i => i.GetAuthorizedJobGroups()).Returns(new List <string> { "*" }); var controller = new JobsController(_mockPermissionsHelper.Object, mockSchedulerCore.Object); // Act controller.Execute(Guid.NewGuid()); // Assert mockSchedulerCore.Verify(i => i.ExecuteJob(It.IsAny <Guid>()), Times.Once); }
public void TestJobsControllerExecuteUnauthorized() { // Arrange Mock <ISchedulerCore> mockSchedulerCore = new Mock <ISchedulerCore>(); mockSchedulerCore.Setup(i => i.GetJobDetail(It.IsAny <Guid>())) .Returns(new JobDetailImpl("Job1", "Group1", typeof(NoOpJob))); _mockPermissionsHelper.Setup(i => i.GetAuthorizedJobGroups()).Returns(new List <string> { "test_group" }); var controller = new JobsController(_mockPermissionsHelper.Object, mockSchedulerCore.Object); // Assert try { // Act controller.Execute(Guid.NewGuid()); } catch (HttpResponseException ex) { // Assert Assert.Equal(HttpStatusCode.Unauthorized, ex.Response.StatusCode); } }