Ejemplo n.º 1
0
        public void TestDequeueWhenChainMocksAndNotUsages()
        {
            var httpRequestMock   = CreateMock("get");
            var mocks             = new[] { CreateMock("get"), httpRequestMock };
            var handlingMockQueue = new HandlingMockQueue();

            handlingMockQueue.Enqueue(mocks);

            var handlingInfo = handlingMockQueue.Dequeue(CreateRequestInfo("get", "/"));

            handlingInfo.Should().NotBeNull();
            handlingInfo.IsUsageCountValid().Should().BeTrue();
            handlingInfo.HasAttempts().Should().BeFalse();
            handlingInfo.UsageCount.ShouldBeEquivalentTo(1);

            handlingInfo = handlingMockQueue.Dequeue(CreateRequestInfo("get", "/"));

            handlingInfo.Should().NotBeNull();
            handlingInfo.IsUsageCountValid().Should().BeTrue();
            handlingInfo.HasAttempts().Should().BeFalse();
            handlingInfo.UsageCount.ShouldBeEquivalentTo(1);

            handlingInfo = handlingMockQueue.Dequeue(CreateRequestInfo("get", "/"));

            handlingInfo.Should().NotBeNull();
            handlingInfo.IsUsageCountValid().Should().BeFalse();
            handlingInfo.HasAttempts().Should().BeFalse();
            handlingInfo.UsageCount.ShouldBeEquivalentTo(2);
            handlingInfo.ResponseMock.Should().Be(httpRequestMock.Response);
        }
Ejemplo n.º 2
0
        public void TestDequeueWhenEmpty()
        {
            var handlingMockQueue = new HandlingMockQueue();

            handlingMockQueue.Enqueue(new HttpRequestMock[0]);
            handlingMockQueue.Dequeue(CreateRequestInfo("get", "/")).Should().BeNull();
        }
Ejemplo n.º 3
0
        private IHttpMock New(IMockUrlEnumerator mockUrlEnumerator, int replicasCount)
        {
            var handlingMockQueue = new HandlingMockQueue();
            var startedHttpMocks  = Enumerable.Range(0, replicasCount)
                                    .Select(x => httpMockRunner.RunMocks(mockUrlEnumerator, handlingMockQueue))
                                    .ToArray();

            var httpMock = new HttpMock(startedHttpMocks, handlingMockQueue);

            httpMocks.Add(httpMock);

            return(httpMock);
        }
Ejemplo n.º 4
0
        public void TestDequeueWhenOneMock()
        {
            var mocks             = new[] { CreateMock("get") };
            var handlingMockQueue = new HandlingMockQueue();

            handlingMockQueue.Enqueue(mocks);

            var handlingInfo = handlingMockQueue.Dequeue(CreateRequestInfo("get", "/"));

            handlingInfo.Should().NotBeNull();
            handlingInfo.IsUsageCountValid().Should().BeTrue();
            handlingInfo.HasAttempts().Should().BeFalse();
            handlingInfo.UsageCount.ShouldBeEquivalentTo(1);

            handlingInfo = handlingMockQueue.Dequeue(CreateRequestInfo("get", "/"));

            handlingInfo.Should().NotBeNull();
            handlingInfo.IsUsageCountValid().Should().BeFalse();
            handlingInfo.HasAttempts().Should().BeFalse();
            handlingInfo.UsageCount.ShouldBeEquivalentTo(2);
        }