Ejemplo n.º 1
0
        public void should_start_new_test()
        {
            // given
            var          testFileQueue = new TestFileQueueStub();
            var          memoryCache   = new MemoryCache("test");
            const string environment   = "env-boot-ay";
            const string username      = "******";

            string[] filenames = { "file1.sjon", "file2.json" };

            // when
            var batchManager = new BatchManager(testFileQueue, memoryCache, null);
            int batchId      = batchManager.StartBatch(filenames, environment, username);

            // then
            Assert.That(batchId, Is.EqualTo(1));
            Assert.That(testFileQueue.Add_Tasks.Count, Is.EqualTo(2));
            Assert.That(testFileQueue.Add_Tasks[0].Environment, Is.EqualTo(environment));
            Assert.That(testFileQueue.Add_Tasks[0].Username, Is.EqualTo(username));
            Assert.That(testFileQueue.Add_Tasks[0].Filename, Is.EqualTo(filenames[0]));

            Assert.That(testFileQueue.Add_Tasks[1].Environment, Is.EqualTo(environment));
            Assert.That(testFileQueue.Add_Tasks[1].Username, Is.EqualTo(username));
            Assert.That(testFileQueue.Add_Tasks[1].Filename, Is.EqualTo(filenames[1]));

            var taskIds = memoryCache[BatchManager.KeyPrefix + batchId] as List <int>;

            Assert.That(taskIds, Is.Not.Null);
            Assert.That(taskIds[0], Is.EqualTo(1));
            Assert.That(taskIds[1], Is.EqualTo(2));
        }
Ejemplo n.º 2
0
        public void should_throw_exception_when_batch_isnt_found()
        {
            // given
            var testFileQueue = new TestFileQueueStub();
            var memoryCache   = new MemoryCache("test");
            var resultFactory = new Mock <ITestFileResultFactory>();

            // when
            var batchManager = new BatchManager(testFileQueue, memoryCache, resultFactory.Object);

            // then
            Assert.Throws <KeyNotFoundException>(() => batchManager.GetBatchStatus(1));
        }