示例#1
0
        public void ReturnsCorrectResponseWhenNotFound()
        {
            var expectedResult = new GetPropertyUseCase.GetPropertyByRefResponse(null);

            _mockGetPropertyUseCase.Setup(m => m.Execute(It.IsAny <string>())).Returns(expectedResult);
            _classUnderTest = new PropertyController(_mockGetPropertyUseCase.Object, _mockLogger.Object, null, null);

            var response = _classUnderTest.GetByReference("foo");

            Assert.NotNull(response);
            Assert.IsInstanceOf(typeof(NotFoundResult), response);
        }
示例#2
0
        public void ReturnsCorrectResponseWithOkStatus()
        {
            var expectedResult = new GetPropertyUseCase.GetPropertyByRefResponse(new Property
            {
                PropRef   = faker.Random.String(12),
                Telephone = faker.Phone.PhoneNumber()
            });

            _mockGetPropertyUseCase.Setup(m => m.Execute(It.IsAny <string>())).Returns(expectedResult);
            _classUnderTest = new PropertyController(_mockGetPropertyUseCase.Object, _mockLogger.Object, null, null);

            var response = _classUnderTest.GetByReference("foo");

            Assert.NotNull(response);
            Assert.AreEqual(200, ((ObjectResult)response).StatusCode);
            Assert.AreEqual(JsonConvert.SerializeObject(expectedResult.Property),
                            JsonConvert.SerializeObject(((ObjectResult)response).Value));
        }