Ejemplo n.º 1
0
        public async Task Should_Only_Get_Runners_With_LastUpdatedDate_Greater_Than_Given()
        {
            // Arrange
            var runner1 = new Domain.Clients.QueueRunner
            {
                Name      = "Runner 1",
                IsRunning = true
            };
            var runner2 = new Domain.Clients.QueueRunner
            {
                Name      = "Runner 2",
                IsRunning = true
            };
            await _context.AddRangeAsync(runner1, runner2).ConfigureAwait(false);

            await _context.SaveChangesAsync().ConfigureAwait(false);

            Thread.Sleep(1000);
            var testDate = DateTime.UtcNow;

            Thread.Sleep(1000);

            runner1.Name = "Changed Runner 1";
            await _context.SaveChangesAsync().ConfigureAwait(false);

            // Act
            var result = (await _sut.GetRunners(lastUpdatedSince: testDate).ConfigureAwait(false)).ToArray();

            // Assert
            result.ShouldNotBeNull();
            result.Length.ShouldBe(1);
            result[0].Name.ShouldBe(runner1.Name);
        }
Ejemplo n.º 2
0
        public async Task Should_Mark_Runner_As_Task_Processed()
        {
            // Arrange
            var runner = new Domain.Clients.QueueRunner
            {
                Name      = "Runner 1",
                IsRunning = true
            };
            await _context.AddAsync(runner).ConfigureAwait(false);

            await _context.SaveChangesAsync().ConfigureAwait(false);

            // Act
            await _sut.MarkQueueRunnerTaskProcessed(runner.Name).ConfigureAwait(false);

            // Assert
            (await _context.Runners.SingleAsync(r => r.Name == runner.Name).ConfigureAwait(false)).LastTaskProcessed.ShouldNotBeNull();
        }
Ejemplo n.º 3
0
        public async Task Should_Only_Get_Runners_With_Tag_And_IsRunningFlag_And_LastUpdatedDateSince_And_LastUpdatedDateBefore_Provided()
        {
            // Arrange
            const string tag     = "Tag";
            var          runner1 = new Domain.Clients.QueueRunner
            {
                Name      = "Runner 1",
                IsRunning = true
            };
            var runner2 = new Domain.Clients.QueueRunner
            {
                Name      = "Runner 2",
                IsRunning = false
            };
            var runner3 = new Domain.Clients.QueueRunner
            {
                Name      = "Runner 3",
                IsRunning = true,
                Tag       = tag
            };
            await _context.AddRangeAsync(runner1, runner2, runner3).ConfigureAwait(false);

            await _context.SaveChangesAsync().ConfigureAwait(false);

            Thread.Sleep(1000);
            var testDate = DateTime.UtcNow;

            Thread.Sleep(1000);

            runner1.Tag = tag;
            await _context.SaveChangesAsync().ConfigureAwait(false);

            // Act
            var result = (await _sut.GetRunners(tag, true, testDate, DateTime.UtcNow).ConfigureAwait(false)).ToArray();

            // Assert
            result.ShouldNotBeNull();
            result.Length.ShouldBe(2);
            result[0].Name.ShouldBe(runner1.Name);
            result[1].Name.ShouldBe(runner3.Name);
        }