예제 #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);
        }
예제 #2
0
        public void TestDequeueWhenEmpty()
        {
            var handlingMockQueue = new HandlingMockQueue();

            handlingMockQueue.Enqueue(new HttpRequestMock[0]);
            handlingMockQueue.Dequeue(CreateRequestInfo("get", "/")).Should().BeNull();
        }
예제 #3
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);
        }