Ejemplo n.º 1
0
        public void ShouldReturnHealthStatus()
        {
            var expected = new HealthStatus()
            {
                IsElasticsearchServerAvailable = true,
                IsMailServerAvailable          = true,
                IsMessageQueueServerAvailable  = true,
            };
            var content      = JsonConvert.SerializeObject(expected);
            var restResponse = new RestResponse()
            {
                Content = content
            };

            MockRestClient.Setup(x => x.Execute(It.Is <RestRequest>(y => y.Resource == HealthStatusName)))
            .Returns(restResponse);
            MockJsonConvert.Setup(x => x.DeserializeObject <HealthStatus>(content))
            .Returns(expected);

            var actual = Subject.GetHealthStatus();

            Assert.That(actual, Is.EqualTo(expected));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource == HealthStatusName)), Times.Once);
            MockJsonConvert.Verify(x => x.DeserializeObject <HealthStatus>(content), Times.Once);
        }
Ejemplo n.º 2
0
        public void ShouldGetCollectionOfResourceStubs()
        {
            var expected     = new List <ResourceStub>();
            var content      = JsonConvert.SerializeObject(expected);
            var restResponse = new RestResponse()
            {
                Content = content
            };

            MockRestClient.Setup(x => x.Execute(It.Is <RestRequest>(y => y.Resource == ResourceStubName)))
            .Returns(restResponse);
            MockJsonConvert.Setup(x => x.DeserializeObject <IList <ResourceStub> >(content))
            .Returns(expected);

            var actual = Subject.GetCollection <ResourceStub>();

            Assert.That(actual.ToList(), Is.EquivalentTo(expected));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource == ResourceStubName)), Times.Once);
            MockJsonConvert.Verify(x => x.DeserializeObject <IList <ResourceStub> >(content), Times.Once);
        }
Ejemplo n.º 3
0
        public void ShouldCreateAndReturnResourceStub()
        {
            var expected     = new ResourceStub();
            var content      = JsonConvert.SerializeObject(expected);
            var restResponse = new RestResponse()
            {
                Content = content
            };

            MockRestClient.Setup(x => x.Execute(It.Is <RestRequest>(y => y.Resource == ResourceStubName)))
            .Returns(restResponse);
            MockJsonConvert.Setup(x => x.DeserializeObject <ResourceStub>(content))
            .Returns(expected);

            var actual = Subject.Create(expected);

            Assert.That(actual, Is.EqualTo(expected));
            MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource == ResourceStubName)), Times.Once);
            MockJsonConvert.Verify(x => x.DeserializeObject <ResourceStub>(content), Times.Once);
        }