Example #1
0
        public void TypeNotABaseType_ThrowsException()
        {
            // Arrange
            var node = ParserInput
                       .FromString("UserType")
                       .ParseInput(parser => parser.baseType());
            var parent = Substitute.For <IField>();

            // Act / Assert
            Assert.Throws <InvalidOperationException>(() => BaseType.Resolve(node, parent));
        }
Example #2
0
        public void CanResolveAllBaseTypes(string baseType, string requiredType, string optionalType)
        {
            // Arrange
            var node = ParserInput
                       .FromString(baseType)
                       .ParseInput(parser => parser.baseType());
            var parent = Substitute.For <IField>();

            // Act
            var type = BaseType.Resolve(node, parent);

            // Assert
            Assert.Equal(baseType, type.Name);
            Assert.Equal(requiredType, type.CSharpRequiredTypeName);
            Assert.Equal(optionalType, type.CSharpOptionalTypeName);
        }
Example #3
0
 public void IsAssignableFrom_ReturnsCorrectResult(BaseType targetType, BaseType expressionType, bool isAssignable)
 {
     Assert.Equal(isAssignable, targetType.IsAssignableFrom(expressionType));
 }