Esempio n. 1
0
        public void GetProperty_ShouldReturnCorrectProperty()
        {
            // Arrange
            Seed(_context);

            // Act
            IActionResult result = _controller.GetById(2) ;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(_context.Properties.FindAsync(2).Result, result);
        }
Esempio n. 2
0
        public void GetReturnsProductWithSameId()
        {
            // Arrange
            var mockRepository = new Mock <IPropertyRepository>();

            mockRepository.Setup(x => x.GetById(42)).Returns(new Property {
                Id = 42
            });

            var controller = new PropertiesController(mockRepository.Object);

            // Act
            IHttpActionResult actionResult = controller.GetById(42);
            var contentResult = actionResult as OkNegotiatedContentResult <Property>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(42, contentResult.Content.Id);
        }