Skip to content

Commit 008225c

Browse files
committed
add additional example for #5 (currently missing part of the expected output)
1 parent 8aadcc1 commit 008225c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/protobuf-net.Grpc.Reflection.Test/SchemaGeneration.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,55 @@ public enum Category
9797
Foo = 1,
9898
Bar = 2,
9999
}
100+
101+
[ServiceContract]
102+
public interface IConferencesService
103+
{
104+
Task<IEnumerable<ConferenceOverview>> ListConferencesEnumerable();
105+
IAsyncEnumerable<ConferenceOverview> ListConferencesAsyncEnumerable();
106+
Task<ListConferencesResult> ListConferencesWrapped();
107+
}
108+
109+
[DataContract]
110+
public class ConferenceOverview
111+
{
112+
[DataMember(Order = 1)]
113+
public Guid ID { get; set; }
114+
115+
[DataMember(Order = 2)]
116+
public string? Title { get; set; }
117+
}
118+
119+
[DataContract]
120+
public class ListConferencesResult
121+
{
122+
[ProtoMember(1)]
123+
public List<ConferenceOverview> Conferences { get; } = new List<ConferenceOverview>();
124+
}
125+
126+
[Fact]
127+
public void ConferenceServiceSchema()
128+
{
129+
var generator = new SchemaGenerator();
130+
var proto = generator.GetSchema<IConferencesService>();
131+
Log(proto);
132+
Assert.Equal(@"syntax = ""proto3"";
133+
package protobuf_net.Grpc.Reflection.Test;
134+
import ""google/protobuf/empty.proto"";
135+
136+
message ConferenceOverview {
137+
string ID = 1; // default value could not be applied: 00000000-0000-0000-0000-000000000000
138+
string Title = 2;
139+
}
140+
message ListConferencesResult {
141+
repeated ConferenceOverview Conferences = 1;
142+
}
143+
service ConferencesService {
144+
rpc ListConferencesAsyncEnumerable (.google.protobuf.Empty) returns (stream ConferenceOverview);
145+
rpc ListConferencesEnumerable (.google.protobuf.Empty) returns (IEnumerable_ConferenceOverview);
146+
rpc ListConferencesWrapped (.google.protobuf.Empty) returns (ListConferencesResult);
147+
}
148+
", proto, ignoreLineEndingDifferences: true);
149+
}
100150
}
101151
}

0 commit comments

Comments
 (0)