Пример #1
0
        public void Create_ProductMetricValid_ReturnsCreatedProductMetricWithId()
        {
            //Arrange
            ProductMetric validProductMetric = new ProductMetric
            {
                Name    = "Oversized Hoodie",
                MetricX = "Width",
                MetricY = "Length",
                MetricZ = "Sleeve Length"
            };
            ProductMetric expected = new ProductMetric
            {
                Id      = 1,
                Name    = "Oversized Hoodie",
                MetricX = "Width",
                MetricY = "Length",
                MetricZ = "Sleeve Length"
            };

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

            productMetricRepository.Setup(repo => repo.Create(validProductMetric)).
            Returns(expected);
            Mock <IProductModelRepository> productModelRepository = new Mock <IProductModelRepository>();

            IProductMetricService productMetricService = new ProductMetricService(productMetricRepository.Object);

            //Act
            ProductMetric actual = productMetricService.Create(validProductMetric);

            //Assert
            Assert.Equal(expected, actual);
        }
Пример #2
0
        public void Create_ProductMetricNull_ThrowsArgumentNullException()
        {
            //Arrange
            ProductMetric invalidProductMetric = null;

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

            IProductMetricService productMetricService = new ProductMetricService(productMetricRepository.Object);

            //Act
            Action actual = () => productMetricService.Create(invalidProductMetric);

            //Assert
            Assert.Throws <ArgumentNullException>(actual);
        }
Пример #3
0
        public void Create_NameNull_ThrowsArgumentException()
        {
            //Arrange
            ProductMetric invalidProductMetric = new ProductMetric
            {
                Name    = null,
                MetricX = "Width",
                MetricY = "Length",
                MetricZ = "Sleeve Length"
            };

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

            IProductMetricService productMetricService = new ProductMetricService(productMetricRepository.Object);

            //Act
            Action actual = () => productMetricService.Create(invalidProductMetric);

            //Assert
            Assert.Throws <ArgumentException>(actual);
        }