Esempio n. 1
0
        public void ShouldReturnNotFoundAndNotAttemptToDeleteTriggerIfItDoesNotExist()
        {
            MockElasticRepo.Setup(x => x.SelectById <TriggerStub>(TriggerDocumentId));

            var actual = Subject.Delete(TriggerDocumentId);

            Assert.That(actual, Is.TypeOf(typeof(NotFoundResult)));
            MockElasticRepo.Verify(x => x.Delete <TriggerStub>(TriggerDocumentId), Times.Never);
            MockEngineScheduler.Verify(x => x.DeleteTrigger(It.IsAny <TriggerStub>()), Times.Never);
        }
Esempio n. 2
0
        public void ShouldGetTriggerById()
        {
            var expected = new TriggerStub()
            {
                Id = TriggerDocumentId
            };

            MockElasticRepo.Setup(x => x.SelectById <TriggerStub>(TriggerDocumentId)).Returns(expected);

            var actual = Subject.Get(TriggerDocumentId);

            Assert.That(actual, Is.TypeOf(typeof(OkNegotiatedContentResult <TriggerStub>)));
            MockElasticRepo.Verify(x => x.SelectById <TriggerStub>(TriggerDocumentId), Times.Once);
        }
Esempio n. 3
0
        public void ShouldUpdateAndReturnTrigger()
        {
            var expected = new TriggerStub()
            {
                Id = TriggerDocumentId
            };

            MockElasticRepo.Setup(x => x.Update(expected)).Returns(expected);
            MockEngineScheduler.Setup(x => x.ScheduleJobWithTrigger(expected));

            var actual = Subject.Put(TriggerDocumentId, expected);

            Assert.That(actual, Is.TypeOf(typeof(OkNegotiatedContentResult <TriggerStub>)));
            MockElasticRepo.Verify(x => x.Update(expected), Times.Once);
            MockEngineScheduler.Verify(x => x.ScheduleJobWithTrigger(expected), Times.Once);
        }
Esempio n. 4
0
        public void ShouldGetListOfTriggers()
        {
            var expected = new List <TriggerStub>()
            {
                new TriggerStub(), new TriggerStub()
            };
            var expectedCount = expected.Count();

            MockElasticRepo.Setup(x => x.SelectAll <TriggerStub>()).Returns(expected);

            var actual = Subject.GetCollection();

            Assert.That(actual.Count(), Is.EqualTo(expectedCount));
            Assert.That(actual, Is.EquivalentTo(expected));
            MockElasticRepo.Verify(x => x.SelectAll <TriggerStub>(), Times.Once);
        }
Esempio n. 5
0
        public void ShouldDeleteTrigger()
        {
            var expected = new TriggerStub()
            {
                Id = TriggerDocumentId
            };

            MockEngineScheduler.Setup(x => x.DeleteTrigger(expected));
            MockElasticRepo.Setup(x => x.SelectById <TriggerStub>(TriggerDocumentId)).Returns(expected);
            MockElasticRepo.Setup(x => x.Delete <TriggerStub>(TriggerDocumentId));

            Subject.Delete(TriggerDocumentId);

            MockElasticRepo.Verify(x => x.SelectById <TriggerStub>(TriggerDocumentId), Times.Once);
            MockElasticRepo.Verify(x => x.Delete <TriggerStub>(TriggerDocumentId), Times.Once);
            MockEngineScheduler.Verify(x => x.DeleteTrigger(expected), Times.Once);
        }
Esempio n. 6
0
        public void ShouldScheduleJobWhenTriggerIsCreated()
        {
            var jobType          = "MyProject.MyIntegrationJob";
            var triggerWithoutId = new TriggerStub()
            {
                JobType = jobType
            };
            var expected = new TriggerStub()
            {
                JobType = jobType,
                Id      = TriggerDocumentId,
            };

            MockElasticRepo.Setup(x => x.Insert(triggerWithoutId)).Returns(expected);
            MockEngineScheduler.Setup(x => x.ScheduleJobWithTrigger(expected));
            MockEngineScheduler.Setup(x => x.IsJobTypeRegistered(jobType)).Returns(true);

            Subject.Post(triggerWithoutId);

            MockElasticRepo.Verify(x => x.Insert(triggerWithoutId), Times.Once);
            MockEngineScheduler.Verify(x => x
                                       .ScheduleJobWithTrigger(It.Is <TriggerStub>(y => y.JobType == jobType && y.Id == TriggerDocumentId)), Times.Once);
        }