예제 #1
0
        public void PrefixFactor_Then_ResultShouldBe1()
        {
            var testee = new Unit("m");

            var result = testee.PrefixFactor;

            result.Should().Be(1);
        }
예제 #2
0
        public void GetPrefixedUnit_Then_ResultPrefixFactorShouldBeExpectedPrefixFactor(double expectedPrefixFactor)
        {
            var testee = new Unit("m");

            var result = testee.GetPrefixedUnit(Prefixes.Kilo);

            result.PrefixFactor.Should().Be(expectedPrefixFactor);
        }
예제 #3
0
        public void Notation_Then_ResultShouldBeExpected()
        {
            const string ExpectedNotation = "g";
            var testee = new Unit(ExpectedNotation);

            var result = testee.Notation;

            result.Should().Be(ExpectedNotation);
        }
예제 #4
0
        public void GetNotationWithoutPrefix_ThenResultShouldBeExpectedNotation()
        {
            const string ExpectedNotation = "m";
            var testee = new Unit(Prefixes.Kilo, ExpectedNotation);

            var result = testee.GetNotationWithoutPrefix();

            result.Should().Be(ExpectedNotation);
        }
예제 #5
0
        public void GetPrefixedUnit_Then_ResultNotationShouldBeExpectedNotation()
        {
            const string ExpectedNotation = "km";
            var testee = new Unit("m");

            var result = testee.GetPrefixedUnit(Prefixes.Kilo);

            result.Notation.Should().Be(ExpectedNotation);
        }
        private static IUnit GetUnit(string lhsUnit)
        {
            var unit = new Unit(lhsUnit.Cast<char>().Last().ToString());
            if (lhsUnit.Length == 2)
            {
                var notation = lhsUnit[0].ToString();
                return unit.GetPrefixedUnit(new FactoredPrefix(notation, 1000, notation));
            }

            return unit;
        }