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
5abe60bf
Commit
5abe60bf
authored
Feb 08, 2016
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConfigureAwait love for tests
parent
47301faa
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
26 deletions
+25
-26
Constraints.cs
MigratedBookSleeveTestSuite/Constraints.cs
+2
-2
Program.cs
MigratedBookSleeveTestSuite/Program.cs
+2
-3
Config.cs
StackExchange.Redis.Tests/Config.cs
+1
-1
FloatingPoint.cs
StackExchange.Redis.Tests/FloatingPoint.cs
+6
-6
SO25567566.cs
StackExchange.Redis.Tests/Issues/SO25567566.cs
+6
-6
Profiling.cs
StackExchange.Redis.Tests/Profiling.cs
+1
-1
TaskTests.cs
StackExchange.Redis.Tests/TaskTests.cs
+1
-1
Transactions.cs
StackExchange.Redis.Tests/Transactions.cs
+6
-6
No files found.
MigratedBookSleeveTestSuite/Constraints.cs
View file @
5abe60bf
...
@@ -35,7 +35,7 @@ public void TestManualIncr()
...
@@ -35,7 +35,7 @@ public void TestManualIncr()
public
async
Task
<
long
?>
ManualIncr
(
IDatabase
connection
,
string
key
)
public
async
Task
<
long
?>
ManualIncr
(
IDatabase
connection
,
string
key
)
{
{
var
oldVal
=
(
long
?)
await
connection
.
StringGetAsync
(
key
);
var
oldVal
=
(
long
?)
await
connection
.
StringGetAsync
(
key
)
.
ConfigureAwait
(
false
)
;
var
newVal
=
(
oldVal
??
0
)
+
1
;
var
newVal
=
(
oldVal
??
0
)
+
1
;
var
tran
=
connection
.
CreateTransaction
();
var
tran
=
connection
.
CreateTransaction
();
{
// check hasn't changed
{
// check hasn't changed
...
@@ -44,7 +44,7 @@ public void TestManualIncr()
...
@@ -44,7 +44,7 @@ public void TestManualIncr()
tran
.
AddCondition
(
Condition
.
StringEqual
(
key
,
oldVal
));
tran
.
AddCondition
(
Condition
.
StringEqual
(
key
,
oldVal
));
tran
.
StringSetAsync
(
key
,
newVal
);
tran
.
StringSetAsync
(
key
,
newVal
);
#pragma warning restore 4014
#pragma warning restore 4014
if
(!
await
tran
.
ExecuteAsync
())
return
null
;
// aborted
if
(!
await
tran
.
ExecuteAsync
()
.
ConfigureAwait
(
false
)
)
return
null
;
// aborted
return
newVal
;
return
newVal
;
}
}
}
}
...
...
MigratedBookSleeveTestSuite/Program.cs
View file @
5abe60bf
...
@@ -170,8 +170,7 @@ where Attribute.IsDefined(method, typeof(TestAttribute))
...
@@ -170,8 +170,7 @@ where Attribute.IsDefined(method, typeof(TestAttribute))
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
,
Inherited
=
false
)]
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
,
Inherited
=
false
)]
public
sealed
class
ActiveTestAttribute
:
Attribute
public
sealed
class
ActiveTestAttribute
:
Attribute
{
{
private
readonly
int
count
;
public
int
Count
{
get
;
}
public
int
Count
{
get
{
return
count
;
}
}
public
ActiveTestAttribute
()
:
this
(
1
)
{
}
public
ActiveTestAttribute
()
:
this
(
1
)
{
}
public
ActiveTestAttribute
(
int
count
)
{
this
.
c
ount
=
count
;
}
public
ActiveTestAttribute
(
int
count
)
{
this
.
C
ount
=
count
;
}
}
}
\ No newline at end of file
StackExchange.Redis.Tests/Config.cs
View file @
5abe60bf
...
@@ -170,7 +170,7 @@ public async System.Threading.Tasks.Task TestConfigureAsync()
...
@@ -170,7 +170,7 @@ public async System.Threading.Tasks.Task TestConfigureAsync()
{
{
Thread
.
Sleep
(
1000
);
Thread
.
Sleep
(
1000
);
Debug
.
WriteLine
(
"About to reconfigure....."
);
Debug
.
WriteLine
(
"About to reconfigure....."
);
await
muxer
.
ConfigureAsync
();
await
muxer
.
ConfigureAsync
()
.
ConfigureAwait
(
false
)
;
Debug
.
WriteLine
(
"Reconfigured"
);
Debug
.
WriteLine
(
"Reconfigured"
);
}
}
}
}
...
...
StackExchange.Redis.Tests/FloatingPoint.cs
View file @
5abe60bf
...
@@ -70,15 +70,15 @@ public async void IncrDecrFloatingPointAsync()
...
@@ -70,15 +70,15 @@ public async void IncrDecrFloatingPointAsync()
double
sum
=
0
;
double
sum
=
0
;
foreach
(
var
value
in
incr
)
foreach
(
var
value
in
incr
)
{
{
await
db
.
StringIncrementAsync
(
key
,
value
);
await
db
.
StringIncrementAsync
(
key
,
value
)
.
ConfigureAwait
(
false
)
;
sum
+=
value
;
sum
+=
value
;
}
}
foreach
(
var
value
in
decr
)
foreach
(
var
value
in
decr
)
{
{
await
db
.
StringDecrementAsync
(
key
,
value
);
await
db
.
StringDecrementAsync
(
key
,
value
)
.
ConfigureAwait
(
false
)
;
sum
-=
value
;
sum
-=
value
;
}
}
var
val
=
(
double
)
await
db
.
StringGetAsync
(
key
);
var
val
=
(
double
)
await
db
.
StringGetAsync
(
key
)
.
ConfigureAwait
(
false
)
;
Assert
.
IsTrue
(
Within
(
sum
,
val
,
0.0001
));
Assert
.
IsTrue
(
Within
(
sum
,
val
,
0.0001
));
}
}
...
@@ -146,15 +146,15 @@ public async void HashIncrDecrFloatingPointAsync()
...
@@ -146,15 +146,15 @@ public async void HashIncrDecrFloatingPointAsync()
double
sum
=
0
;
double
sum
=
0
;
foreach
(
var
value
in
incr
)
foreach
(
var
value
in
incr
)
{
{
await
db
.
HashIncrementAsync
(
key
,
field
,
value
);
await
db
.
HashIncrementAsync
(
key
,
field
,
value
)
.
ConfigureAwait
(
false
)
;
sum
+=
value
;
sum
+=
value
;
}
}
foreach
(
var
value
in
decr
)
foreach
(
var
value
in
decr
)
{
{
await
db
.
HashDecrementAsync
(
key
,
field
,
value
);
await
db
.
HashDecrementAsync
(
key
,
field
,
value
)
.
ConfigureAwait
(
false
)
;
sum
-=
value
;
sum
-=
value
;
}
}
var
val
=
(
double
)
await
db
.
HashGetAsync
(
key
,
field
);
var
val
=
(
double
)
await
db
.
HashGetAsync
(
key
,
field
)
.
ConfigureAwait
(
false
)
;
Assert
.
IsTrue
(
Within
(
sum
,
val
,
0.0001
));
Assert
.
IsTrue
(
Within
(
sum
,
val
,
0.0001
));
}
}
...
...
StackExchange.Redis.Tests/Issues/SO25567566.cs
View file @
5abe60bf
...
@@ -18,7 +18,7 @@ public async void Execute()
...
@@ -18,7 +18,7 @@ public async void Execute()
{
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
{
Assert
.
AreEqual
(
"ok"
,
await
DoStuff
(
conn
));
Assert
.
AreEqual
(
"ok"
,
await
DoStuff
(
conn
)
.
ConfigureAwait
(
false
)
);
}
}
}
}
...
@@ -30,13 +30,13 @@ private async Task<string> DoStuff(ConnectionMultiplexer conn)
...
@@ -30,13 +30,13 @@ private async Task<string> DoStuff(ConnectionMultiplexer conn)
var
timeout
=
Task
.
Delay
(
5000
);
var
timeout
=
Task
.
Delay
(
5000
);
var
len
=
db
.
ListLengthAsync
(
"list"
);
var
len
=
db
.
ListLengthAsync
(
"list"
);
if
(
await
Task
.
WhenAny
(
timeout
,
len
)
!=
len
)
if
(
await
Task
.
WhenAny
(
timeout
,
len
)
.
ConfigureAwait
(
false
)
!=
len
)
{
{
return
"Timeout getting length"
;
return
"Timeout getting length"
;
}
}
if
((
await
len
)
==
0
)
if
((
await
len
.
ConfigureAwait
(
false
)
)
==
0
)
{
{
db
.
ListRightPush
(
"list"
,
"foo"
,
flags
:
CommandFlags
.
FireAndForget
);
db
.
ListRightPush
(
"list"
,
"foo"
,
flags
:
CommandFlags
.
FireAndForget
);
}
}
...
@@ -48,14 +48,14 @@ private async Task<string> DoStuff(ConnectionMultiplexer conn)
...
@@ -48,14 +48,14 @@ private async Task<string> DoStuff(ConnectionMultiplexer conn)
var
exec
=
tran
.
ExecuteAsync
();
var
exec
=
tran
.
ExecuteAsync
();
// SWAP THESE TWO
// SWAP THESE TWO
bool
ok
=
await
Task
.
WhenAny
(
exec
,
timeout
)
==
exec
;
bool
ok
=
await
Task
.
WhenAny
(
exec
,
timeout
)
.
ConfigureAwait
(
false
)
==
exec
;
//bool ok = true;
//bool ok = true;
if
(
ok
)
if
(
ok
)
{
{
if
(
await
exec
)
if
(
await
exec
.
ConfigureAwait
(
false
)
)
{
{
await
Task
.
WhenAll
(
x
,
y
,
z
);
await
Task
.
WhenAll
(
x
,
y
,
z
)
.
ConfigureAwait
(
false
)
;
var
db2
=
conn
.
GetDatabase
();
var
db2
=
conn
.
GetDatabase
();
db2
.
HashGet
(
"hash"
,
"whatever"
);
db2
.
HashGet
(
"hash"
,
"whatever"
);
...
...
StackExchange.Redis.Tests/Profiling.cs
View file @
5abe60bf
...
@@ -447,7 +447,7 @@ public void LowAllocationEnumerable()
...
@@ -447,7 +447,7 @@ public void LowAllocationEnumerable()
.
ContinueWith
(
.
ContinueWith
(
async
_
=>
async
_
=>
{
{
return
(
string
)(
await
db
.
StringGetAsync
(
"foo"
+
i
));
return
(
string
)(
await
db
.
StringGetAsync
(
"foo"
+
i
)
.
ConfigureAwait
(
false
)
);
}
}
);
);
...
...
StackExchange.Redis.Tests/TaskTests.cs
View file @
5abe60bf
...
@@ -109,7 +109,7 @@ private void Continue(Task task)
...
@@ -109,7 +109,7 @@ private void Continue(Task task)
}
}
private
async
void
DoAwait
(
Task
task
)
private
async
void
DoAwait
(
Task
task
)
{
{
await
task
;
await
task
.
ConfigureAwait
(
false
)
;
continuationThread
=
Environment
.
CurrentManagedThreadId
;
continuationThread
=
Environment
.
CurrentManagedThreadId
;
evt
.
Set
();
evt
.
Set
();
}
}
...
...
StackExchange.Redis.Tests/Transactions.cs
View file @
5abe60bf
...
@@ -333,12 +333,12 @@ public async void BasicTran()
...
@@ -333,12 +333,12 @@ public async void BasicTran()
var
g
=
db
.
KeyExists
(
key
);
var
g
=
db
.
KeyExists
(
key
);
Assert
.
AreEqual
(
10
,
await
a
);
Assert
.
AreEqual
(
10
,
await
a
.
ConfigureAwait
(
false
)
);
Assert
.
AreEqual
(
15
,
await
b
);
Assert
.
AreEqual
(
15
,
await
b
.
ConfigureAwait
(
false
)
);
Assert
.
AreEqual
(
15
,
(
long
)
await
c
);
Assert
.
AreEqual
(
15
,
(
long
)
await
c
.
ConfigureAwait
(
false
)
);
Assert
.
IsTrue
(
await
d
);
Assert
.
IsTrue
(
await
d
.
ConfigureAwait
(
false
)
);
Assert
.
IsTrue
(
await
e
);
Assert
.
IsTrue
(
await
e
.
ConfigureAwait
(
false
)
);
Assert
.
IsFalse
(
await
f
);
Assert
.
IsFalse
(
await
f
.
ConfigureAwait
(
false
)
);
Assert
.
IsFalse
(
g
);
Assert
.
IsFalse
(
g
);
}
}
}
}
...
...
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