Exemplo n.º 1
0
        public void ShouldRunAllDefaultCasts()
        {
            IConverterRegistry converterRegistry = new ConverterRegistry();

            CastTestRunner.RunTests((testCase) =>
            {
                // Arrange
                var value = CastTestRunner.GenerateValueForType(testCase.SourceType);
                var generatedTestSuccessful = CastTestRunner.CastValueWithGeneratedCode(value, testCase.SourceType, testCase.TargetType, testCase.CastFlag);

                // Act
                var convertedObject = converterRegistry.TryConvert(
                    sourceType: testCase.SourceType,
                    targetType: testCase.TargetType,
                    value: value,
                    defaultReturnValue: null);

                // Assert
                var castResult   = new CastResult(convertedObject, testCase.CastFlag);
                var isSuccessful = CastTestRunner.AreEqual(
                    this.testOutputHelper,
                    testCase.SourceType,
                    testCase.TargetType,
                    generatedTestSuccessful,
                    castResult,
                    testCase.CastFlag);

                return(isSuccessful);
            });
        }
Exemplo n.º 2
0
        public void ShouldRunAllCasts()
        {
            CastTestRunner.RunTests(testCase =>
            {
                // Arrange
                var value = CastTestRunner.GenerateValueForType(testCase.SourceType);
                var generatedTestSuccessful = CastTestRunner.CastValueWithGeneratedCode(value, testCase.SourceType, testCase.TargetType, testCase.CastFlag);

                // Act
                var castResult = TypeHelper.CastTo(value, testCase.TargetType);

                // Assert
                var isSuccessful = CastTestRunner.AreEqual(
                    this.testOutputHelper,
                    testCase.SourceType,
                    testCase.TargetType,
                    generatedTestSuccessful,
                    castResult,
                    testCase.CastFlag);

                if (!isSuccessful)
                {
                    Debugger.Launch();
                }

                return(isSuccessful);
            });
        }