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 GetImportsText_FileNameConvertersNull_ExceptionThrown() { //arrange var generatorOptionsProvider = new GeneratorOptionsProvider { GeneratorOptions = new GeneratorOptions { FileNameConverters = null } }; //act,assert var tsContentGenerator = new TsContentGenerator(_typeDependencyService, _typeService, _templateService, _tsContentParser, _metadataReaderFactory, generatorOptionsProvider, null); Assert.Throws <ArgumentNullException>(() => tsContentGenerator.GetImportsText(typeof(string), "asdf")); }
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)); }