Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerwal committed Jun 3, 2014
1 parent 96e6137 commit ca4a418
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SearchProcessing.OpenSubtitles;
using SearchProcessing.OpenSubtitles.Domain;

namespace SearchProcessing.Test.OpenSubtitles
{
Expand All @@ -9,7 +10,17 @@ public class OpenSubtitlesProxyWrapperTest
[TestMethod]
public void LogInLogOutTest()
{
OpenSubtitlesProxyWrapper wrapper = new OpenSubtitlesProxyWrapper();

ResponseStatusLookupId status = wrapper.GetSessionStatus();

Assert.AreEqual(ResponseStatusLookupId.Ok, status, "The session's status was not in an Ok state.");

wrapper.Dispose();

status = wrapper.GetSessionStatus();

Assert.AreEqual(ResponseStatusLookupId.NoSession, status, "The session was not ended correctly.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class OpenSubtitlesProxyWrapper : IDisposable
private string _language;
private string _userAgent;

private IOpenSubtitlesProxy _proxy;
private readonly IOpenSubtitlesProxy _proxy;

private LogInResponse _logInResponse;
private readonly LogInResponse _logInResponse;

#endregion Fields

Expand All @@ -40,14 +40,19 @@ public OpenSubtitlesProxyWrapper()

public void Dispose()
{
_proxy.LogOut(_logInResponse.Token);
LogOut();
}

#endregion IDisposable Members

#region Methods

public ResponseStatusLookupId GetSessionStatus()
{
BasicResponse response = _proxy.SessionCheck(_logInResponse.Token);

return response.GetResponseStatus();
}

#endregion Methods

Expand All @@ -66,6 +71,13 @@ private void InitializeConfiguration()
_userAgent = ConfigurationSettings.OpenSubtitles.UserAgent;
}

private bool LogOut()
{
ResponseStatusLookupId status = _proxy.LogOut(_logInResponse.Token).GetResponseStatus();

return status == ResponseStatusLookupId.Ok;
}

#endregion Helper Methods
}
}

0 comments on commit ca4a418

Please sign in to comment.