示例#1
0
        public void LengthTimesLength_Returns_AreaQuantity()
        {
            // Arrange
            SiUnitSystemFactory siFactory = new SiUnitSystemFactory();
            IUnitSystem         siSystem  = siFactory.Create();

            StandardQuantitiesCatalog.Setup();

            // Act
            Quantity <float> width    = new Quantity <float>(2.0f, StandardUnitsCatalog.Meter);
            Quantity <float> height   = new Quantity <float>(4.0f, StandardUnitsCatalog.Meter);
            Quantity <float> resultm2 = (Quantity <float>)(width * height);

            IValueConverter converter = siSystem.CreateConverter(resultm2.Unit, StandardUnitsCatalog.SquareCentimeter);

            Assert.NotNull(converter);

            Quantity <float> resultcm2 = new Quantity <float>(converter.Convert(resultm2.Value), converter.Target);

            // Assert
            Assert.AreEqual(8.0f, resultm2.Value);
            Assert.AreEqual(StandardUnitsCatalog.SquareMeter, resultm2.Unit);
            Assert.AreEqual(StandardDimensionsCatalog.Area, resultm2.Dimension);
            Assert.AreEqual(StandardDimensionsCatalog.Area, resultcm2.Dimension);
            Assert.AreEqual(resultm2.Value * 100.0f * 100.0f, resultcm2.Value);
        }
示例#2
0
        public Program()
        {
            SiUnitSystemFactory siFactory = new SiUnitSystemFactory();

            _siSystem = siFactory.Create();
            StandardQuantitiesCatalog.Setup();
        }
示例#3
0
        public void Create_DoesNotThrow()
        {
            // Arrange
            SiUnitSystemFactory factory = new SiUnitSystemFactory();

            // Act/Assert
            Assert.DoesNotThrow(() => factory.Create());
        }
示例#4
0
        public void Create_ResultSupportsAllDerivedSiDimensions()
        {
            // Arrange
            SiUnitSystemFactory factory = new SiUnitSystemFactory();

            // Act
            IUnitSystem system = factory.Create();

            // Assert
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Area));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Pressure));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Volume));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Speed));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Force));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Energy));
        }
示例#5
0
        public void Create_ResultSupportsAllBaseSiDimensions()
        {
            // Arrange
            SiUnitSystemFactory factory = new SiUnitSystemFactory();

            // Act
            IUnitSystem system = factory.Create();

            // Assert
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.AmountOfSubstance));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.ElectricCurrent));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Length));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.LuminousIntensity));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Mass));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Time));
            Assert.True(system.SupportsDimension(StandardDimensionsCatalog.Temperature));
        }