public void WhenProductIsValid_CanReturnCubicWeight()
        {
            //Arrange
            var product  = FakeModels.TestProduct;
            var settings = new CubicWeightSettings()
            {
                ConversionFactor = 1
            };

            var stubILogger           = StubHelper.StubILogger <CubicWeightService>();
            var stubIExceptionFactory = StubHelper.StubIExceptionFactory;
            var stubIFetchService     = StubHelper.StubIFetchService;

            var testedService = new CubicWeightService(stubILogger.Object,
                                                       stubIExceptionFactory.Object,
                                                       stubIFetchService.Object,
                                                       Options.Create(settings));

            //Act
            var actual = testedService.WeightCalculator(product);

            //Assert
            var weight = product.Size.CubicMetres * settings.ConversionFactor;

            Assert.Equal(weight, actual);
        }
 public FetchService(
     ILogger <FetchService> logger,
     IRestApiService restApiService,
     IOptions <CubicWeightSettings> settings)
 {
     _logger         = logger;
     _restApiService = restApiService;
     _settings       = settings.Value;
 }
Exemplo n.º 3
0
 public CubicWeightService(
     ILogger <CubicWeightService> logger,
     IExceptionFactory exceptionFactory,
     IFetchService fetchService,
     IOptions <CubicWeightSettings> settings)
 {
     _logger           = logger;
     _exceptionFactory = exceptionFactory;
     _fetchService     = fetchService;
     _settings         = settings.Value;
 }
        public void WhenSizeIsNull_CanReturnZero()
        {
            //Arrange
            var emptyProduct = new Product();
            var settings     = new CubicWeightSettings()
            {
                ConversionFactor = 250
            };

            var stubILogger           = StubHelper.StubILogger <CubicWeightService>();
            var stubIExceptionFactory = StubHelper.StubIExceptionFactory;
            var stubIFetchService     = StubHelper.StubIFetchService;

            var testedService = new CubicWeightService(stubILogger.Object,
                                                       stubIExceptionFactory.Object,
                                                       stubIFetchService.Object,
                                                       Options.Create(settings));

            //Act
            var actual = testedService.WeightCalculator(emptyProduct);

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