public void TestProtoInput() { FileDescriptorSet files = new FileDescriptorSet(); Assert.Equal(0, files.file.Count); InputFileLoader.Merge(files, @"ProtoGen\descriptor.proto", Console.Error); Assert.Equal(1, files.file.Count); }
public void TestBinaryInput() { // compile .proto to .bin Process.Start("protoc", @"--descriptor_set_out=ProtoGen\descriptor.bin --include_imports ProtoGen\descriptor.proto").WaitForExit(); // process .bin FileDescriptorSet files = new FileDescriptorSet(); Assert.Equal(0, files.file.Count); InputFileLoader.Merge(files, @"ProtoGen\descriptor.bin", Console.Error); Assert.Equal(1, files.file.Count); }
public void TestGarbageInput() { FileDescriptorSet files = new FileDescriptorSet(); try { InputFileLoader.Merge(files, @"ProtoGen\InputLoader.cs", Console.Error); Assert.Fail("Should have barfed"); } catch (ProtoParseException ex) { bool sw = ex.Message.StartsWith("An error occurred parsing InputLoader.cs"); if (!sw) { Assert.Fail("Expected message not found: " + ex.Message); } } catch { Assert.Fail("Expected ArgumentException"); } }
public FileDescriptorSet LoadTypes(Stream ms = null) { var files = new FileDescriptorSet(); var args = string.Join(" ", (_includePaths ?? new string[0]) .Concat(_addToIncludePath ? _paths.Select(Path.GetDirectoryName) : new string[0]) .Where(Directory.Exists) .Select(o => o.ToLowerInvariant()) .Distinct() .Select(o => "-I " + o)); using (var sr = ms != null ? new StreamWriter(ms) : StreamWriter.Null) { foreach (var path in _paths .Where(File.Exists) .Select(o => o.ToLowerInvariant()) .Distinct()) { InputFileLoader.Merge(files, path, sr, args); } } return(files); }
public void TestMissingInput() { FileDescriptorSet files = new FileDescriptorSet(); InputFileLoader.Merge(files, @"ProtoGen\NoneSuch.bin", Console.Error); }
public void TestEmptyPath() { FileDescriptorSet files = new FileDescriptorSet(); InputFileLoader.Merge(files, "", Console.Error); }
public void TestNullPath() { FileDescriptorSet files = new FileDescriptorSet(); InputFileLoader.Merge(files, null, Console.Error); }
public void TestNullFileSet() { InputFileLoader.Merge(null, "abc", Console.Error); }