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); }
public void MakeDataTypeCoversAllDataTypes() { foreach (var dataType in EnumExtensions.GetEnumCollection <DataType>()) { Action act = () => TestCommon.MakeDataType(dataType); act.Should().NotThrow <TestOperationException>(); } }
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); }
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); } } }
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); }