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
de7da51a
Commit
de7da51a
authored
Jul 02, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix geo tests to run locally (if the version supports it)
parent
8976c8cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
41 deletions
+20
-41
GeoTests.cs
StackExchange.Redis.Tests/GeoTests.cs
+20
-41
No files found.
StackExchange.Redis.Tests/GeoTests.cs
View file @
de7da51a
using
Xunit
;
using
Xunit
;
using
System
;
using
System
;
using
System.IO
;
using
Xunit.Abstractions
;
using
Xunit.Abstractions
;
namespace
StackExchange.Redis.Tests
namespace
StackExchange.Redis.Tests
{
{
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
class
AzureTestAttribute
:
FactAttribute
{
}
public
class
GeoTests
:
TestBase
public
class
GeoTests
:
TestBase
{
{
public
GeoTests
(
ITestOutputHelper
output
)
:
base
(
output
)
{
}
public
GeoTests
(
ITestOutputHelper
output
)
:
base
(
output
)
{
}
private
ConnectionMultiplexer
Create
()
{
Skip
.
IfNoConfig
(
nameof
(
TestConfig
.
Config
.
AzureCacheServer
),
TestConfig
.
Current
.
AzureCacheServer
);
Skip
.
IfNoConfig
(
nameof
(
TestConfig
.
Config
.
AzureCachePassword
),
TestConfig
.
Current
.
AzureCachePassword
);
var
options
=
new
ConfigurationOptions
();
options
.
EndPoints
.
Add
(
TestConfig
.
Current
.
AzureCacheServer
);
options
.
Ssl
=
true
;
options
.
ConnectTimeout
=
5000
;
options
.
Password
=
TestConfig
.
Current
.
AzureCachePassword
;
options
.
TieBreaker
=
""
;
var
log
=
new
StringWriter
();
var
conn
=
ConnectionMultiplexer
.
Connect
(
options
,
log
);
var
s
=
log
.
ToString
();
Output
.
WriteLine
(
s
);
Skip
.
IfMissingFeature
(
conn
,
nameof
(
RedisFeatures
.
Geo
),
r
=>
r
.
Geo
);
return
conn
;
}
public
const
int
Db
=
0
;
public
static
GeoEntry
public
static
GeoEntry
palermo
=
new
GeoEntry
(
13.361389
,
38.115556
,
"Palermo"
),
palermo
=
new
GeoEntry
(
13.361389
,
38.115556
,
"Palermo"
),
catania
=
new
GeoEntry
(
15.087269
,
37.502669
,
"Catania"
),
catania
=
new
GeoEntry
(
15.087269
,
37.502669
,
"Catania"
),
...
@@ -42,12 +15,13 @@ public static GeoEntry
...
@@ -42,12 +15,13 @@ public static GeoEntry
cefal
ù
=
new
GeoEntry
(
14.0188
,
38.0084
,
"Cefalù"
);
cefal
ù
=
new
GeoEntry
(
14.0188
,
38.0084
,
"Cefalù"
);
public
static
GeoEntry
[]
all
=
{
palermo
,
catania
,
agrigento
,
cefal
ù
};
public
static
GeoEntry
[]
all
=
{
palermo
,
catania
,
agrigento
,
cefal
ù
};
[
AzureTes
t
]
[
Fac
t
]
public
void
GeoAdd
()
public
void
GeoAdd
()
{
{
using
(
var
conn
=
Create
())
using
(
var
conn
=
Create
())
{
{
var
db
=
conn
.
GetDatabase
(
Db
);
Skip
.
IfMissingFeature
(
conn
,
nameof
(
RedisFeatures
.
Geo
),
r
=>
r
.
Geo
);
var
db
=
conn
.
GetDatabase
();
RedisKey
key
=
Me
();
RedisKey
key
=
Me
();
db
.
KeyDelete
(
key
);
db
.
KeyDelete
(
key
);
...
@@ -63,12 +37,13 @@ public void GeoAdd()
...
@@ -63,12 +37,13 @@ public void GeoAdd()
}
}
}
}
[
AzureTes
t
]
[
Fac
t
]
public
void
GetDistance
()
public
void
GetDistance
()
{
{
using
(
var
conn
=
Create
())
using
(
var
conn
=
Create
())
{
{
var
db
=
conn
.
GetDatabase
(
Db
);
Skip
.
IfMissingFeature
(
conn
,
nameof
(
RedisFeatures
.
Geo
),
r
=>
r
.
Geo
);
var
db
=
conn
.
GetDatabase
();
RedisKey
key
=
Me
();
RedisKey
key
=
Me
();
db
.
KeyDelete
(
key
);
db
.
KeyDelete
(
key
);
db
.
GeoAdd
(
key
,
all
);
db
.
GeoAdd
(
key
,
all
);
...
@@ -82,12 +57,13 @@ public void GetDistance()
...
@@ -82,12 +57,13 @@ public void GetDistance()
}
}
}
}
[
AzureTes
t
]
[
Fac
t
]
public
void
GeoHash
()
public
void
GeoHash
()
{
{
using
(
var
conn
=
Create
())
using
(
var
conn
=
Create
())
{
{
var
db
=
conn
.
GetDatabase
(
Db
);
Skip
.
IfMissingFeature
(
conn
,
nameof
(
RedisFeatures
.
Geo
),
r
=>
r
.
Geo
);
var
db
=
conn
.
GetDatabase
();
RedisKey
key
=
Me
();
RedisKey
key
=
Me
();
db
.
KeyDelete
(
key
);
db
.
KeyDelete
(
key
);
db
.
GeoAdd
(
key
,
all
);
db
.
GeoAdd
(
key
,
all
);
...
@@ -106,12 +82,13 @@ public void GeoHash()
...
@@ -106,12 +82,13 @@ public void GeoHash()
}
}
}
}
[
AzureTes
t
]
[
Fac
t
]
public
void
GeoGetPosition
()
public
void
GeoGetPosition
()
{
{
using
(
var
conn
=
Create
())
using
(
var
conn
=
Create
())
{
{
var
db
=
conn
.
GetDatabase
(
Db
);
Skip
.
IfMissingFeature
(
conn
,
nameof
(
RedisFeatures
.
Geo
),
r
=>
r
.
Geo
);
var
db
=
conn
.
GetDatabase
();
RedisKey
key
=
Me
();
RedisKey
key
=
Me
();
db
.
KeyDelete
(
key
);
db
.
KeyDelete
(
key
);
db
.
GeoAdd
(
key
,
all
);
db
.
GeoAdd
(
key
,
all
);
...
@@ -126,12 +103,13 @@ public void GeoGetPosition()
...
@@ -126,12 +103,13 @@ public void GeoGetPosition()
}
}
}
}
[
AzureTes
t
]
[
Fac
t
]
public
void
GeoRemove
()
public
void
GeoRemove
()
{
{
using
(
var
conn
=
Create
())
using
(
var
conn
=
Create
())
{
{
var
db
=
conn
.
GetDatabase
(
Db
);
Skip
.
IfMissingFeature
(
conn
,
nameof
(
RedisFeatures
.
Geo
),
r
=>
r
.
Geo
);
var
db
=
conn
.
GetDatabase
();
RedisKey
key
=
Me
();
RedisKey
key
=
Me
();
db
.
KeyDelete
(
key
);
db
.
KeyDelete
(
key
);
db
.
GeoAdd
(
key
,
all
);
db
.
GeoAdd
(
key
,
all
);
...
@@ -148,12 +126,13 @@ public void GeoRemove()
...
@@ -148,12 +126,13 @@ public void GeoRemove()
}
}
}
}
[
AzureTes
t
]
[
Fac
t
]
public
void
GeoRadius
()
public
void
GeoRadius
()
{
{
using
(
var
conn
=
Create
())
using
(
var
conn
=
Create
())
{
{
var
db
=
conn
.
GetDatabase
(
Db
);
Skip
.
IfMissingFeature
(
conn
,
nameof
(
RedisFeatures
.
Geo
),
r
=>
r
.
Geo
);
var
db
=
conn
.
GetDatabase
();
RedisKey
key
=
Me
();
RedisKey
key
=
Me
();
db
.
KeyDelete
(
key
);
db
.
KeyDelete
(
key
);
db
.
GeoAdd
(
key
,
all
);
db
.
GeoAdd
(
key
,
all
);
...
@@ -187,4 +166,4 @@ public void GeoRadius()
...
@@ -187,4 +166,4 @@ public void GeoRadius()
}
}
}
}
}
}
}
}
\ No newline at end of file
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