示例#1
0
        public void FromDna_InvalidDna_ThrowsException()
        {
            // Arrange
            // Arrange
            var dna = new QuantityDna
            {
                QuantityType = (QuantityType)ushort.MaxValue,
            };

            // Act and assert
            Assert.Throws <ArgumentException>(() => QuantityFactory.FromDna(dna, 0));
        }
示例#2
0
        public void FromDna_ValidDna_CreatesQuantity(QuantityType type, ushort unitType, Type expectedType)
        {
            // Arrange
            var dna = new QuantityDna
            {
                QuantityType = type,
                UnitType     = unitType
            };

            // Act
            var result = QuantityFactory.FromDna(dna, 0);

            // Assert
            Assert.That(result.GetType(), Is.EqualTo(expectedType));
        }
示例#3
0
        public void FromDna_ValidDna_QuantityCreated(QuantityType actualType, ushort actualSubType, ushort actualPrefix, Type expectedType)
        {
            // Arrange
            var dna = new QuantityDna()
            {
                QuantityType = actualType,
                UnitType     = actualSubType,
                UnitSubType  = actualPrefix
            };

            const int value = 100;

            // Act
            var actualResult = QuantityFactory.FromDna(dna, value);

            // Assert
            Assert.That(actualResult, Is.InstanceOf(expectedType));
            Assert.That(actualResult.Value, Is.EqualTo(value));
            Assert.That(actualResult.UnitSubType, Is.EqualTo(actualPrefix));
        }