Exemplo n.º 1
0
        public void Read_IdExisting_ReturnsProductMetricWithSpecifiedId()
        {
            //Arrange
            int           existingId = 12;
            ProductMetric expected   = new ProductMetric
            {
                Id      = existingId,
                Name    = "Oversized Hoodie",
                MetricX = "",
                MetricY = "Length",
                MetricZ = "Sleeve Length"
            };

            Mock <IProductMetricRepository> productMetricRepository = new Mock <IProductMetricRepository>();

            productMetricRepository.Setup(repo => repo.Read(existingId)).
            Returns(expected);

            IProductMetricService productMetricService = new ProductMetricService(productMetricRepository.Object);

            //Act
            ProductMetric actual = productMetricService.Read(existingId);

            //Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
        public void Read_IdNonExisting_ReturnsNull()
        {
            //Arrange
            int           existingId = 12;
            ProductMetric expected   = null;

            Mock <IProductMetricRepository> productMetricRepository = new Mock <IProductMetricRepository>();

            productMetricRepository.Setup(repo => repo.Read(existingId)).
            Returns(expected);

            IProductMetricService productMetricService = new ProductMetricService(productMetricRepository.Object);

            //Act
            ProductMetric actual = productMetricService.Read(existingId);

            //Assert
            Assert.Equal(expected, actual);
        }