Beispiel #1
0
        public static string ToFlagString(this StrictNullTypeUnionFlags strictNullTypeUnionFlags)
        {
            var result = "";

            if (strictNullTypeUnionFlags.HasFlag(StrictNullTypeUnionFlags.Null))
            {
                result += "null ";
            }
            if (strictNullTypeUnionFlags.HasFlag(StrictNullTypeUnionFlags.Undefined))
            {
                result += "undefined ";
            }

            return(result.TrimEnd().Replace(" ", "|"));
        }
Beispiel #2
0
        public void GetTsTypeName_MemberGiven_TsTypeNameReturned(MemberInfo memberInfo, TypeNameConverterCollection converters,
                                                                 StrictNullTypeUnionFlags csNullableTranslation, string expectedResult)
        {
            //arrange
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = new GeneratorOptions
                {
                    TypeNameConverters    = converters,
                    CsNullableTranslation = csNullableTranslation
                }
            };

            _typeService = new TypeService(_metadataReaderFactory, generatorOptionsProvider);

            //act
            string actualResult = _typeService.GetTsTypeName(memberInfo);

            //assert
            Assert.Equal(expectedResult, actualResult);
        }
Beispiel #3
0
        public void ToStrictNullFlags_StringTranslationGiven_FlagsReturned(string input, StrictNullTypeUnionFlags expectedResult)
        {
            StrictNullTypeUnionFlags actualResult = input.ToStrictNullFlags();

            Assert.Equal(expectedResult, actualResult);
        }
Beispiel #4
0
        public void ToFlagString_FlagsGiven_StringTranslationReturned(StrictNullTypeUnionFlags typeUnionFlags, string expectedResult)
        {
            string actualResult = typeUnionFlags.ToFlagString();

            Assert.Equal(expectedResult, actualResult);
        }