public void GetImportsText_TypeGiven_ImportsTextGenerated(Type type,
                                                                  string outputDir,
                                                                  TypeNameConverterCollection fileNameConverters,
                                                                  TypeNameConverterCollection typeNameConverters,
                                                                  IEnumerable <object> typeDependencies,
                                                                  string expectedOutput)
        {
            //arrange
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = new GeneratorOptions
                {
                    FileNameConverters = fileNameConverters,
                    TypeNameConverters = typeNameConverters
                }
            };

            _typeDependencyService.GetTypeDependencies(Arg.Any <Type>()).Returns(typeDependencies);
            _templateService.FillImportTemplate(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns(i => $"{i.ArgAt<string>(0)} | {i.ArgAt<string>(1)} | {i.ArgAt<string>(2)};");
            var tsContentGenerator = new TsContentGenerator(_typeDependencyService, _typeService, _templateService, _tsContentParser, _metadataReaderFactory, generatorOptionsProvider, null);

            //act
            string actualOutput = tsContentGenerator.GetImportsText(type, outputDir);

            //assert
            Assert.Equal(expectedOutput, actualOutput);
        }
        public void GetImportsText_TypeNull_ExceptionThrown()
        {
            //arrange
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = new GeneratorOptions()
            };
            var tsContentGenerator = new TsContentGenerator(_typeDependencyService, _typeService, _templateService, _tsContentParser, _metadataReaderFactory, generatorOptionsProvider, null);

            //act,assert
            Assert.Throws <ArgumentNullException>(() => tsContentGenerator.GetImportsText(null, "asdf"));
        }
        public void GetImplementsText_TypeNameConvertersNull_ExceptionThrown()
        {
            //arrange
            var generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = new GeneratorOptions {
                    TypeNameConverters = null
                }
            };
            var tsContentGenerator = new TsContentGenerator(_typeDependencyService, _typeService, _templateService, _tsContentParser, _metadataReaderFactory, generatorOptionsProvider, null);

            //act,assert
            Assert.Throws <ArgumentNullException>(() => tsContentGenerator.GetImplementsText(typeof(string)));
        }
        public void GetMemberValueText_MemberGiven_CorrectValueReturned(MemberInfo memberInfo, bool convertTypesToString, string expected)
        {
            //arrange
            ITypeService typeService = GetTypeService(convertTypesToString);
            var          generatorOptionsProvider = new GeneratorOptionsProvider {
                GeneratorOptions = new GeneratorOptions()
            };
            var tsContentGenerator = new TsContentGenerator(_typeDependencyService, typeService, _templateService, _tsContentParser, _metadataReaderFactory, generatorOptionsProvider, null);

            //act
            string actual = tsContentGenerator.GetMemberValueText(memberInfo);

            //assert
            Assert.Equal(expected, actual);
        }
        public void GetImportsText_TypeGiven_ImportsTextGenerated(Type type,
                                                                  string outputDir,
                                                                  TypeNameConverterCollection fileNameConverters,
                                                                  TypeNameConverterCollection typeNameConverters,
                                                                  IEnumerable <object> typeDependencies,
                                                                  IEnumerable <MemberInfo> tsExportableMembers,
                                                                  string expectedOutput)
        {
            _typeDependencyService.GetTypeDependencies(Arg.Any <Type>()).Returns(typeDependencies);
            _typeService.GetTsExportableMembers(Arg.Any <Type>()).Returns(tsExportableMembers);
            _templateService.FillImportTemplate(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns(i => $"{i.ArgAt<string>(0)} | {i.ArgAt<string>(1)} | {i.ArgAt<string>(2)};");
            var tsContentGenerator = new TsContentGenerator(_typeDependencyService, _typeService, _templateService, _tsContentParser, _metadataReader);

            string actualOutput = tsContentGenerator.GetImportsText(type, outputDir, fileNameConverters, typeNameConverters);

            Assert.Equal(expectedOutput, actualOutput);
        }
        public void GetImportsText_TypeNameConvertersNull_ExceptionThrown()
        {
            var tsContentGenerator = new TsContentGenerator(_typeDependencyService, _typeService, _templateService, _tsContentParser, _metadataReader);

            Assert.Throws <ArgumentNullException>(() => tsContentGenerator.GetImportsText(typeof(string), "asdf", new TypeNameConverterCollection(), null));
        }
        public void GetCustomHead_FilePathNull_ExceptionThrown()
        {
            var tsContentGenerator = new TsContentGenerator(_typeDependencyService, _typeService, _templateService, _tsContentParser, _metadataReader);

            Assert.Throws <ArgumentNullException>(() => tsContentGenerator.GetCustomHead(null));
        }
        public void GetExtendsText_TypeNull_ExceptionThrown()
        {
            var tsContentGenerator = new TsContentGenerator(_typeDependencyService, _typeService, _templateService, _tsContentParser, _metadataReader);

            Assert.Throws <ArgumentNullException>(() => tsContentGenerator.GetExtendsText(null, new TypeNameConverterCollection()));
        }
Esempio n. 9
0
        public void GetExtendsText_TypeNameConvertersNull_ExceptionThrown()
        {
            var tsContentGenerator = new TsContentGenerator(_typeDependencyService, _typeService, _templateService, _tsContentParser);

            Assert.Throws <ArgumentNullException>(() => tsContentGenerator.GetExtendsText(typeof(string), null));
        }