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
371d341c
Commit
371d341c
authored
May 12, 2016
by
Jon Skeet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1518 from jskeet/move_test
Move test for standalone BoolValue to JsonParserTest
parents
920ee735
7cc9cb40
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
7 deletions
+19
-7
JsonFormatterTest.cs
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
+16
-0
JsonParserTest.cs
csharp/src/Google.Protobuf.Test/JsonParserTest.cs
+3
-0
WrappersTest.cs
...p/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
+0
-7
No files found.
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
View file @
371d341c
...
...
@@ -512,6 +512,22 @@ namespace Google.Protobuf
Assert
.
Throws
<
InvalidOperationException
>(()
=>
JsonFormatter
.
Default
.
Format
(
any
));
}
[
Test
]
[
TestCase
(
typeof
(
BoolValue
),
true
,
"true"
)]
[
TestCase
(
typeof
(
Int32Value
),
32
,
"32"
)]
[
TestCase
(
typeof
(
Int64Value
),
32L
,
"\"32\""
)]
[
TestCase
(
typeof
(
UInt32Value
),
32U
,
"32"
)]
[
TestCase
(
typeof
(
UInt64Value
),
32U
L
,
"\"32\""
)]
[
TestCase
(
typeof
(
StringValue
),
"foo"
,
"\"foo\""
)]
[
TestCase
(
typeof
(
FloatValue
),
1.5f
,
"1.5"
)]
[
TestCase
(
typeof
(
DoubleValue
),
1.5d
,
"1.5"
)]
public
void
Wrappers_Standalone
(
System
.
Type
wrapperType
,
object
value
,
string
expectedJson
)
{
IMessage
populated
=
(
IMessage
)
Activator
.
CreateInstance
(
wrapperType
);
populated
.
Descriptor
.
Fields
[
WrappersReflection
.
WrapperValueFieldNumber
].
Accessor
.
SetValue
(
populated
,
value
);
Assert
.
AreEqual
(
expectedJson
,
JsonFormatter
.
Default
.
Format
(
populated
));
}
/// <summary>
/// Checks that the actual JSON is the same as the expected JSON - but after replacing
/// all apostrophes in the expected JSON with double quotes. This basically makes the tests easier
...
...
csharp/src/Google.Protobuf.Test/JsonParserTest.cs
View file @
371d341c
...
...
@@ -133,9 +133,12 @@ namespace Google.Protobuf
}
[
Test
]
[
TestCase
(
typeof
(
BoolValue
),
"true"
,
true
)]
[
TestCase
(
typeof
(
Int32Value
),
"32"
,
32
)]
[
TestCase
(
typeof
(
Int64Value
),
"32"
,
32L
)]
[
TestCase
(
typeof
(
Int64Value
),
"\"32\""
,
32L
)]
[
TestCase
(
typeof
(
UInt32Value
),
"32"
,
32U
)]
[
TestCase
(
typeof
(
UInt64Value
),
"\"32\""
,
32U
L
)]
[
TestCase
(
typeof
(
UInt64Value
),
"32"
,
32U
L
)]
[
TestCase
(
typeof
(
StringValue
),
"\"foo\""
,
"foo"
)]
[
TestCase
(
typeof
(
FloatValue
),
"1.5"
,
1.5f
)]
...
...
csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
View file @
371d341c
...
...
@@ -417,12 +417,5 @@ namespace Google.Protobuf.WellKnownTypes
TestWellKnownTypes
.
Descriptor
.
Fields
[
TestWellKnownTypes
.
StringFieldFieldNumber
].
Accessor
.
Clear
(
message
);
Assert
.
IsNull
(
message
.
StringField
);
}
[
Test
]
public
void
GivenBoolValueWhenPerformingRoundTripEncodingViaJsonThenShouldNotExpectObjectAtTopLevel
()
{
var
value
=
new
BoolValue
{
Value
=
true
};
Assert
.
AreEqual
(
value
,
JsonParser
.
Default
.
Parse
<
BoolValue
>(
JsonFormatter
.
Default
.
Format
(
value
)));
}
}
}
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