Exemplo n.º 1
0
        public void JTokensAreConvertedToAny(Type input)
        {
            var sut = new TypeDeterminer(CreatePropertySettings(), enumSettings, namespaceSettings);

            var actual = sut.Determine(input);

            Assert.That(actual.FormattedType, Is.EqualTo("any"));
            Assert.That(actual.Dependencies, Is.Empty);
        }
Exemplo n.º 2
0
        public void PrimitiveTypesAsExpected(Type input, string expected)
        {
            var sut = new TypeDeterminer(CreatePropertySettings(), enumSettings, namespaceSettings);

            var actual = sut.Determine(input);

            Assert.That(actual.FormattedType, Is.EqualTo(expected));
            Assert.That(actual.Dependencies, Is.Empty);
        }
Exemplo n.º 3
0
        public void GenericTypeIsTranslatedToGeneric()
        {
            var input = typeof(GenericClass <string, Product>);
            var sut   = new TypeDeterminer(CreatePropertySettings(), enumSettings, namespaceSettings);

            var actual = sut.Determine(input);

            Assert.That(actual.FormattedType, Is.EqualTo("TypescriptGenerator.Test.GenericClass<string,TestObjects.Product>"));
            Assert.That(actual.Dependencies, Is.EquivalentTo(new [] { typeof(GenericClass <,>), typeof(Product) }));
        }
Exemplo n.º 4
0
        public void DictionaryAsExpected()
        {
            var input = typeof(Dictionary <int, string>);
            var sut   = new TypeDeterminer(CreatePropertySettings(), enumSettings, namespaceSettings);

            var actual = sut.Determine(input);

            Assert.That(actual.FormattedType, Is.EqualTo("{ [key: number]: string }"));
            Assert.That(actual.Dependencies, Is.Empty);
        }
Exemplo n.º 5
0
        public void CollectionAsExpected()
        {
            var input = typeof(List <string>);
            var nullableStringConverter = new GenericTypeConverter(x => x == typeof(string), x => "string | null");
            var propertySettings        = CreatePropertySettings();

            propertySettings.TypeConverters.Add(nullableStringConverter);
            var sut = new TypeDeterminer(propertySettings, enumSettings, namespaceSettings);

            var actual = sut.Determine(input);

            Assert.That(actual.FormattedType, Is.EqualTo("(string | null)[]"));
            Assert.That(actual.Dependencies, Is.Empty);
        }