Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerwal committed Aug 31, 2014
1 parent abe00ac commit 1b22038
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,21 @@ public void GetResponseStatusTest()
);
}
}

/// <summary>
/// Tests the GetResponseStatus method when the Status parsing fails.
/// </summary>
[TestMethod]
public void GetResponseStatusParseFailTest()
{
BasicResponse basicResponse = new BasicResponse
{
Status = "unParsable"
};

ResponseStatusLookupId status = basicResponse.GetResponseStatus();

Assert.AreEqual(ResponseStatusLookupId.None, status, "The status should have been set to 'None'.");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

using CookComputing.XmlRpc;
using CookComputing.XmlRpc;
using MediaHandleUtilities.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SearchProcessing.OpenSubtitles;
using SearchProcessing.OpenSubtitles.Domain;
using System.Linq;
using System.Text.RegularExpressions;

namespace SearchProcessing.Test.OpenSubtitles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,17 @@ public void TokenTest()
[TestMethod]
public void TokenLogInResponseNullTest()
{
/*ConfigurationSettings.Initialize();
string username = ConfigurationSettings.OpenSubtitles.Username;
string password = ConfigurationSettings.OpenSubtitles.Password;
string language = ConfigurationSettings.OpenSubtitles.Language;
string userAgent = ConfigurationSettings.OpenSubtitles.UserAgent;
IOpenSubtitlesProxy proxy = XmlRpcProxyGen.Create<IOpenSubtitlesProxy>();
LogInResponse logInResponse = proxy.LogIn(username, password, language, userAgent);*/

OpenSubtitlesProxyWrapper wrapper = new OpenSubtitlesProxyWrapper
using (OpenSubtitlesProxyWrapper wrapper = new OpenSubtitlesProxyWrapper())
{
LogInResponse = null
};
// revert to this later so that correctly done Dispose (log out) can occure
LogInResponse savedLogInResponse = wrapper.LogInResponse;

Assert.IsNull(wrapper.Token, "The Token should be null.");
wrapper.LogInResponse = null;

wrapper.Dispose();
Assert.IsNull(wrapper.Token, "The Token should be null.");

wrapper.LogInResponse = savedLogInResponse;
}
}
}
}
5 changes: 5 additions & 0 deletions SearchProcessing/SearchProcessing/RequestProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public static TRootResult MakeRequest<TRootResult, TResult>(string requestUrl)
HttpWebRequest request = WebRequest.CreateHttp(requestUrl);
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
if (response == null)
{
return default(TRootResult);
}

if (response.StatusCode != HttpStatusCode.OK)
{
throw new Exception(String.Format("Server Error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription));
Expand Down

0 comments on commit 1b22038

Please sign in to comment.