mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 13:53:19 -07:00
Removed the service locator from the base classes and added in some Api tests
added all the tests back in!
This commit is contained in:
parent
187a59261a
commit
84dc4515fd
21 changed files with 251 additions and 176 deletions
|
@ -25,6 +25,7 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Moq;
|
||||
|
||||
|
@ -32,6 +33,7 @@ using Nancy;
|
|||
using Nancy.Testing;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
|
@ -50,7 +52,6 @@ using PlexRequests.UI.Helpers;
|
|||
namespace PlexRequests.UI.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("Needs rework")]
|
||||
public class AdminModuleTests
|
||||
{
|
||||
private Mock<ISettingsService<PlexRequestSettings>> PlexRequestMock { get; set; }
|
||||
|
@ -71,6 +72,7 @@ namespace PlexRequests.UI.Tests
|
|||
private Mock<IRepository<LogEntity>> LogRepo { get; set; }
|
||||
private Mock<INotificationService> NotificationService { get; set; }
|
||||
private Mock<ICacheProvider> Cache { get; set; }
|
||||
private Mock<ISettingsService<LogSettings>> Log { get; set; }
|
||||
|
||||
private ConfigurableBootstrapper Bootstrapper { get; set; }
|
||||
|
||||
|
@ -83,9 +85,10 @@ namespace PlexRequests.UI.Tests
|
|||
|
||||
PlexMock = new Mock<IPlexApi>();
|
||||
PlexMock.Setup(x => x.SignIn("Username1", "Password1"))
|
||||
.Returns(new PlexAuthentication { user = new User { authentication_token = "abc", username = "Username1" } });
|
||||
.Returns(new PlexAuthentication { user = new User { authentication_token = "abc", title = "Username1" } });
|
||||
|
||||
PlexRequestMock = new Mock<ISettingsService<PlexRequestSettings>>();
|
||||
PlexRequestMock.Setup(x => x.GetSettings()).Returns(new PlexRequestSettings());
|
||||
CpMock = new Mock<ISettingsService<CouchPotatoSettings>>();
|
||||
PlexSettingsMock = new Mock<ISettingsService<PlexSettings>>();
|
||||
SonarrApiMock = new Mock<ISonarrApi>();
|
||||
|
@ -101,6 +104,7 @@ namespace PlexRequests.UI.Tests
|
|||
NotificationService = new Mock<INotificationService>();
|
||||
HeadphonesSettings = new Mock<ISettingsService<HeadphonesSettings>>();
|
||||
Cache = new Mock<ICacheProvider>();
|
||||
Log = new Mock<ISettingsService<LogSettings>>();
|
||||
|
||||
Bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
|
@ -123,16 +127,11 @@ namespace PlexRequests.UI.Tests
|
|||
with.Dependency(NotificationService.Object);
|
||||
with.Dependency(HeadphonesSettings.Object);
|
||||
with.Dependency(Cache.Object);
|
||||
with.ApplicationStartup(
|
||||
(container, pipelines) =>
|
||||
{
|
||||
var loc = ServiceLocator.Instance;
|
||||
loc.SetContainer(container);
|
||||
});
|
||||
with.Dependency(Log.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
with.RequestStartup((container, pipelines, context) =>
|
||||
{
|
||||
context.CurrentUser = new UserIdentity { UserName = "user" };
|
||||
context.CurrentUser = new UserIdentity { UserName = "user", Claims = new List<string> {"Admin"} };
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -240,7 +239,7 @@ namespace PlexRequests.UI.Tests
|
|||
[Test]
|
||||
public void GetUsersSuccessfully()
|
||||
{
|
||||
var users = new PlexFriends { User = new[] { new UserFriends { Username = "abc2" }, } };
|
||||
var users = new PlexFriends { User = new[] { new UserFriends { Title = "abc2" }, } };
|
||||
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(users);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
|
||||
|
@ -255,9 +254,11 @@ namespace PlexRequests.UI.Tests
|
|||
|
||||
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||
|
||||
var body = result.Body.AsString();
|
||||
|
||||
var body = JsonConvert.DeserializeObject<JObject>(result.Body.AsString());
|
||||
var user = body["users"];
|
||||
Assert.That(body, Is.Not.Null);
|
||||
Assert.That(body, Contains.Substring("abc2"));
|
||||
Assert.That(user.ToString().Contains("abc"), Is.True);
|
||||
|
||||
PlexMock.Verify(x => x.GetUsers(It.IsAny<string>()), Times.Once);
|
||||
AuthMock.Verify(x => x.GetSettings(), Times.Once);
|
||||
|
@ -276,6 +277,7 @@ namespace PlexRequests.UI.Tests
|
|||
with.Header("Accept", "application/json");
|
||||
with.FormValue("username", "Username1");
|
||||
with.FormValue("password", "Password1");
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -24,22 +24,37 @@
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
using FluentValidation;
|
||||
|
||||
using Moq;
|
||||
|
||||
using Nancy;
|
||||
using Nancy.Bootstrapper;
|
||||
using Nancy.Testing;
|
||||
using Nancy.Validation;
|
||||
using Nancy.Validation.FluentValidation;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.UI.Helpers;
|
||||
using PlexRequests.Store;
|
||||
using PlexRequests.UI.Models;
|
||||
using PlexRequests.UI.Modules;
|
||||
using PlexRequests.UI.Validators;
|
||||
|
||||
using Ploeh.AutoFixture;
|
||||
|
||||
namespace PlexRequests.UI.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("Locator :(")]
|
||||
public class ApiModuleTests
|
||||
{
|
||||
private ConfigurableBootstrapper Bootstrapper { get; set; }
|
||||
|
@ -47,38 +62,147 @@ namespace PlexRequests.UI.Tests
|
|||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var requests = new Fixture().CreateMany<RequestedModel>();
|
||||
var requestMock = new Mock<IRequestService>();
|
||||
var settingsMock = new Mock<ISettingsService<PlexRequestSettings>>();
|
||||
settingsMock.Setup(x => x.GetSettings()).Returns(new PlexRequestSettings {ApiKey = "api"});
|
||||
requestMock.Setup(x => x.GetAll()).Returns(requests);
|
||||
requestMock.Setup(x => x.Get(1)).Returns(requests.FirstOrDefault());
|
||||
requestMock.Setup(x => x.Get(99)).Returns(new RequestedModel());
|
||||
requestMock.Setup(x => x.DeleteRequest(It.IsAny<RequestedModel>()));
|
||||
|
||||
Bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<ApiModule>();
|
||||
with.Dependency(requestMock.Object);
|
||||
with.Dependency(settingsMock.Object);
|
||||
with.ApplicationStartup(
|
||||
(c, a) =>
|
||||
{
|
||||
var loc = ServiceLocator.Instance;
|
||||
loc.SetContainer(c);
|
||||
});
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
with.ModelValidatorLocator(
|
||||
new DefaultValidatorLocator(
|
||||
new List<IModelValidatorFactory>()
|
||||
{
|
||||
new FluentValidationValidatorFactory(
|
||||
new DefaultFluentAdapterFactory(new List<IFluentAdapter>()),
|
||||
new List<IValidator> { new RequestedModelValidator() })
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Action<BrowserContext> GetBrowser()
|
||||
{
|
||||
return with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
with.Header("Accept", "application/json");
|
||||
with.Query("apikey", "api");
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InvalidApiKey()
|
||||
{
|
||||
var browser = new Browser(Bootstrapper);
|
||||
|
||||
var result = browser.Get("/api/requests", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
with.Header("Accept", "application/json");
|
||||
with.Query("apikey","a");
|
||||
});
|
||||
|
||||
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||
|
||||
var body = JsonConvert.DeserializeObject<ApiModel<List<RequestedModel>>>(result.Body.AsString());
|
||||
Assert.That(body.Error, Is.True);
|
||||
Assert.That(body.ErrorMessage, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllRequests()
|
||||
{
|
||||
|
||||
var browser = new Browser(Bootstrapper);
|
||||
|
||||
var result = browser.Post("/api/requests", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
with.Header("Accept", "application/json");
|
||||
with.Query("apikey","a");
|
||||
|
||||
});
|
||||
|
||||
var result = browser.Get("/api/requests", GetBrowser());
|
||||
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||
|
||||
var body = JsonConvert.DeserializeObject<ApiModel<List<RequestedModel>>>(result.Body.AsString());
|
||||
Assert.That(body.Data, Is.Not.Null);
|
||||
Assert.That(body.Data.Count, Is.GreaterThan(0));
|
||||
Assert.That(body.Error, Is.False);
|
||||
Assert.That(body.ErrorMessage, Is.Null.Or.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSingleRequest()
|
||||
{
|
||||
var browser = new Browser(Bootstrapper);
|
||||
|
||||
var result = browser.Get("/api/requests/1", GetBrowser());
|
||||
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||
|
||||
var body = JsonConvert.DeserializeObject<ApiModel<List<RequestedModel>>>(result.Body.AsString());
|
||||
Assert.That(body.Data, Is.Not.Null);
|
||||
Assert.That(body.Data.Count, Is.EqualTo(1));
|
||||
Assert.That(body.Error, Is.False);
|
||||
Assert.That(body.ErrorMessage, Is.Null.Or.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSingleRequestThatDoesntExist()
|
||||
{
|
||||
var browser = new Browser(Bootstrapper);
|
||||
|
||||
var result = browser.Get("/api/requests/99", GetBrowser());
|
||||
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||
|
||||
var body = JsonConvert.DeserializeObject<ApiModel<List<RequestedModel>>>(result.Body.AsString());
|
||||
Assert.That(body.Data, Is.Not.Null);
|
||||
Assert.That(body.Data.Count, Is.EqualTo(0));
|
||||
Assert.That(body.Error, Is.True);
|
||||
Assert.That(body.ErrorMessage, Is.Not.Null.Or.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteARequest()
|
||||
{
|
||||
var browser = new Browser(Bootstrapper);
|
||||
|
||||
var result = browser.Delete("/api/requests/1", GetBrowser());
|
||||
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||
|
||||
var body = JsonConvert.DeserializeObject<ApiModel<bool>>(result.Body.AsString());
|
||||
Assert.That(body.Data, Is.True);
|
||||
Assert.That(body.Error, Is.False);
|
||||
Assert.That(body.ErrorMessage, Is.Null.Or.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteARequestThatDoesNotExist()
|
||||
{
|
||||
var browser = new Browser(Bootstrapper);
|
||||
|
||||
var result = browser.Delete("/api/requests/99", GetBrowser());
|
||||
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||
|
||||
var body = JsonConvert.DeserializeObject<ApiModel<bool>>(result.Body.AsString());
|
||||
Assert.That(body.Data, Is.False);
|
||||
Assert.That(body.Error, Is.True);
|
||||
Assert.That(body.ErrorMessage, Is.Not.Null.Or.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateAEmptyRequest()
|
||||
{
|
||||
var browser = new Browser(Bootstrapper);
|
||||
|
||||
var result = browser.Post("/api/requests/", GetBrowser());
|
||||
Assert.That(HttpStatusCode.OK, Is.EqualTo(result.StatusCode));
|
||||
|
||||
var body = JsonConvert.DeserializeObject<ApiModel<string[]>>(result.Body.AsString());
|
||||
Assert.That(body.Data, Is.Not.Null.Or.Empty);
|
||||
Assert.That(body.Error, Is.True);
|
||||
Assert.That(body.ErrorMessage, Is.Not.Null.Or.Empty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,11 @@
|
|||
<HintPath>..\packages\FluentScheduler.3.1.46\lib\net40\FluentScheduler.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="FluentValidation, Version=6.2.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentValidation.6.2.1.0\lib\Net45\FluentValidation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
@ -58,6 +63,10 @@
|
|||
<HintPath>..\packages\Nancy.Testing.1.4.1\lib\net40\Nancy.Testing.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Validation.FluentValidation, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Nancy.Validation.FluentValidation.1.4.1\lib\net40\Nancy.Validation.FluentValidation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.ViewEngines.Razor, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Nancy.Viewengines.Razor.1.4.3\lib\net40\Nancy.ViewEngines.Razor.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
|
|
@ -47,11 +47,12 @@ using PlexRequests.UI.Modules;
|
|||
namespace PlexRequests.UI.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("Needs some work")]
|
||||
//[Ignore("Needs some work")]
|
||||
public class UserLoginModuleTests
|
||||
{
|
||||
private Mock<ISettingsService<AuthenticationSettings>> AuthMock { get; set; }
|
||||
private Mock<ISettingsService<PlexRequestSettings>> PlexRequestMock { get; set; }
|
||||
private ConfigurableBootstrapper Bootstrapper { get; set; }
|
||||
private Mock<IPlexApi> PlexMock { get; set; }
|
||||
|
||||
[SetUp]
|
||||
|
@ -60,6 +61,15 @@ namespace PlexRequests.UI.Tests
|
|||
AuthMock = new Mock<ISettingsService<AuthenticationSettings>>();
|
||||
PlexMock = new Mock<IPlexApi>();
|
||||
PlexRequestMock = new Mock<ISettingsService<PlexRequestSettings>>();
|
||||
PlexRequestMock.Setup(x => x.GetSettings()).Returns(new PlexRequestSettings());
|
||||
Bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(PlexRequestMock.Object);
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -68,21 +78,11 @@ namespace PlexRequests.UI.Tests
|
|||
var expectedSettings = new AuthenticationSettings { UserAuthentication = false, PlexAuthToken = "abc" };
|
||||
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
|
||||
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.Dependency(PlexRequestMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
|
||||
var loc = ServiceLocator.Instance;
|
||||
loc.SetContainer(TinyIoCContainer.Current);
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
var result = browser.Post("/userlogin", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
|
@ -106,17 +106,10 @@ namespace PlexRequests.UI.Tests
|
|||
var expectedSettings = new AuthenticationSettings { UserAuthentication = false, PlexAuthToken = "abc" };
|
||||
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
|
||||
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
var result = browser.Post("/userlogin", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
|
@ -143,7 +136,7 @@ namespace PlexRequests.UI.Tests
|
|||
{
|
||||
new UserFriends
|
||||
{
|
||||
Username = "abc",
|
||||
Title = "abc",
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -152,17 +145,9 @@ namespace PlexRequests.UI.Tests
|
|||
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(plexFriends);
|
||||
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(new PlexAccount());
|
||||
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
var result = browser.Post("/userlogin", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
|
@ -199,17 +184,9 @@ namespace PlexRequests.UI.Tests
|
|||
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(plexFriends);
|
||||
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(new PlexAccount());
|
||||
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
|
||||
var result = browser.Post("/userlogin", with =>
|
||||
{
|
||||
|
@ -240,7 +217,7 @@ namespace PlexRequests.UI.Tests
|
|||
{
|
||||
new UserFriends
|
||||
{
|
||||
Username = "abc",
|
||||
Title = "abc",
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -257,17 +234,9 @@ namespace PlexRequests.UI.Tests
|
|||
PlexMock.Setup(x => x.SignIn(It.IsAny<string>(), It.IsAny<string>())).Returns(plexAuth);
|
||||
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(new PlexAccount());
|
||||
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
var result = browser.Post("/userlogin", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
|
@ -310,17 +279,10 @@ namespace PlexRequests.UI.Tests
|
|||
PlexMock.Setup(x => x.GetUsers(It.IsAny<string>())).Returns(plexFriends);
|
||||
PlexMock.Setup(x => x.SignIn(It.IsAny<string>(), It.IsAny<string>())).Returns(plexAuth);
|
||||
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
|
||||
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
var result = browser.Post("/userlogin", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
|
@ -347,17 +309,9 @@ namespace PlexRequests.UI.Tests
|
|||
var expectedSettings = new AuthenticationSettings { UserAuthentication = false, DeniedUsers = "abc", PlexAuthToken = "abc" };
|
||||
AuthMock.Setup(x => x.GetSettings()).Returns(expectedSettings);
|
||||
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
var result = browser.Post("/userlogin", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
|
@ -379,17 +333,9 @@ namespace PlexRequests.UI.Tests
|
|||
[Test]
|
||||
public void Logout()
|
||||
{
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
Bootstrapper.WithSession(new Dictionary<string, object> { { SessionKeys.UsernameKey, "abc" } });
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object> { { SessionKeys.UsernameKey, "abc" } });
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
var result = browser.Get("/userlogin/logout", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
|
@ -418,17 +364,9 @@ namespace PlexRequests.UI.Tests
|
|||
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(account);
|
||||
PlexMock.Setup(x => x.SignIn(It.IsAny<string>(), It.IsAny<string>())).Returns(new PlexAuthentication { user = new User { username = "Jamie" } });
|
||||
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
var result = browser.Post("/userlogin", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
|
@ -473,17 +411,9 @@ namespace PlexRequests.UI.Tests
|
|||
PlexMock.Setup(x => x.SignIn(It.IsAny<string>(), It.IsAny<string>())).Returns(plexAuth);
|
||||
PlexMock.Setup(x => x.GetAccount(It.IsAny<string>())).Returns(account);
|
||||
|
||||
var bootstrapper = new ConfigurableBootstrapper(with =>
|
||||
{
|
||||
with.Module<UserLoginModule>();
|
||||
with.Dependency(AuthMock.Object);
|
||||
with.Dependency(PlexMock.Object);
|
||||
with.RootPathProvider<TestRootPathProvider>();
|
||||
});
|
||||
Bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
bootstrapper.WithSession(new Dictionary<string, object>());
|
||||
|
||||
var browser = new Browser(bootstrapper);
|
||||
var browser = new Browser(Bootstrapper);
|
||||
var result = browser.Post("/userlogin", with =>
|
||||
{
|
||||
with.HttpRequest();
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
<package id="AutoFixture" version="3.40.0" targetFramework="net452" />
|
||||
<package id="CsQuery" version="1.3.3" targetFramework="net46" />
|
||||
<package id="FluentScheduler" version="3.1.46" targetFramework="net46" />
|
||||
<package id="FluentValidation" version="6.2.1.0" targetFramework="net46" />
|
||||
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net46" />
|
||||
<package id="Moq" version="4.2.1510.2205" targetFramework="net452" />
|
||||
<package id="Nancy" version="1.4.3" targetFramework="net46" />
|
||||
<package id="Nancy.Testing" version="1.4.1" targetFramework="net46" />
|
||||
<package id="Nancy.Validation.FluentValidation" version="1.4.1" targetFramework="net46" />
|
||||
<package id="Nancy.Viewengines.Razor" version="1.4.3" targetFramework="net46" />
|
||||
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net46" />
|
||||
<package id="NUnit" version="3.2.0" targetFramework="net46" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue