Merge pull request #41 from tparnell8/master
Release minor fix to event race conditions. Add CLS support
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -9,7 +9,8 @@
|
||||
*.DotSettings
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
*.lock
|
||||
tools/
|
||||
**/.settings
|
||||
NDependOut
|
||||
*.ndproj
|
||||
@@ -24,7 +25,7 @@ build/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
output/
|
||||
# Visual Studo 2015 cache/options directory
|
||||
.vs/
|
||||
|
||||
@@ -132,7 +133,7 @@ publish/
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
@@ -4,4 +4,5 @@
|
||||
<package id="NUnit.Runners" version="2.6.4" />
|
||||
<package id="OpenCover" version="4.5.3723" />
|
||||
<package id="ReportGenerator" version="2.1.4.0" />
|
||||
<package id="Mono.Gendarme" version="2.11.0.20121120" />
|
||||
</packages>
|
||||
10
.travis.yml
Normal file
10
.travis.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
language: csharp
|
||||
solution: Untappd.Net.sln
|
||||
script:
|
||||
- xbuild /p:Configuration=Release Untappd.Net.sln
|
||||
- mono ./packages/NUnit.Runners.*/tools/nunit-console.exe ./src/*Tests/bin/Release/*Tests.dll
|
||||
sudo: false
|
||||
script:
|
||||
- gem install bundle
|
||||
- bundle
|
||||
- rake preflight
|
||||
5
Gemfile
Normal file
5
Gemfile
Normal file
@@ -0,0 +1,5 @@
|
||||
source 'http://rubygems.org'
|
||||
gem 'rake'
|
||||
gem 'os'
|
||||
gem 'albacore'
|
||||
gem 'nokogiri'
|
||||
24
README.md
24
README.md
@@ -1,5 +1,11 @@
|
||||
**Master:** [](https://ci.appveyor.com/project/tparnell8/untappd-net/branch/master)
|
||||
**Master AppVeyor Build (Windows):** [](https://ci.appveyor.com/project/tparnell8/untappd-net/branch/master)
|
||||
|
||||
**Master Travis-CI (Linux):** [](https://travis-ci.org/tparnell8/Untappd.Net)
|
||||
|
||||
**Master Circle-CI (Linux):** [](https://circleci.com/gh/tparnell8/Untappd.Net/tree/master)
|
||||
|
||||
**Release:**[](https://ci.appveyor.com/project/tparnell8/untappd-net/branch/Release)
|
||||
|
||||
**Code Coverage:** [](https://coveralls.io/r/tparnell8/Untappd.Net?branch=master)
|
||||
|
||||
**Kanban** [](https://waffle.io/tparnell8/untappd.net)
|
||||
@@ -10,6 +16,22 @@
|
||||
|
||||
This is a c# wrapper around the Untappd API. This can be downloaded via [Nuget](https://www.nuget.org/packages/Untappd.Net/), or the [backup feed](https://www.myget.org/F/untappd-net/api/v2).
|
||||
|
||||
## Building via command line
|
||||
|
||||
If you wish to build via command line install ruby, and ruby gems. Open up a console in the root directory of this project, and then run the following:
|
||||
|
||||
* `gem install rake`
|
||||
* `gem install bundle`
|
||||
* `bundle`
|
||||
* `rake preflight`
|
||||
|
||||
## My PR is broken, it works in VS!
|
||||
|
||||
if your pull request is broken either one of two things is happening.
|
||||
|
||||
1. Your changes are not mono compatible, which prevent linux users from using your changes. This will only happen if travis ci says your build is broken, but appveyor does not.
|
||||
2. You have added gendarme violations. You can run gendarme locally by running `rake preflight` from your console.
|
||||
|
||||
## API Coverage
|
||||
|
||||
Current both Authenticated and Unauthenticated requests.
|
||||
|
||||
69
Rakefile
Normal file
69
Rakefile
Normal file
@@ -0,0 +1,69 @@
|
||||
require 'bundler/setup'
|
||||
require 'rake/clean'
|
||||
require 'albacore'
|
||||
require 'open-uri'
|
||||
require 'fileutils'
|
||||
require 'os'
|
||||
require 'nokogiri'
|
||||
import 'assets/tools.rake'
|
||||
|
||||
|
||||
PACKAGES = File.expand_path("packages")
|
||||
TOOLS = File.expand_path("tools")
|
||||
NUGET = File.expand_path("#{TOOLS}/nuget")
|
||||
Configuration = ENV['CONFIGURATION'] || 'Release'
|
||||
|
||||
desc 'retrieve dependencies'
|
||||
task :retrieve => ['tools:nuget_fetch']
|
||||
|
||||
desc 'build the project'
|
||||
task :build => [:compile]
|
||||
|
||||
desc 'Run the tests'
|
||||
task :test => [:nunit]
|
||||
|
||||
desc 'Retrieve, Build, Test'
|
||||
task :preflight => [:retrieve, :build, :test, :cs_lint]
|
||||
|
||||
|
||||
|
||||
build :compile => ['tools:nuget_fetch'] do |b|
|
||||
b.prop 'Configuration', Configuration
|
||||
b.sln = 'Untappd.Net.sln'
|
||||
end
|
||||
|
||||
test_runner :nunit do |tests|
|
||||
tests.files = FileList["src/**/*UnitTests/bin/#{Configuration}/*UnitTests.dll"] # dll files with test
|
||||
tests.exe = "packages/NUnit.Runners.2.6.4/tools/nunit-console.exe" # executable to run tests with
|
||||
end
|
||||
|
||||
task :cs_lint do
|
||||
|
||||
unless Dir.exists?('output')
|
||||
Dir.mkdir('output')
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
CMD_PREFIX = ""
|
||||
if !OS.windows?
|
||||
CMD_PREFIX = "mono"
|
||||
end
|
||||
|
||||
sh "#{CMD_PREFIX} packages/Mono.Gendarme.2.11.0.20121120/tools/gendarme.exe src/Untappd.Net/bin/#{Configuration}/Untappd.Net.dll --html output/gendarme.html --severity high+ --ignore assets/gendarme/gendarme.ignore --console"
|
||||
|
||||
end
|
||||
|
||||
|
||||
# task :tests => :'tests:unit'
|
||||
|
||||
#task :ensure_nuget_key do
|
||||
# raise 'missing env NUGET_KEY value' unless ENV['NUGET_KEY']
|
||||
#end
|
||||
|
||||
#Albacore::Tasks::Release.new :release,
|
||||
# pkg_dir: 'build/pkg',
|
||||
# depend_on: [:create_nugets, :ensure_nuget_key],
|
||||
# nuget_exe: 'packages/NuGet.CommandLine/tools/NuGet.exe',
|
||||
# api_key: ENV['NUGET_KEY']
|
||||
120
Untappd.Net.sln
120
Untappd.Net.sln
@@ -1,38 +1,82 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Untappd.Net", "src\Untappd.Net\Untappd.Net.csproj", "{D8571A44-2E86-43A3-B64A-2364614C6934}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Untappd.Net.UnitTests", "src\Untappd.Net.UnitTests\Untappd.Net.UnitTests.csproj", "{513A3FB2-6664-40E7-A03E-591D852C42E4}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7175F502-2C45-4728-8693-A6ACDC7D5892}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
appveyor.yml = appveyor.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{8013BAEB-9A81-4ED1-8471-343D16B06D98}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.nuget\packages.config = .nuget\packages.config
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D8571A44-2E86-43A3-B64A-2364614C6934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D8571A44-2E86-43A3-B64A-2364614C6934}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D8571A44-2E86-43A3-B64A-2364614C6934}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D8571A44-2E86-43A3-B64A-2364614C6934}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{513A3FB2-6664-40E7-A03E-591D852C42E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{513A3FB2-6664-40E7-A03E-591D852C42E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{513A3FB2-6664-40E7-A03E-591D852C42E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{513A3FB2-6664-40E7-A03E-591D852C42E4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Untappd.Net", "src\Untappd.Net\Untappd.Net.csproj", "{D8571A44-2E86-43A3-B64A-2364614C6934}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Untappd.Net.UnitTests", "src\Untappd.Net.UnitTests\Untappd.Net.UnitTests.csproj", "{513A3FB2-6664-40E7-A03E-591D852C42E4}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7175F502-2C45-4728-8693-A6ACDC7D5892}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
appveyor.yml = appveyor.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{8013BAEB-9A81-4ED1-8471-343D16B06D98}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.nuget\packages.config = .nuget\packages.config
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{513A3FB2-6664-40E7-A03E-591D852C42E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{513A3FB2-6664-40E7-A03E-591D852C42E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{513A3FB2-6664-40E7-A03E-591D852C42E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{513A3FB2-6664-40E7-A03E-591D852C42E4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D8571A44-2E86-43A3-B64A-2364614C6934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D8571A44-2E86-43A3-B64A-2364614C6934}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D8571A44-2E86-43A3-B64A-2364614C6934}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D8571A44-2E86-43A3-B64A-2364614C6934}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = src\Untappd.Net\Untappd.Net.csproj
|
||||
Policies = $0
|
||||
$0.DotNetNamingPolicy = $1
|
||||
$1.DirectoryNamespaceAssociation = PrefixedHierarchical
|
||||
$1.ResourceNamePolicy = FileFormatDefault
|
||||
$0.TextStylePolicy = $2
|
||||
$2.inheritsSet = VisualStudio
|
||||
$2.inheritsScope = text/plain
|
||||
$2.scope = text/x-csharp
|
||||
$0.CSharpFormattingPolicy = $3
|
||||
$3.IndentSwitchBody = True
|
||||
$3.IndentBlocksInsideExpressions = True
|
||||
$3.AnonymousMethodBraceStyle = NextLine
|
||||
$3.PropertyBraceStyle = NextLine
|
||||
$3.PropertyGetBraceStyle = NextLine
|
||||
$3.PropertySetBraceStyle = NextLine
|
||||
$3.EventBraceStyle = NextLine
|
||||
$3.EventAddBraceStyle = NextLine
|
||||
$3.EventRemoveBraceStyle = NextLine
|
||||
$3.StatementBraceStyle = NextLine
|
||||
$3.ElseNewLinePlacement = NewLine
|
||||
$3.CatchNewLinePlacement = NewLine
|
||||
$3.FinallyNewLinePlacement = NewLine
|
||||
$3.WhileNewLinePlacement = DoNotCare
|
||||
$3.ArrayInitializerWrapping = DoNotChange
|
||||
$3.ArrayInitializerBraceStyle = NextLine
|
||||
$3.BeforeMethodDeclarationParentheses = False
|
||||
$3.BeforeMethodCallParentheses = False
|
||||
$3.BeforeConstructorDeclarationParentheses = False
|
||||
$3.NewLineBeforeConstructorInitializerColon = NewLine
|
||||
$3.NewLineAfterConstructorInitializerColon = SameLine
|
||||
$3.BeforeDelegateDeclarationParentheses = False
|
||||
$3.NewParentheses = False
|
||||
$3.SpacesBeforeBrackets = False
|
||||
$3.inheritsSet = Mono
|
||||
$3.inheritsScope = text/x-csharp
|
||||
$3.scope = text/x-csharp
|
||||
$0.StandardHeader = $4
|
||||
$4.Text =
|
||||
$4.IncludeInNewFiles = True
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -25,6 +25,9 @@ build:
|
||||
after_test:
|
||||
- packages\OpenCover.4.5.3723\OpenCover.Console.exe -register:user -filter:"+[Untappd.Net*]* -[*Tests]*" -target:"packages\NUnit.Runners.2.6.4\tools\nunit-console.exe" -targetargs:"/noshadow /domain:single src\Untappd.Net.UnitTests\bin\Release\Untappd.Net.UnitTests.dll" -output:coverage.xml
|
||||
- packages\coveralls.io.1.3.4\tools\coveralls.net.exe --opencover coverage.xml
|
||||
- gem install bundle
|
||||
- bundle
|
||||
- rake cs_lint
|
||||
deploy:
|
||||
- provider: NuGet
|
||||
server:
|
||||
@@ -38,3 +41,6 @@ deploy:
|
||||
secure: wsN6BzH8ETiXhB9SndP57mHhivqM+CVnghI/+w5XE3bI8K092Z4V4FrJixcrxKnI
|
||||
on:
|
||||
branch: release
|
||||
artifacts:
|
||||
path: output/gendarme.html
|
||||
name: gendarme
|
||||
|
||||
60
assets/gendarme/gendarme.ignore
Normal file
60
assets/gendarme/gendarme.ignore
Normal file
@@ -0,0 +1,60 @@
|
||||
# we have hard coded strings...sue us
|
||||
R: Gendarme.Rules.Design.PreferUriOverStringRule
|
||||
A: *
|
||||
|
||||
# We don't really care if our exceptions are not serializable
|
||||
R: Gendarme.Rules.Serialization.MissingSerializationConstructorRule
|
||||
A: Untappd.Net
|
||||
|
||||
# Either implement or do not bother
|
||||
R: Gendarme.Rules.Exceptions.MissingExceptionConstructorsRule
|
||||
A: Untappd.Net
|
||||
|
||||
# TODO: Implement
|
||||
R: Gendarme.Rules.BadPractice.DoNotForgetNotImplementedMethodsRule
|
||||
N: Untappd.Net
|
||||
|
||||
|
||||
R: Gendarme.Rules.Design.ConsiderAddingInterfaceRule
|
||||
T: Untappd.Net.Request.BasicRequest # This class is an abstract class, its inheritors should implement the interface
|
||||
T: Untappd.Net.SingleObjectArrayConverter # We should figure out how to implement the write json here...
|
||||
A: Untappd.Net
|
||||
|
||||
# Microsoft says we shouldn't dispose tasks ourselves
|
||||
R: Gendarme.Rules.Correctness.EnsureLocalDisposalRule
|
||||
A: Untappd.Net
|
||||
|
||||
# We use the obsolete constructor for testing
|
||||
R: Gendarme.Rules.Performance.AvoidUncalledPrivateCodeRule
|
||||
T: Untappd.Net.Request.Repository
|
||||
|
||||
# we really want constants
|
||||
R: Gendarme.Rules.BadPractice.AvoidVisibleConstantFieldRule
|
||||
T: Untappd.Net.Constants
|
||||
|
||||
# for json binding
|
||||
R: Gendarme.Rules.Naming.AvoidNonAlphanumericIdentifierRule
|
||||
A: Untappd.Net
|
||||
|
||||
# cannot be helped
|
||||
R: Gendarme.Rules.Naming.AvoidDeepNamespaceHierarchyRule
|
||||
A: Untappd.Net
|
||||
|
||||
R: Gendarme.Rules.Maintainability.AvoidLackOfCohesionOfMethodsRule
|
||||
A: Untappd.Net
|
||||
|
||||
# We need to multiple call
|
||||
R: Gendarme.Rules.Performance.AvoidRepetitiveCallsToPropertiesRule
|
||||
T: Untappd.Net.Request.Repository
|
||||
|
||||
# we want to do this here
|
||||
R: Gendarme.Rules.Exceptions.DoNotSwallowErrorsCatchingNonSpecificExceptionsRule
|
||||
M: System.Void Untappd.Net.Request.Repository/<ExecuteRequestAsync>c__async0`1::MoveNext()
|
||||
|
||||
# We violate case sometimes for json bindings
|
||||
R: Gendarme.Rules.Naming.UseCorrectCasingRule
|
||||
A: Untappd.Net
|
||||
|
||||
# TODO: Serialize properly
|
||||
R: Gendarme.Rules.Serialization.ImplementISerializableCorrectlyRule
|
||||
T: Untappd.Net.Exception.HttpErrorException
|
||||
12
assets/puppet/init.pp
Normal file
12
assets/puppet/init.pp
Normal file
@@ -0,0 +1,12 @@
|
||||
include apt
|
||||
class mono {
|
||||
package { "mono-devel" :
|
||||
ensure => "installed"
|
||||
}
|
||||
package { "mono-gmcs" :
|
||||
ensure => "installed"
|
||||
}
|
||||
package { "mono-vbnc" :
|
||||
ensure => "installed"
|
||||
}
|
||||
}
|
||||
3
assets/puppet/site.pp
Normal file
3
assets/puppet/site.pp
Normal file
@@ -0,0 +1,3 @@
|
||||
import 'init.pp'
|
||||
|
||||
include mono
|
||||
37
assets/tools.rake
Normal file
37
assets/tools.rake
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace :tools do
|
||||
|
||||
# If we don't have a copy of nuget, download it
|
||||
task :nuget_bootstrap do
|
||||
puts 'Ensuring NuGet exists in tools/NuGet'
|
||||
|
||||
if !FileTest.exist?("#{NUGET}/nuget.exe")
|
||||
puts 'Downloading nuget from nuget.org'
|
||||
|
||||
FileUtils.mkdir_p("#{NUGET}")
|
||||
File.open("#{NUGET}/nuget.exe", "wb") do |file|
|
||||
file.write open('https://nuget.org/nuget.exe').read
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Fetch nuget dependencies for all packages
|
||||
task :nuget_fetch => :nuget_bootstrap do
|
||||
|
||||
# If we aren't running under windows, assume we're using mono
|
||||
CMD_PREFIX = ""
|
||||
if !OS.windows?
|
||||
CMD_PREFIX = "mono"
|
||||
begin
|
||||
sh "mozroots --import --sync" #attempt to sync ssl things...
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
# Make sure we get solution-level deps
|
||||
sh "#{CMD_PREFIX} #{NUGET}/nuget.exe i .nuget/packages.config -o packages"
|
||||
|
||||
FileList["src/**/packages.config"].each { |filepath|
|
||||
sh "#{CMD_PREFIX} #{NUGET}/nuget.exe i #{filepath} -o packages"
|
||||
}
|
||||
end
|
||||
end
|
||||
6
circle.yml
Normal file
6
circle.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
dependencies:
|
||||
pre:
|
||||
- sudo apt-get update; sudo apt-get install mono-devel
|
||||
test:
|
||||
override:
|
||||
- rake preflight
|
||||
@@ -2,7 +2,7 @@
|
||||
using NUnit.Framework;
|
||||
using Untappd.Net.Authentication;
|
||||
|
||||
namespace Untappd.Net.UnitTests.Client
|
||||
namespace Untappd.Net.UnitTests.Authentication
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestAuthenticatedUntappdCredentials
|
||||
@@ -2,7 +2,7 @@
|
||||
using NUnit.Framework;
|
||||
using Untappd.Net.Authentication;
|
||||
|
||||
namespace Untappd.Net.UnitTests.Client
|
||||
namespace Untappd.Net.UnitTests.Authentication
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestUnAuthenticatedUntappdCredentials
|
||||
@@ -1,6 +1,5 @@
|
||||
using NUnit.Framework;
|
||||
using Untappd.Net.Exception;
|
||||
|
||||
namespace Untappd.Net.UnitTests.Exception
|
||||
{
|
||||
[TestFixture]
|
||||
@@ -24,5 +23,7 @@ namespace Untappd.Net.UnitTests.Exception
|
||||
{
|
||||
throw new BaseUntappdException("messageHere", new System.Exception("innerException!"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Untappd.Net.UnitTests.Request
|
||||
request.Setup(a => a.AddParameter(It.IsAny<string>(), It.IsAny<string>()));
|
||||
|
||||
var response = new Mock<IRestResponse>();
|
||||
response.Setup(a => a.Content).Returns(File.ReadAllText("../../Responses/json/BeerInfo.json"));
|
||||
response.Setup(a => a.Content).Returns(File.ReadAllText("../../Responses/Json/BeerInfo.json"));
|
||||
client.Setup(a => a.Execute(It.IsAny<IRestRequest>())).Callback(() =>
|
||||
{
|
||||
}).Returns(response.Object);
|
||||
|
||||
@@ -18,7 +18,7 @@ using Untappd.Net.Responses.VenueInfo;
|
||||
using UserDistinctBeers = Untappd.Net.Responses.UserDistinctBeer;
|
||||
using UserWishList = Untappd.Net.Responses.UserWishlist;
|
||||
|
||||
namespace Untappd.Net.UnitTests
|
||||
namespace Untappd.Net.UnitTests.Responses
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestDeserializer
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -33,10 +33,6 @@
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core">
|
||||
<HintPath>..\..\packages\NUnitTestAdapter.1.2\lib\nunit.core.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
@@ -56,10 +52,6 @@
|
||||
<HintPath>..\..\packages\NUnitTestAdapter.1.2\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=105.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\RestSharp.105.0.1\lib\net4\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@@ -67,14 +59,20 @@
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath>..\..\packages\RestSharp.105.0.1\lib\net4\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Responses\Actions\TestCheckInAction.cs" />
|
||||
<Compile Include="Responses\Actions\TestSimpleActions.cs" />
|
||||
<Compile Include="Responses\TestDeserializer.cs" />
|
||||
<Compile Include="Authentication\TestAuthenticationHelper.cs" />
|
||||
<Compile Include="Client\TestAuthenticatedUntappdCredentials.cs" />
|
||||
<Compile Include="Client\TestUnAuthenticatedUntappdCredentials.cs" />
|
||||
<Compile Include="Authentication\TestAuthenticatedUntappdCredentials.cs" />
|
||||
<Compile Include="Authentication\TestUnAuthenticatedUntappdCredentials.cs" />
|
||||
<Compile Include="Exception\TestBaseUntappdException.cs" />
|
||||
<Compile Include="Exception\TestEndpointConfigurationException.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -98,7 +96,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Untappd.Net\Untappd.Net.csproj">
|
||||
<Project>{d8571a44-2e86-43a3-b64a-2364614c6934}</Project>
|
||||
<Project>{D8571A44-2E86-43A3-B64A-2364614C6934}</Project>
|
||||
<Name>Untappd.Net</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -4,6 +4,7 @@ using RestSharp;
|
||||
|
||||
namespace Untappd.Net.Exception
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class HttpErrorException : BaseUntappdException
|
||||
{
|
||||
public override string Message
|
||||
@@ -17,6 +18,14 @@ namespace Untappd.Net.Exception
|
||||
private readonly string _message;
|
||||
public HttpErrorException(IRestRequest request, IRestResponse response)
|
||||
{
|
||||
if(request == null)
|
||||
{
|
||||
throw new ArgumentNullException("request");
|
||||
}
|
||||
if (response == null)
|
||||
{
|
||||
throw new ArgumentNullException("response");
|
||||
}
|
||||
var code = (int) response.StatusCode;
|
||||
if (code == 200)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,9 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
using System;
|
||||
|
||||
|
||||
[assembly: AssemblyTitle("Untappd.Net")]
|
||||
[assembly: AssemblyDescription("C# Untappd Wrapper")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
@@ -13,6 +16,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: CLSCompliantAttribute(true)]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Untappd.Net.Request
|
||||
{
|
||||
public abstract class BasicRequest
|
||||
{
|
||||
protected abstract string _EndPoint { get; }
|
||||
protected abstract string EndPointWithConfiguration { get; }
|
||||
/// <summary>
|
||||
/// Pass in the parameter into the request...ie username, brewery, etc.
|
||||
/// </summary>
|
||||
@@ -15,9 +15,9 @@ namespace Untappd.Net.Request
|
||||
if (!String.IsNullOrEmpty(parameter))
|
||||
{
|
||||
parameter = string.Format("/{0}", parameter);
|
||||
return string.Format(_EndPoint, parameter);
|
||||
return string.Format(EndPointWithConfiguration, parameter);
|
||||
}
|
||||
return string.Format(_EndPoint, string.Empty);
|
||||
return string.Format(EndPointWithConfiguration, string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Untappd.Net.Request
|
||||
{
|
||||
internal IRestClient Client;
|
||||
internal IRestRequest Request;
|
||||
private bool FailFast { get; set; }
|
||||
bool FailFast { get; set; }
|
||||
/// <summary>
|
||||
/// Event to listen to when failFast is set to false
|
||||
/// This allows you to capture the excpetion, before its swallowed
|
||||
@@ -65,28 +65,30 @@ namespace Untappd.Net.Request
|
||||
return this;
|
||||
}
|
||||
|
||||
private TResult ExecuteRequest<TResult>()
|
||||
TResult ExecuteRequest<TResult>()
|
||||
where TResult : class
|
||||
{
|
||||
return ProcessExecution<TResult>(Client.Execute(Request));
|
||||
}
|
||||
|
||||
private async Task<TResult> ExecuteRequestAsync<TResult>()
|
||||
async Task<TResult> ExecuteRequestAsync<TResult>()
|
||||
where TResult : class
|
||||
{
|
||||
return ProcessExecution<TResult>(await Client.ExecuteTaskAsync(Request));
|
||||
}
|
||||
|
||||
private TResult ProcessExecution<TResult>(IRestResponse response)
|
||||
TResult ProcessExecution<TResult>(IRestResponse response)
|
||||
where TResult : class
|
||||
{
|
||||
//if the return type is not 200 throw errors
|
||||
if (response.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
var excpetion = new HttpErrorException(Request, response);
|
||||
if (OnExceptionThrown != null)
|
||||
var eventThrow = OnExceptionThrown;
|
||||
|
||||
if (eventThrow != null)
|
||||
{
|
||||
OnExceptionThrown(this, new UnhandledExceptionEventArgs(excpetion, FailFast));
|
||||
eventThrow(this, new UnhandledExceptionEventArgs(excpetion, FailFast));
|
||||
}
|
||||
if (FailFast)
|
||||
{
|
||||
@@ -101,9 +103,11 @@ namespace Untappd.Net.Request
|
||||
}
|
||||
catch(System.Exception e)
|
||||
{
|
||||
if (OnExceptionThrown != null)
|
||||
var eventThrow = OnExceptionThrown;
|
||||
|
||||
if (eventThrow != null)
|
||||
{
|
||||
OnExceptionThrown(this, new UnhandledExceptionEventArgs(e, FailFast));
|
||||
eventThrow(this, new UnhandledExceptionEventArgs(e, FailFast));
|
||||
}
|
||||
if (FailFast)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Untappd.Net.Authentication;
|
||||
using System;
|
||||
|
||||
namespace Untappd.Net.Request
|
||||
{
|
||||
@@ -13,6 +14,15 @@ namespace Untappd.Net.Request
|
||||
/// <returns>returns dynamic since often the return doesn't matter</returns>
|
||||
public dynamic Post(IAuthenticatedUntappdCredentials credentials, IAction action)
|
||||
{
|
||||
if (credentials == null)
|
||||
{
|
||||
throw new ArgumentNullException("credentials");
|
||||
}
|
||||
if (action == null)
|
||||
{
|
||||
throw new ArgumentNullException("action");
|
||||
}
|
||||
|
||||
return ConfigureRequest(credentials, action.EndPoint, action.BodyParameters, action.RequestMethod)
|
||||
.ExecuteRequest<dynamic>();
|
||||
}
|
||||
@@ -25,6 +35,15 @@ namespace Untappd.Net.Request
|
||||
/// <returns>returns dynamic since often the return doesn't matter</returns>
|
||||
public Task<dynamic> PostAsync(IAuthenticatedUntappdCredentials credentials, IAction action)
|
||||
{
|
||||
if (credentials == null)
|
||||
{
|
||||
throw new ArgumentNullException("credentials");
|
||||
}
|
||||
if (action == null)
|
||||
{
|
||||
throw new ArgumentNullException("action");
|
||||
}
|
||||
|
||||
return ConfigureRequest(credentials, action.EndPoint, action.BodyParameters, action.RequestMethod)
|
||||
.ExecuteRequestAsync<dynamic>();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,10 @@ namespace Untappd.Net.Responses.Actions
|
||||
get { return _shout; }
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
if (value.Length > 140)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value", value,"Shout can be no more than 140 characters");
|
||||
|
||||
@@ -937,7 +937,7 @@ namespace Untappd.Net.Responses.BeerInfo
|
||||
|
||||
public class BeerInfo : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/beer/info{0}"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/beer/info{0}"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace Untappd.Net.Responses.BeerSearch
|
||||
|
||||
public class BeerSearch : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/search/beer"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/search/beer"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -908,7 +908,7 @@ namespace Untappd.Net.Responses.BreweryInfo
|
||||
|
||||
public class BreweryInfo : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/brewery/info{0}"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/brewery/info{0}"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Untappd.Net.Responses.BrewerySearch
|
||||
|
||||
public class BrewerySearch : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/search/brewery"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/search/brewery"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -511,7 +511,7 @@ namespace Untappd.Net.Responses.Feeds.ActivityFeed
|
||||
|
||||
public class ActivityFeed : BasicRequest, IAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "/v4/checkin/recent"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "/v4/checkin/recent"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -478,7 +478,7 @@ namespace Untappd.Net.Responses.Feeds.UserActivityFeed
|
||||
|
||||
public class UserActivityFeed : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/user/checkins{0}"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/user/checkins{0}"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace Untappd.Net.Responses.UserBadges
|
||||
/// </summary>
|
||||
public class UserBadges : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/user/badges{0}"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/user/badges{0}"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -225,7 +225,7 @@ namespace Untappd.Net.Responses.UserDistinctBeer
|
||||
|
||||
public class UserDistinctBeers : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/user/beers{0}"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/user/beers{0}"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Untappd.Net.Responses.UserFriends
|
||||
|
||||
public class UserFriends : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/user/friends{0}"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/user/friends{0}"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -1099,7 +1099,7 @@ namespace Untappd.Net.Responses.UserInfo
|
||||
|
||||
public class UserInfo : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/user/info{0}"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/user/info{0}"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace Untappd.Net.Responses.UserWishlist
|
||||
|
||||
public class UserWishList : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "/v4/user/wishlist{0}"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "/v4/user/wishlist{0}"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -1193,7 +1193,7 @@ namespace Untappd.Net.Responses.VenueInfo
|
||||
|
||||
public class VenueInfo : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
|
||||
{
|
||||
protected override string _EndPoint { get { return "v4/venue/info{0}"; } }
|
||||
protected override string EndPointWithConfiguration { get { return "v4/venue/info{0}"; } }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public Meta Meta { get; set; }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -30,10 +30,6 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath>..\..\packages\RestSharp.105.0.1\lib\net4\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -44,6 +40,9 @@
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="OAuth\AuthenticationHelper.cs" />
|
||||
|
||||
Reference in New Issue
Block a user