예제 #1
0
        static void LimitedIntegerTypeNormaliseTests(string value, string expectedStr)
        {
            var actual   = (LimitedIntegerType)TestCommon.MakeDataType(DataType.LimitedInteger, value);
            var expected = BigInteger.Parse(expectedStr);

            actual.Value.Should().Be(expected);
        }
예제 #2
0
 public void MakeDataTypeCoversAllDataTypes()
 {
     foreach (var dataType in EnumExtensions.GetEnumCollection <DataType>())
     {
         Action act = () => TestCommon.MakeDataType(dataType);
         act.Should().NotThrow <TestOperationException>();
     }
 }
예제 #3
0
        static void LimitedIntegerTypesBitwidthCasts(string a, string b, string expected)
        {
            var intA   = (LimitedIntegerType)TestCommon.MakeDataType(DataType.LimitedInteger, a);
            var intB   = (LimitedIntegerType)TestCommon.MakeDataType(DataType.LimitedInteger, b);
            var intExp = (LimitedIntegerType)TestCommon.MakeDataType(DataType.LimitedInteger, expected);

            var actual = (LimitedIntegerType)TestCommon.Operate(null, OperatorType.Add, intA, intB);

            actual.Value.Should().Be(intExp.Value);
            actual.SignAndBitWidth.Should().Be(intExp.SignAndBitWidth);
        }
예제 #4
0
 public void AllSupportedTypeCastsWorkCorrectly()
 {
     foreach (var cast in DataMapper.AllTypeCasts.Value)
     {
         var dataValue = TestCommon.MakeDataType(cast.Key);
         foreach (var val in cast.Value)
         {
             ((Action)(() => dataValue.CastTo(val, null))).Should().NotThrow($"a cast from {cast.Key} to {val} should be supported");
             dataValue.CastTo(val, null).DataType.Should().Be(val);
         }
     }
 }
예제 #5
0
        static internal TDataType MakeDataType <TDataType>(DataType dataType, string value = "")
            where TDataType : class, IDataType <DataType>
        {
            var dataTypeInst = string.IsNullOrWhiteSpace(value)
                ? TestCommon.MakeDataType(dataType)
                : TestCommon.MakeDataType(dataType, value);

            dataTypeInst.Should().NotBeNull();
            dataTypeInst.Should().BeOfType <TDataType>();
            var typedDataType = dataTypeInst as TDataType;

            typedDataType.Should().NotBeNull();
            return(typedDataType);
        }