Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
0da4a89c
Commit
0da4a89c
authored
Jul 09, 2015
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Knock-on effects of moving GetSampleMessage.
parent
14f2222a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
GeneratedMessageTest.cs
csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs
+8
-8
No files found.
csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs
View file @
0da4a89c
...
@@ -603,7 +603,7 @@ namespace Google.Protobuf
...
@@ -603,7 +603,7 @@ namespace Google.Protobuf
[
Test
]
[
Test
]
public
void
Reflection_GetValue
()
public
void
Reflection_GetValue
()
{
{
var
message
=
GetSampleMessage
();
var
message
=
SampleMessages
.
CreateFullTestAllTypes
();
var
fields
=
message
.
Fields
;
var
fields
=
message
.
Fields
;
Assert
.
AreEqual
(
message
.
SingleBool
,
fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
GetValue
(
message
));
Assert
.
AreEqual
(
message
.
SingleBool
,
fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
GetValue
(
message
));
Assert
.
AreEqual
(
message
.
SingleBytes
,
fields
[
TestAllTypes
.
SingleBytesFieldNumber
].
GetValue
(
message
));
Assert
.
AreEqual
(
message
.
SingleBytes
,
fields
[
TestAllTypes
.
SingleBytesFieldNumber
].
GetValue
(
message
));
...
@@ -647,7 +647,7 @@ namespace Google.Protobuf
...
@@ -647,7 +647,7 @@ namespace Google.Protobuf
[
Test
]
[
Test
]
public
void
Reflection_Clear
()
public
void
Reflection_Clear
()
{
{
var
message
=
GetSampleMessage
();
var
message
=
SampleMessages
.
CreateFullTestAllTypes
();
var
fields
=
message
.
Fields
;
var
fields
=
message
.
Fields
;
fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
Clear
(
message
);
fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
Clear
(
message
);
fields
[
TestAllTypes
.
SingleInt32FieldNumber
].
Clear
(
message
);
fields
[
TestAllTypes
.
SingleInt32FieldNumber
].
Clear
(
message
);
...
@@ -657,7 +657,7 @@ namespace Google.Protobuf
...
@@ -657,7 +657,7 @@ namespace Google.Protobuf
fields
[
TestAllTypes
.
SingleForeignMessageFieldNumber
].
Clear
(
message
);
fields
[
TestAllTypes
.
SingleForeignMessageFieldNumber
].
Clear
(
message
);
fields
[
TestAllTypes
.
RepeatedDoubleFieldNumber
].
Clear
(
message
);
fields
[
TestAllTypes
.
RepeatedDoubleFieldNumber
].
Clear
(
message
);
var
expected
=
new
TestAllTypes
(
GetSampleMessage
())
var
expected
=
new
TestAllTypes
(
SampleMessages
.
CreateFullTestAllTypes
())
{
{
SingleBool
=
false
,
SingleBool
=
false
,
SingleInt32
=
0
,
SingleInt32
=
0
,
...
@@ -680,7 +680,7 @@ namespace Google.Protobuf
...
@@ -680,7 +680,7 @@ namespace Google.Protobuf
public
void
Reflection_SetValue_SingleFields
()
public
void
Reflection_SetValue_SingleFields
()
{
{
// Just a sample (primitives, messages, enums, strings, byte strings)
// Just a sample (primitives, messages, enums, strings, byte strings)
var
message
=
GetSampleMessage
();
var
message
=
SampleMessages
.
CreateFullTestAllTypes
();
var
fields
=
message
.
Fields
;
var
fields
=
message
.
Fields
;
fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
SetValue
(
message
,
false
);
fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
SetValue
(
message
,
false
);
fields
[
TestAllTypes
.
SingleInt32FieldNumber
].
SetValue
(
message
,
500
);
fields
[
TestAllTypes
.
SingleInt32FieldNumber
].
SetValue
(
message
,
500
);
...
@@ -690,7 +690,7 @@ namespace Google.Protobuf
...
@@ -690,7 +690,7 @@ namespace Google.Protobuf
fields
[
TestAllTypes
.
SingleForeignMessageFieldNumber
].
SetValue
(
message
,
new
ForeignMessage
{
C
=
12345
});
fields
[
TestAllTypes
.
SingleForeignMessageFieldNumber
].
SetValue
(
message
,
new
ForeignMessage
{
C
=
12345
});
fields
[
TestAllTypes
.
SingleDoubleFieldNumber
].
SetValue
(
message
,
20150701.5
);
fields
[
TestAllTypes
.
SingleDoubleFieldNumber
].
SetValue
(
message
,
20150701.5
);
var
expected
=
new
TestAllTypes
(
GetSampleMessage
())
var
expected
=
new
TestAllTypes
(
SampleMessages
.
CreateFullTestAllTypes
())
{
{
SingleBool
=
false
,
SingleBool
=
false
,
SingleInt32
=
500
,
SingleInt32
=
500
,
...
@@ -707,7 +707,7 @@ namespace Google.Protobuf
...
@@ -707,7 +707,7 @@ namespace Google.Protobuf
[
Test
]
[
Test
]
public
void
Reflection_SetValue_SingleFields_WrongType
()
public
void
Reflection_SetValue_SingleFields_WrongType
()
{
{
var
message
=
GetSampleMessage
();
var
message
=
SampleMessages
.
CreateFullTestAllTypes
();
var
fields
=
message
.
Fields
;
var
fields
=
message
.
Fields
;
Assert
.
Throws
<
InvalidCastException
>(()
=>
fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
SetValue
(
message
,
"This isn't a bool"
));
Assert
.
Throws
<
InvalidCastException
>(()
=>
fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
SetValue
(
message
,
"This isn't a bool"
));
}
}
...
@@ -723,7 +723,7 @@ namespace Google.Protobuf
...
@@ -723,7 +723,7 @@ namespace Google.Protobuf
[
Test
]
[
Test
]
public
void
Reflection_SetValue_RepeatedFields
()
public
void
Reflection_SetValue_RepeatedFields
()
{
{
var
message
=
GetSampleMessage
();
var
message
=
SampleMessages
.
CreateFullTestAllTypes
();
var
fields
=
message
.
Fields
;
var
fields
=
message
.
Fields
;
Assert
.
Throws
<
InvalidOperationException
>(()
=>
fields
[
TestAllTypes
.
RepeatedDoubleFieldNumber
].
SetValue
(
message
,
new
double
[
10
]));
Assert
.
Throws
<
InvalidOperationException
>(()
=>
fields
[
TestAllTypes
.
RepeatedDoubleFieldNumber
].
SetValue
(
message
,
new
double
[
10
]));
}
}
...
@@ -731,7 +731,7 @@ namespace Google.Protobuf
...
@@ -731,7 +731,7 @@ namespace Google.Protobuf
[
Test
]
[
Test
]
public
void
Reflection_GetValue_IncorrectType
()
public
void
Reflection_GetValue_IncorrectType
()
{
{
var
message
=
GetSampleMessage
();
var
message
=
SampleMessages
.
CreateFullTestAllTypes
();
Assert
.
Throws
<
InvalidCastException
>(()
=>
message
.
Fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
GetValue
(
new
TestMap
()));
Assert
.
Throws
<
InvalidCastException
>(()
=>
message
.
Fields
[
TestAllTypes
.
SingleBoolFieldNumber
].
GetValue
(
new
TestMap
()));
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment