public void CreateImposter_SendsRequest_WithJsonBody()
        {
            var imposter = new HttpImposter(123, null);

            var response = GetResponse(HttpStatusCode.Created);

            HttpContent content = null;
            _mockClient.Setup(x => x.PostAsync(It.IsAny<string>(), It.IsAny<HttpContent>()))
                .ReturnsAsync(response)
                .Callback<string, HttpContent>((res, cont) => content = cont);

            _proxy.CreateImposter(new HttpImposter(123, null));

            var json = content.ReadAsStringAsync().Result;
            var serializedImposter = JsonConvert.DeserializeObject<HttpImposter>(json);

            Assert.AreEqual(imposter.Port, serializedImposter.Port);
        }
 private void CreateImposter()
 {
     _imposter = _client.CreateHttpImposter(ImposterPort);
     _client.Submit(_imposter);
 }
 public void Constructor_SetsProtocol()
 {
     var imposter = new HttpImposter(123, null);
     Assert.AreEqual("http", imposter.Protocol);
 }
 public void Constructor_SetsPort()
 {
     const int port = 123;
     var imposter = new HttpImposter(port, null);
     Assert.AreEqual(port, imposter.Port);
 }
 public void Constructor_SetsName()
 {
     const string expectedName = "Service";
     var imposter = new HttpImposter(123, expectedName);
     Assert.AreEqual(expectedName, imposter.Name);
 }
 public void Constructor_InitializesStubsCollection()
 {
     var imposter = new HttpImposter(123, null);
     Assert.IsNotNull(imposter.Stubs);
 }
 public void AddStub_AddsStubToCollection()
 {
     var imposter = new HttpImposter(123, null);
     imposter.AddStub();
     Assert.AreEqual(1, imposter.Stubs.Count);
 }
        public void Submit_CallsSubmitOnAllPendingImposters()
        {
            const int firstPortNumber = 123;
            const int secondPortNumber = 456;

            var imposter1 = new HttpImposter(firstPortNumber, null);
            var imposter2 = new HttpImposter(secondPortNumber, null);

            _client.Submit(new [] { imposter1, imposter2});

            _mockRequestProxy.Verify(x => x.CreateImposter(It.Is<Imposter>(imp => imp.Port == firstPortNumber)), Times.Once);
            _mockRequestProxy.Verify(x => x.CreateImposter(It.Is<Imposter>(imp => imp.Port == secondPortNumber)), Times.Once);
        }