Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
c32ac415
Commit
c32ac415
authored
Oct 22, 2015
by
Jeremy Meng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test project to build with dnxcore.
parent
136279bb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
10 deletions
+69
-10
BasicOps.cs
StackExchange.Redis.Tests/BasicOps.cs
+8
-0
Config.cs
StackExchange.Redis.Tests/Config.cs
+4
-0
Naming.cs
StackExchange.Redis.Tests/Naming.cs
+51
-8
Profiling.cs
StackExchange.Redis.Tests/Profiling.cs
+5
-2
project.json
...is.Tests_dnxcore50/StackExchange.Redis.Tests/project.json
+1
-0
No files found.
StackExchange.Redis.Tests/BasicOps.cs
View file @
c32ac415
...
@@ -239,7 +239,15 @@ public void MassiveBulkOpsAsync(bool preserveOrder, bool withContinuation)
...
@@ -239,7 +239,15 @@ public void MassiveBulkOpsAsync(bool preserveOrder, bool withContinuation)
Action
<
Task
>
nonTrivial
=
delegate
Action
<
Task
>
nonTrivial
=
delegate
{
{
#if !NETCORE
Thread
.
SpinWait
(
5
);
Thread
.
SpinWait
(
5
);
#else
var
spinWait
=
new
SpinWait
();
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
spinWait
.
SpinOnce
();
}
#endif
};
};
var
watch
=
Stopwatch
.
StartNew
();
var
watch
=
Stopwatch
.
StartNew
();
for
(
int
i
=
0
;
i
<=
AsyncOpsQty
;
i
++)
for
(
int
i
=
0
;
i
<=
AsyncOpsQty
;
i
++)
...
...
StackExchange.Redis.Tests/Config.cs
View file @
c32ac415
...
@@ -144,7 +144,11 @@ public void ReadConfig()
...
@@ -144,7 +144,11 @@ public void ReadConfig()
var
all
=
conn
.
ConfigGet
();
var
all
=
conn
.
ConfigGet
();
Assert
.
IsTrue
(
all
.
Length
>
0
,
"any"
);
Assert
.
IsTrue
(
all
.
Length
>
0
,
"any"
);
#if !NETCORE
var
pairs
=
all
.
ToDictionary
(
x
=>
(
string
)
x
.
Key
,
x
=>
(
string
)
x
.
Value
,
StringComparer
.
InvariantCultureIgnoreCase
);
var
pairs
=
all
.
ToDictionary
(
x
=>
(
string
)
x
.
Key
,
x
=>
(
string
)
x
.
Value
,
StringComparer
.
InvariantCultureIgnoreCase
);
#else
var
pairs
=
all
.
ToDictionary
(
x
=>
(
string
)
x
.
Key
,
x
=>
(
string
)
x
.
Value
,
StringComparer
.
OrdinalIgnoreCase
);
#endif
Assert
.
AreEqual
(
all
.
Length
,
pairs
.
Count
);
Assert
.
AreEqual
(
all
.
Length
,
pairs
.
Count
);
Assert
.
IsTrue
(
pairs
.
ContainsKey
(
"timeout"
),
"timeout"
);
Assert
.
IsTrue
(
pairs
.
ContainsKey
(
"timeout"
),
"timeout"
);
...
...
StackExchange.Redis.Tests/Naming.cs
View file @
c32ac415
...
@@ -17,7 +17,7 @@ public class Naming
...
@@ -17,7 +17,7 @@ public class Naming
public
void
CheckSignatures
(
Type
type
,
bool
isAsync
)
public
void
CheckSignatures
(
Type
type
,
bool
isAsync
)
{
{
// check that all methods and interfaces look appropriate for their sync/async nature
// check that all methods and interfaces look appropriate for their sync/async nature
CheckName
(
type
,
isAsync
);
CheckName
(
type
.
GetTypeInfo
()
,
isAsync
);
var
members
=
type
.
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
Static
|
BindingFlags
.
DeclaredOnly
);
var
members
=
type
.
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
Static
|
BindingFlags
.
DeclaredOnly
);
foreach
(
var
member
in
members
)
foreach
(
var
member
in
members
)
{
{
...
@@ -29,9 +29,9 @@ public void CheckSignatures(Type type, bool isAsync)
...
@@ -29,9 +29,9 @@ public void CheckSignatures(Type type, bool isAsync)
[
Test
]
[
Test
]
public
void
ShowReadOnlyOperations
()
public
void
ShowReadOnlyOperations
()
{
{
var
msg
=
typeof
(
ConnectionMultiplexer
).
Assembly
.
GetType
(
"StackExchange.Redis.Message"
);
var
msg
=
typeof
(
ConnectionMultiplexer
).
GetTypeInfo
().
Assembly
.
GetType
(
"StackExchange.Redis.Message"
);
Assert
.
IsNotNull
(
msg
,
"Message"
);
Assert
.
IsNotNull
(
msg
,
"Message"
);
var
cmd
=
typeof
(
ConnectionMultiplexer
).
Assembly
.
GetType
(
"StackExchange.Redis.RedisCommand"
);
var
cmd
=
typeof
(
ConnectionMultiplexer
).
GetTypeInfo
().
Assembly
.
GetType
(
"StackExchange.Redis.RedisCommand"
);
Assert
.
IsNotNull
(
cmd
,
"RedisCommand"
);
Assert
.
IsNotNull
(
cmd
,
"RedisCommand"
);
var
method
=
msg
.
GetMethod
(
"IsMasterOnly"
,
BindingFlags
.
Static
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Public
);
var
method
=
msg
.
GetMethod
(
"IsMasterOnly"
,
BindingFlags
.
Static
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Public
);
Assert
.
IsNotNull
(
method
,
"IsMasterOnly"
);
Assert
.
IsNotNull
(
method
,
"IsMasterOnly"
);
...
@@ -89,7 +89,7 @@ static bool UsesKey(Type type)
...
@@ -89,7 +89,7 @@ static bool UsesKey(Type type)
{
{
if
(
UsesKey
(
type
.
GetElementType
()))
return
true
;
if
(
UsesKey
(
type
.
GetElementType
()))
return
true
;
}
}
if
(
type
.
IsGenericType
)
// KVP, etc
if
(
type
.
GetTypeInfo
().
IsGenericType
)
// KVP, etc
{
{
var
args
=
type
.
GetGenericArguments
();
var
args
=
type
.
GetGenericArguments
();
if
(
args
.
Any
(
UsesKey
))
return
true
;
if
(
args
.
Any
(
UsesKey
))
return
true
;
...
@@ -139,7 +139,7 @@ public void CheckSyncAsyncMethodsMatch(Type from, Type to)
...
@@ -139,7 +139,7 @@ public void CheckSyncAsyncMethodsMatch(Type from, Type to)
{
{
huntType
=
null
;
huntType
=
null
;
}
}
else
if
(
method
.
ReturnType
.
IsSubclassOf
(
typeof
(
Task
)))
else
if
(
method
.
ReturnType
.
GetTypeInfo
().
IsSubclassOf
(
typeof
(
Task
)))
{
{
huntType
=
method
.
ReturnType
.
GetGenericArguments
()[
0
];
huntType
=
method
.
ReturnType
.
GetGenericArguments
()[
0
];
}
}
...
@@ -150,7 +150,12 @@ public void CheckSyncAsyncMethodsMatch(Type from, Type to)
...
@@ -150,7 +150,12 @@ public void CheckSyncAsyncMethodsMatch(Type from, Type to)
var
pFrom
=
method
.
GetParameters
();
var
pFrom
=
method
.
GetParameters
();
Type
[]
args
=
pFrom
.
Select
(
x
=>
x
.
ParameterType
).
ToArray
();
Type
[]
args
=
pFrom
.
Select
(
x
=>
x
.
ParameterType
).
ToArray
();
Assert
.
AreEqual
(
typeof
(
CommandFlags
),
args
.
Last
());
Assert
.
AreEqual
(
typeof
(
CommandFlags
),
args
.
Last
());
#if !NETCORE
var
found
=
to
.
GetMethod
(
huntName
,
flags
,
null
,
method
.
CallingConvention
,
args
,
null
);
var
found
=
to
.
GetMethod
(
huntName
,
flags
,
null
,
method
.
CallingConvention
,
args
,
null
);
#else
var
found
=
to
.
GetMethods
(
flags
)
.
SingleOrDefault
(
m
=>
m
.
Name
==
huntName
&&
m
.
HasMatchingParameterTypes
(
args
));
#endif
Assert
.
IsNotNull
(
found
,
"Found "
+
name
+
", no "
+
huntName
);
Assert
.
IsNotNull
(
found
,
"Found "
+
name
+
", no "
+
huntName
);
var
pTo
=
found
.
GetParameters
();
var
pTo
=
found
.
GetParameters
();
...
@@ -166,16 +171,24 @@ public void CheckSyncAsyncMethodsMatch(Type from, Type to)
...
@@ -166,16 +171,24 @@ public void CheckSyncAsyncMethodsMatch(Type from, Type to)
Console
.
WriteLine
(
"Validated: {0} ({1} methods)"
,
from
.
Name
,
count
);
Console
.
WriteLine
(
"Validated: {0} ({1} methods)"
,
from
.
Name
,
count
);
}
}
static
readonly
Type
ignoreType
=
typeof
(
ConnectionMultiplexer
).
Assembly
.
GetType
(
"StackExchange.Redis.IgnoreNamePrefixAttribute"
);
static
readonly
Type
ignoreType
=
typeof
(
ConnectionMultiplexer
).
GetTypeInfo
().
Assembly
.
GetType
(
"StackExchange.Redis.IgnoreNamePrefixAttribute"
);
void
CheckMethod
(
MethodInfo
method
,
bool
isAsync
)
void
CheckMethod
(
MethodInfo
method
,
bool
isAsync
)
{
{
#if DEBUG
#if DEBUG
#if !NETCORE
bool
ignorePrefix
=
ignoreType
!=
null
&&
Attribute
.
IsDefined
(
method
,
ignoreType
);
bool
ignorePrefix
=
ignoreType
!=
null
&&
Attribute
.
IsDefined
(
method
,
ignoreType
);
if
(
ignorePrefix
)
#else
bool
ignorePrefix
=
ignoreType
!=
null
&&
method
.
IsDefined
(
ignoreType
);
#endif
if
(
ignorePrefix
)
{
{
#if !NETCORE
Attribute
attrib
=
Attribute
.
GetCustomAttribute
(
method
,
ignoreType
);
Attribute
attrib
=
Attribute
.
GetCustomAttribute
(
method
,
ignoreType
);
if
((
bool
)
attrib
.
GetType
().
GetProperty
(
"IgnoreEntireMethod"
).
GetValue
(
attrib
))
#else
Attribute
attrib
=
method
.
GetCustomAttribute
(
ignoreType
);
#endif
if
((
bool
)
attrib
.
GetType
().
GetProperty
(
"IgnoreEntireMethod"
).
GetValue
(
attrib
))
{
{
return
;
return
;
}
}
...
@@ -212,4 +225,34 @@ void CheckName(MemberInfo member, bool isAsync)
...
@@ -212,4 +225,34 @@ void CheckName(MemberInfo member, bool isAsync)
else
Assert
.
IsFalse
(
member
.
Name
.
EndsWith
(
"Async"
),
member
.
Name
+
":Name - don't end *Async"
);
else
Assert
.
IsFalse
(
member
.
Name
.
EndsWith
(
"Async"
),
member
.
Name
+
":Name - don't end *Async"
);
}
}
}
}
public
static
class
ReflectionExtensions
{
#if !NETCORE
public
static
Type
GetTypeInfo
(
this
Type
type
)
{
return
type
;
}
#else
public
static
bool
HasMatchingParameterTypes
(
this
MethodInfo
method
,
Type
[]
paramTypes
)
{
var
types
=
method
.
GetParameters
().
Select
(
pi
=>
pi
.
ParameterType
).
ToArray
();
if
(
types
.
Length
!=
paramTypes
.
Length
)
{
return
false
;
}
for
(
int
i
=
0
;
i
<
types
.
Length
;
i
++)
{
if
(
types
[
i
]
!=
paramTypes
[
i
])
{
return
false
;
}
}
return
true
;
}
#endif
}
}
}
StackExchange.Redis.Tests/Profiling.cs
View file @
c32ac415
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
#if NETCORE
using
System.Reflection
;
#endif
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
NUnit.Framework
;
using
NUnit.Framework
;
using
System.Threading
;
using
System.Threading
;
...
@@ -456,11 +459,11 @@ public void LowAllocationEnumerable()
...
@@ -456,11 +459,11 @@ public void LowAllocationEnumerable()
conn
.
WaitAll
(
allTasks
.
ToArray
());
conn
.
WaitAll
(
allTasks
.
ToArray
());
var
res
=
conn
.
FinishProfiling
(
profiler
.
MyContext
);
var
res
=
conn
.
FinishProfiling
(
profiler
.
MyContext
);
Assert
.
IsTrue
(
res
.
GetType
().
IsValueType
);
Assert
.
IsTrue
(
res
.
GetType
().
GetTypeInfo
().
IsValueType
);
using
(
var
e
=
res
.
GetEnumerator
())
using
(
var
e
=
res
.
GetEnumerator
())
{
{
Assert
.
IsTrue
(
e
.
GetType
().
IsValueType
);
Assert
.
IsTrue
(
e
.
GetType
().
GetTypeInfo
().
IsValueType
);
Assert
.
IsTrue
(
e
.
MoveNext
());
Assert
.
IsTrue
(
e
.
MoveNext
());
var
i
=
e
.
Current
;
var
i
=
e
.
Current
;
...
...
StackExchange.Redis.Tests_dnxcore50/StackExchange.Redis.Tests/project.json
View file @
c32ac415
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
"dependencies"
:
{
"dependencies"
:
{
"System.Console"
:
"4.0.0-beta-*"
,
"System.Console"
:
"4.0.0-beta-*"
,
"System.Linq.Expressions"
:
"4.0.11-beta-*"
,
"System.Linq.Expressions"
:
"4.0.11-beta-*"
,
"System.Reflection.Extensions"
:
"4.0.1-beta-*"
,
"System.Threading.Tasks.Parallel"
:
"4.0.1-beta-*"
,
"System.Threading.Tasks.Parallel"
:
"4.0.1-beta-*"
,
"moq"
:
"4.3.0.0"
,
"moq"
:
"4.3.0.0"
,
"nunit"
:
"3.0.0-beta-5"
"nunit"
:
"3.0.0-beta-5"
...
...
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