1 Commits

Author SHA1 Message Date
Tommy Parnell
4c6b62ec30 oops 2016-11-07 08:03:28 -05:00
5 changed files with 94 additions and 94 deletions

View File

@@ -25,7 +25,7 @@ task :lint => [:build, :cs_lint]
desc 'Retrieve, Build, Test' desc 'Retrieve, Build, Test'
task :preflight => [:clean, :retrieve, :build, :test, :lint] task :preflight => [:clean, :retrieve, :build, :test, :lint]
throw "oops"
desc 'cleans up artifacts' desc 'cleans up artifacts'
task :clean do task :clean do
puts 'cleaning artifacts from directory' puts 'cleaning artifacts from directory'

View File

@@ -6,25 +6,25 @@ namespace Untappd.Net.UnitTests.Exception
[TestFixture] [TestFixture]
public class TestBaseUntappdException public class TestBaseUntappdException
{ {
//[ExpectedException(typeof(BaseUntappdException))] [ExpectedException(typeof(BaseUntappdException))]
[Test] [Test]
public void TestStandardException() public void TestStandardException()
{ {
//throw new BaseUntappdException(); throw new BaseUntappdException();
} }
//[ExpectedException(typeof(BaseUntappdException), ExpectedMessage = "messageHere")] [ExpectedException(typeof(BaseUntappdException), ExpectedMessage = "messageHere")]
[Test] [Test]
public void TestStandardExceptionWithMessage() public void TestStandardExceptionWithMessage()
{ {
//throw new BaseUntappdException("messageHere"); throw new BaseUntappdException("messageHere");
} }
//[ExpectedException(typeof(BaseUntappdException), ExpectedMessage = "messageHere")] [ExpectedException(typeof(BaseUntappdException), ExpectedMessage = "messageHere")]
[Test] [Test]
public void TestStandardExceptionWithInner() public void TestStandardExceptionWithInner()
{ {
throw new BaseUntappdException("messageHere", new System.Exception("innerException!"));
} }
} }
} }

View File

@@ -7,10 +7,10 @@ namespace Untappd.Net.UnitTests.Exception
public class TestEndpointConfigurationException public class TestEndpointConfigurationException
{ {
[Test] [Test]
//[ExpectedException(typeof(EndpointConfigurationException), ExpectedMessage = "Invalid endpoint configured")] [ExpectedException(typeof(EndpointConfigurationException), ExpectedMessage = "Invalid endpoint configured")]
public void TestThrownExeption() public void TestThrownExeption()
{ {
//throw new EndpointConfigurationException(); throw new EndpointConfigurationException();
} }
} }
} }

View File

@@ -12,19 +12,19 @@ namespace Untappd.Net.UnitTests.Exception
[Test] [Test]
public void ConfirmNullExceptions() public void ConfirmNullExceptions()
{ {
// var mockRequest = new Mock<IRestRequest>(); var mockRequest = new Mock<IRestRequest>();
// var mockResponse = new Mock<IRestResponse>(); var mockResponse = new Mock<IRestResponse>();
// Assert.Throws<ArgumentNullException>(() => Assert.Throws<ArgumentNullException>(() =>
// { {
// var t = new HttpErrorException(mockRequest.Object, null); var t = new HttpErrorException(mockRequest.Object, null);
// Console.WriteLine(t); Console.WriteLine(t);
// }); });
// Assert.Throws<ArgumentNullException>(() => Assert.Throws<ArgumentNullException>(() =>
// { {
// var t = new HttpErrorException(null, mockResponse.Object); var t = new HttpErrorException(null, mockResponse.Object);
// Console.WriteLine(t); Console.WriteLine(t);
// }); });
} }
} }
} }

View File

@@ -19,100 +19,100 @@ namespace Untappd.Net.UnitTests.Request
[Test] [Test]
public void ConfirmRequestWorks() public void ConfirmRequestWorks()
{ {
// var mockCreds = new Mock<IUnAuthenticatedUntappdCredentials>(); var mockCreds = new Mock<IUnAuthenticatedUntappdCredentials>();
// mockCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() mockCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
// { {
// {"client_id", "id"}, {"client_id", "id"},
// {"client_secret", "secret"} {"client_secret", "secret"}
// })); }));
// var bodyParam = new Dictionary<string, object> { { "key", "value" } }; var bodyParam = new Dictionary<string, object> { { "key", "value" } };
// var client = new Mock<IRestClient>(); var client = new Mock<IRestClient>();
// var request = new Mock<IRestRequest>(); var request = new Mock<IRestRequest>();
// request.Setup(a => a.AddParameter(It.IsAny<string>(), It.IsAny<string>())); request.Setup(a => a.AddParameter(It.IsAny<string>(), It.IsAny<string>()));
// request.Setup(a => a.AddParameter(It.IsAny<string>(), It.IsAny<string>())); request.Setup(a => a.AddParameter(It.IsAny<string>(), It.IsAny<string>()));
// var response = new Mock<IRestResponse>(); 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(() => client.Setup(a => a.Execute(It.IsAny<IRestRequest>())).Callback(() =>
// { {
// }).Returns(response.Object); }).Returns(response.Object);
// client.Setup(a => a.ExecuteTaskAsync(It.IsAny<IRestRequest>())).Callback(() => client.Setup(a => a.ExecuteTaskAsync(It.IsAny<IRestRequest>())).Callback(() =>
// { {
// }).Returns(Task.Run(() => response.Object)); }).Returns(Task.Run(() => response.Object));
// #pragma warning disable CS0618 // Type or member is obsolete Using as intended #pragma warning disable CS0618 // Type or member is obsolete Using as intended
// var repository = new Repository(client.Object, request.Object); var repository = new Repository(client.Object, request.Object);
// #pragma warning restore CS0618 // Type or member is obsolete #pragma warning restore CS0618 // Type or member is obsolete
// repository.Get<BeerInfo>(mockCreds.Object, "awesome", bodyParam); repository.Get<BeerInfo>(mockCreds.Object, "awesome", bodyParam);
// request.Verify(a => a.AddParameter("client_id", mockCreds.Object.AuthenticationData["client_id"])); request.Verify(a => a.AddParameter("client_id", mockCreds.Object.AuthenticationData["client_id"]));
// request.Verify(a => a.AddParameter("client_secret", mockCreds.Object.AuthenticationData["client_secret"])); request.Verify(a => a.AddParameter("client_secret", mockCreds.Object.AuthenticationData["client_secret"]));
// request.Verify(a => a.AddParameter("key", "value")); request.Verify(a => a.AddParameter("key", "value"));
// repository.GetAsync<BeerInfo>(mockCreds.Object, "awesome", bodyParam).Wait(); repository.GetAsync<BeerInfo>(mockCreds.Object, "awesome", bodyParam).Wait();
// request.Verify(a => a.AddParameter("client_id", mockCreds.Object.AuthenticationData["client_id"])); request.Verify(a => a.AddParameter("client_id", mockCreds.Object.AuthenticationData["client_id"]));
// request.Verify(a => a.AddParameter("client_secret", mockCreds.Object.AuthenticationData["client_secret"])); request.Verify(a => a.AddParameter("client_secret", mockCreds.Object.AuthenticationData["client_secret"]));
// request.Verify(a => a.AddParameter("key", "value")); request.Verify(a => a.AddParameter("key", "value"));
// var mockAuthCreds = new Mock<IAuthenticatedUntappdCredentials>(); var mockAuthCreds = new Mock<IAuthenticatedUntappdCredentials>();
// mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
// { {
// {"access_token", "accessToken"} {"access_token", "accessToken"}
// })); }));
// repository.Get<BeerInfo>(mockAuthCreds.Object, "awesome", bodyParam); repository.Get<BeerInfo>(mockAuthCreds.Object, "awesome", bodyParam);
// request.Verify(a => a.AddParameter("key", "value")); request.Verify(a => a.AddParameter("key", "value"));
// request.Verify(a => a.AddParameter("access_token", "accessToken")); request.Verify(a => a.AddParameter("access_token", "accessToken"));
// repository.GetAsync<BeerInfo>(mockAuthCreds.Object, "awesome", bodyParam).Wait(); repository.GetAsync<BeerInfo>(mockAuthCreds.Object, "awesome", bodyParam).Wait();
// request.Verify(a => a.AddParameter("key", "value")); request.Verify(a => a.AddParameter("key", "value"));
// request.Verify(a => a.AddParameter("access_token", "accessToken")); request.Verify(a => a.AddParameter("access_token", "accessToken"));
// mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
// { {
// {"access_token", "PostaccessToken"} {"access_token", "PostaccessToken"}
// })); }));
// var checkin = new CheckIn("-5", "EST", 1044097) { Shout = "Awesome Brew", Rating = 4 }; var checkin = new CheckIn("-5", "EST", 1044097) { Shout = "Awesome Brew", Rating = 4 };
// repository.FailFast = true; repository.FailFast = true;
// repository.OnExceptionThrown += (sender, e) => repository.OnExceptionThrown += (sender, e) =>
// { {
// Assert.IsNotNull(sender); Assert.IsNotNull(sender);
// Assert.IsNotNull(e); Assert.IsNotNull(e);
// }; };
// Assert.Throws<HttpErrorException>(() => repository.Post(mockAuthCreds.Object, checkin)); Assert.Throws<HttpErrorException>(() => repository.Post(mockAuthCreds.Object, checkin));
// repository.FailFast = false; repository.FailFast = false;
// repository.Post(mockAuthCreds.Object, checkin); repository.Post(mockAuthCreds.Object, checkin);
// request.Verify(a => a.AddParameter("access_token", "PostaccessToken")); request.Verify(a => a.AddParameter("access_token", "PostaccessToken"));
// mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
// { {
// {"access_token", "PostAsyncaccessToken"} {"access_token", "PostAsyncaccessToken"}
// })); }));
// repository.PostAsync(mockAuthCreds.Object, checkin).Wait(); repository.PostAsync(mockAuthCreds.Object, checkin).Wait();
// request.Verify(a => a.AddParameter("access_token", "PostAsyncaccessToken")); request.Verify(a => a.AddParameter("access_token", "PostAsyncaccessToken"));
} }
[Test] [Test]
public void ConfirmBasicConstructorWorks() public void ConfirmBasicConstructorWorks()
{ {
// var constructorTest = new Repository(); var constructorTest = new Repository();
// Assert.IsTrue(constructorTest.Client != null); Assert.IsTrue(constructorTest.Client != null);
// Assert.IsTrue(constructorTest.Request != null); Assert.IsTrue(constructorTest.Request != null);
} }
[Test] [Test]
public void TimeoutShouldGetPassedIn() public void TimeoutShouldGetPassedIn()
{ {
// var timeout = 100; var timeout = 100;
// var repo = new Repository(timeout: timeout); var repo = new Repository(timeout: timeout);
// Assert.AreEqual(repo.Request.Timeout, timeout); Assert.AreEqual(repo.Request.Timeout, timeout);
} }
[Test] [Test]
public void ConfirmConfigureGetRequestClearsParams() public void ConfirmConfigureGetRequestClearsParams()
{ {
// var constructorTest = new Repository(); var constructorTest = new Repository();
// constructorTest.Request.Parameters.Add(new Parameter { Name = "param" }); constructorTest.Request.Parameters.Add(new Parameter { Name = "param" });
// Assert.IsTrue(constructorTest.Request.Parameters.Count > 0); Assert.IsTrue(constructorTest.Request.Parameters.Count > 0);
// constructorTest.ConfigureRequest("endpoint"); constructorTest.ConfigureRequest("endpoint");
// Assert.IsTrue(constructorTest.Request.Parameters.Count == 0); Assert.IsTrue(constructorTest.Request.Parameters.Count == 0);
} }
} }
} }