diff --git a/PlexRequestes.Automation.Helpers/DatabaseConfiguration.cs b/PlexRequestes.Automation.Helpers/DatabaseConfiguration.cs new file mode 100644 index 000000000..c72b27e43 --- /dev/null +++ b/PlexRequestes.Automation.Helpers/DatabaseConfiguration.cs @@ -0,0 +1,81 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: DatabaseConfiguration.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +using Mono.Data.Sqlite; + +using PlexRequests.Core; +using PlexRequests.Core.SettingModels; +using PlexRequests.Helpers; +using PlexRequests.Store; +using PlexRequests.Store.Repository; + +namespace PlexRequestes.Automation.Helpers +{ + public static class DatabaseConfiguration + { + private static SettingsJsonRepository _jsonRepository = new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()); + + public static void ResetDatabase() + { + var defaultSettings = new PlexRequestSettings + { + RequireTvShowApproval = true, + RequireMovieApproval = true, + SearchForMovies = true, + SearchForTvShows = true, + BaseUrl = string.Empty, + CollectAnalyticData = true, + }; + UpdateSettings(defaultSettings); + + LandingPageSettings lp = null; + PlexSettings plexSettings = null; + SonarrSettings sonarr = null; + CouchPotatoSettings cp = null; + SickRageSettings sr = null; + UpdateSettings(lp); + UpdateSettings(plexSettings); + UpdateSettings(sonarr); + UpdateSettings(cp); + UpdateSettings(sr); + + + } + + + public static void UpdateSettings(T settings) where T : Settings, new() + { + var service = new SettingsServiceV2(_jsonRepository); + if (settings == null) + { + var existing = service.GetSettings(); + service.Delete(existing); + return; + } + service.SaveSettings(settings); + } + } +} \ No newline at end of file diff --git a/PlexRequestes.Automation.Helpers/DriverHelpers.cs b/PlexRequestes.Automation.Helpers/DriverHelpers.cs new file mode 100644 index 000000000..ca2564473 --- /dev/null +++ b/PlexRequestes.Automation.Helpers/DriverHelpers.cs @@ -0,0 +1,77 @@ +using System; + +using OpenQA.Selenium; + +namespace PlexRequestes.Automation.Helpers +{ + public static class DriverHelpers + { + public static bool Exists(this IWebElement element, bool preformAStringEmptyCheck) + { + try + { + var text = element.Text; + if (preformAStringEmptyCheck) + { + if (string.IsNullOrEmpty(text)) + { + return false; + } + } + } + catch (NoSuchElementException) + { + return false; + } + + return true; + } + + public static bool Exists(this IWebDriver driver, By locator, bool preformAStringEmptyCheck) + { + try + { + var element = driver.FindElement(locator); + var text = element.Text; + if (preformAStringEmptyCheck) + { + if (string.IsNullOrEmpty(text)) + { + return false; + } + } + } + catch (NoSuchElementException) + { + return false; + } + + return true; + } + + /// + /// The exists. + /// + /// The element. + /// + /// The . + /// + public static bool Exists(this IWebElement element) + { + try + { + var text = element.Text; + if (string.IsNullOrEmpty(text)) + { + return false; + } + } + catch (Exception) + { + return false; + } + + return true; + } + } +} diff --git a/PlexRequestes.Automation.Helpers/PlexRequestes.Automation.Helpers.csproj b/PlexRequestes.Automation.Helpers/PlexRequestes.Automation.Helpers.csproj new file mode 100644 index 000000000..850f474fa --- /dev/null +++ b/PlexRequestes.Automation.Helpers/PlexRequestes.Automation.Helpers.csproj @@ -0,0 +1,88 @@ + + + + + Debug + AnyCPU + {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288} + Library + Properties + PlexRequestes.Automation.Helpers + PlexRequestes.Automation.Helpers + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll + True + + + ..\Assemblies\Mono.Data.Sqlite.dll + + + + + + + + + + + + ..\packages\Selenium.WebDriver.2.53.1\lib\net40\WebDriver.dll + True + + + ..\packages\Selenium.Support.2.53.1\lib\net40\WebDriver.Support.dll + True + + + + + + + + + + + + + {dd7dc444-d3bf-4027-8ab9-efc71f5ec581} + PlexRequests.Core + + + {1252336D-42A3-482A-804C-836E60173DFA} + PlexRequests.Helpers + + + {92433867-2b7b-477b-a566-96c382427525} + PlexRequests.Store + + + + + \ No newline at end of file diff --git a/PlexRequestes.Automation.Helpers/Properties/AssemblyInfo.cs b/PlexRequestes.Automation.Helpers/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..81cb11299 --- /dev/null +++ b/PlexRequestes.Automation.Helpers/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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. +[assembly: AssemblyTitle("PlexRequestes.Automation.Helpers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PlexRequestes.Automation.Helpers")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("dc8bacef-c284-4a8f-a9aa-7f49efaba288")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PlexRequestes.Automation.Helpers/packages.config b/PlexRequestes.Automation.Helpers/packages.config new file mode 100644 index 000000000..34b40b473 --- /dev/null +++ b/PlexRequestes.Automation.Helpers/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PlexRequests.Automation.Pages/BasePage.cs b/PlexRequests.Automation.Pages/BasePage.cs new file mode 100644 index 000000000..dd8838004 --- /dev/null +++ b/PlexRequests.Automation.Pages/BasePage.cs @@ -0,0 +1,38 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: BasePage.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +using OpenQA.Selenium; +using OpenQA.Selenium.Support.PageObjects; + +namespace PlexRequests.Automation.Pages +{ + public class BasePage + { + [FindsBy(How = How.XPath, Using = "/html/body/div[5]")] + public IWebElement Notificaiton { get; set; } + protected IWebDriver WebDriver { get; set; } + } +} \ No newline at end of file diff --git a/PlexRequests.Automation.Pages/PlexRequests.Automation.Pages.csproj b/PlexRequests.Automation.Pages/PlexRequests.Automation.Pages.csproj new file mode 100644 index 000000000..4a7817af0 --- /dev/null +++ b/PlexRequests.Automation.Pages/PlexRequests.Automation.Pages.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {F8D4A7A7-F0FB-4D04-81DB-637C953E0707} + Library + Properties + PlexRequests.Automation.Pages + PlexRequests.Automation.Pages + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + ..\packages\Selenium.WebDriver.2.53.1\lib\net40\WebDriver.dll + True + + + ..\packages\Selenium.Support.2.53.1\lib\net40\WebDriver.Support.dll + True + + + + + + + + + + + + + + {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288} + PlexRequestes.Automation.Helpers + + + + + \ No newline at end of file diff --git a/PlexRequests.Automation.Pages/Properties/AssemblyInfo.cs b/PlexRequests.Automation.Pages/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..3236727f1 --- /dev/null +++ b/PlexRequests.Automation.Pages/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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. +[assembly: AssemblyTitle("PlexRequests.Automation.Pages")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PlexRequests.Automation.Pages")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f8d4a7a7-f0fb-4d04-81db-637c953e0707")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PlexRequests.Automation.Pages/SearchPage.cs b/PlexRequests.Automation.Pages/SearchPage.cs new file mode 100644 index 000000000..94506168a --- /dev/null +++ b/PlexRequests.Automation.Pages/SearchPage.cs @@ -0,0 +1,89 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SearchPage.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +using OpenQA.Selenium; +using OpenQA.Selenium.Support.PageObjects; + +using PlexRequestes.Automation.Helpers; + +namespace PlexRequests.Automation.Pages +{ + public class SearchPage : BasePage + { + public SearchPage(IWebDriver webDriver) + { + WebDriver = webDriver; + PageFactory.InitElements(WebDriver, this); + + while (!PageTitle.Exists()) + { + Thread.Sleep(500); + PageFactory.InitElements(WebDriver, this); + } + } + + [FindsBy(How = How.Id, Using = "searchTitle")] + public IWebElement PageTitle { get; set; } + + [FindsBy(How = How.Id, Using = "movieSearchContent")] + public IWebElement SearchBox { get; set; } + + [FindsBy(How = How.Id, Using = "movieTabButton")] + public IWebElement MovieTab { get; set; } + + [FindsBy(How = How.XPath, Using = "//*[@id=\"movieList\"]/div")] + public IList MovieResults { get; set; } + + public SearchPage SearchForMovie(string movie) + { + MovieTab.Click(); + + SearchBox.SendKeys(movie); + + while (MovieResults.Count < 0) + { + Thread.Sleep(500); + PageFactory.InitElements(WebDriver, this); + } + + return this; + } + + public bool RequestMovie(IWebElement movieElement) + { + var request = movieElement.FindElement(By.XPath(".//div[3]/form/button")); + request.Click(); + + PageFactory.InitElements(WebDriver, this); + + return Notificaiton.Exists(); + } + } +} \ No newline at end of file diff --git a/PlexRequests.Automation.Pages/UserLoginPage.cs b/PlexRequests.Automation.Pages/UserLoginPage.cs new file mode 100644 index 000000000..7cf6ad3b6 --- /dev/null +++ b/PlexRequests.Automation.Pages/UserLoginPage.cs @@ -0,0 +1,36 @@ +using OpenQA.Selenium; +using OpenQA.Selenium.Support.PageObjects; + +using PlexRequestes.Automation.Helpers; + +namespace PlexRequests.Automation.Pages +{ + public class UserLoginPage : BasePage + { + public UserLoginPage(IWebDriver webDriver) + { + WebDriver = webDriver; + PageFactory.InitElements(WebDriver, this); + } + + [FindsBy(How = How.Id, Using = "username")] + public IWebElement Username { get; set; } + [FindsBy(How = How.Id, Using = "password")] + public IWebElement Password { get; set; } + [FindsBy(How = How.Id, Using = "loginBtn")] + public IWebElement Submit { get; set; } + + public SearchPage Login(string username, string password = "") + { + Username.SendKeys(username); + + if (Password.Exists(false) && !string.IsNullOrEmpty(password)) + { + Password.SendKeys(password); + } + + Submit.Click(); + return new SearchPage(WebDriver); + } + } +} diff --git a/PlexRequests.Automation.Pages/packages.config b/PlexRequests.Automation.Pages/packages.config new file mode 100644 index 000000000..b142e9d72 --- /dev/null +++ b/PlexRequests.Automation.Pages/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/PlexRequests.Automation/AutomationTestBase.cs b/PlexRequests.Automation/AutomationTestBase.cs new file mode 100644 index 000000000..84560035d --- /dev/null +++ b/PlexRequests.Automation/AutomationTestBase.cs @@ -0,0 +1,42 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: AutomationTestBase.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +using System.Reflection; + +using OpenQA.Selenium; + +namespace PlexRequests.Automation +{ + public class AutomationTestBase + { + protected IWebDriver Driver { get; set; } + + public AutomationTestBase(string url) + { + Driver = WebDriverSetup.SetUp(url); + } + } +} \ No newline at end of file diff --git a/PlexRequests.Automation/PlexRequests.Automation.csproj b/PlexRequests.Automation/PlexRequests.Automation.csproj new file mode 100644 index 000000000..b9218b815 --- /dev/null +++ b/PlexRequests.Automation/PlexRequests.Automation.csproj @@ -0,0 +1,107 @@ + + + + Debug + AnyCPU + {40DC5C6C-2860-44D0-9F91-DEB84C22D103} + Library + Properties + PlexRequests.Automation + PlexRequests.Automation + v4.5.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll + True + + + + + ..\packages\Selenium.WebDriver.2.53.1\lib\net40\WebDriver.dll + True + + + ..\packages\Selenium.Support.2.53.1\lib\net40\WebDriver.Support.dll + True + + + + + + + + + + + + + + + + + + + + + + {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288} + PlexRequestes.Automation.Helpers + + + {F8D4A7A7-F0FB-4D04-81DB-637C953E0707} + PlexRequests.Automation.Pages + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/PlexRequests.Automation/Properties/AssemblyInfo.cs b/PlexRequests.Automation/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..cfc4aa9e4 --- /dev/null +++ b/PlexRequests.Automation/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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. +[assembly: AssemblyTitle("PlexRequests.Automation")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PlexRequests.Automation")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 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 +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("40dc5c6c-2860-44d0-9f91-deb84c22d103")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PlexRequests.Automation/UserLoginTests.cs b/PlexRequests.Automation/UserLoginTests.cs new file mode 100644 index 000000000..17b97b7be --- /dev/null +++ b/PlexRequests.Automation/UserLoginTests.cs @@ -0,0 +1,44 @@ +using NUnit.Framework; + +using PlexRequestes.Automation.Helpers; + +using PlexRequests.Automation.Pages; + +namespace PlexRequests.Automation +{ + [TestFixture] + public class UserLoginTests : AutomationTestBase + { + + public UserLoginTests() : base("http://localhost:8080") + { + } + + [Test] + [Ignore("Cannot work with CI Build currently")] + public void LoginWithoutAuthentication() + { + using (Driver) + { + var userLogin = new UserLoginPage(Driver); + var search = userLogin.Login("AutomationUser"); + + Assert.That(search.PageTitle.Exists()); + } + } + + [Test] + [Ignore("Cannot work with CI Build currently")] + public void SearchAndRequestMovie() + { + using (Driver) + { + var userLogin = new UserLoginPage(Driver); + var search = userLogin.Login("AutomationUser"); + + search.SearchForMovie("007"); + } + } + } +} + \ No newline at end of file diff --git a/PlexRequests.Automation/WebDriverSetup.cs b/PlexRequests.Automation/WebDriverSetup.cs new file mode 100644 index 000000000..c7f90c325 --- /dev/null +++ b/PlexRequests.Automation/WebDriverSetup.cs @@ -0,0 +1,53 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: WebDriverSetup.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +using System; + +using OpenQA.Selenium; +using OpenQA.Selenium.Firefox; + +namespace PlexRequests.Automation +{ + + public static class WebDriverSetup + { + private static IWebDriver _webDriver; + + public static IWebDriver SetUp(string url) + { + var driverService = FirefoxDriverService.CreateDefaultService("C:\\Tools\\WebDriver"); + driverService.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"; + driverService.HideCommandPromptWindow = true; + driverService.SuppressInitialDiagnosticInformation = true; + _webDriver = new FirefoxDriver(driverService, new FirefoxOptions(), TimeSpan.FromSeconds(60)); + _webDriver.Navigate().GoToUrl(url); + _webDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMinutes(1)); + _webDriver.Manage().Window.Maximize(); + return _webDriver; + } + } + +} \ No newline at end of file diff --git a/PlexRequests.Automation/packages.config b/PlexRequests.Automation/packages.config new file mode 100644 index 000000000..a8952a9ef --- /dev/null +++ b/PlexRequests.Automation/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PlexRequests.Core/SettingsServiceV2.cs b/PlexRequests.Core/SettingsServiceV2.cs index 0e702873b..3f422c70c 100644 --- a/PlexRequests.Core/SettingsServiceV2.cs +++ b/PlexRequests.Core/SettingsServiceV2.cs @@ -1,162 +1,162 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SettingsServiceV2.cs -// Created By: Jamie Rees -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// ************************************************************************/ -#endregion - -using System.Threading.Tasks; -using Newtonsoft.Json; - -using PlexRequests.Core.SettingModels; -using PlexRequests.Helpers; -using PlexRequests.Store; -using PlexRequests.Store.Models; -using PlexRequests.Store.Repository; - -namespace PlexRequests.Core -{ - public class SettingsServiceV2 : ISettingsService - where T : Settings, new() - { - - public SettingsServiceV2(ISettingsRepository repo) - { - Repo = repo; - EntityName = typeof(T).Name; - } - - private ISettingsRepository Repo { get; set; } - private string EntityName { get; set; } - - public T GetSettings() - { - var result = Repo.Get(EntityName); - if (result == null) - { - return new T(); - } - result.Content = DecryptSettings(result); - var obj = string.IsNullOrEmpty(result.Content) ? null : JsonConvert.DeserializeObject(result.Content, SerializerSettings.Settings); - - var model = obj; - - return model; - } - - public async Task GetSettingsAsync() - { - var result = await Repo.GetAsync(EntityName); - if (result == null) - { - return new T(); - } - result.Content = DecryptSettings(result); - return string.IsNullOrEmpty(result.Content) ? null : JsonConvert.DeserializeObject(result.Content, SerializerSettings.Settings); - } - - public bool SaveSettings(T model) - { - var entity = Repo.Get(EntityName); - - if (entity == null) - { - var newEntity = model; - - var settings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(newEntity, SerializerSettings.Settings) }; - settings.Content = EncryptSettings(settings); - var insertResult = Repo.Insert(settings); - - return insertResult != long.MinValue; - } - - - var modified = model; - modified.Id = entity.Id; - - var globalSettings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings), Id = entity.Id }; - globalSettings.Content = EncryptSettings(globalSettings); - var result = Repo.Update(globalSettings); - - return result; - } - - public async Task SaveSettingsAsync(T model) - { - var entity = await Repo.GetAsync(EntityName); - - if (entity == null) - { - var newEntity = model; - - var settings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(newEntity, SerializerSettings.Settings) }; - settings.Content = EncryptSettings(settings); - var insertResult = await Repo.InsertAsync(settings); - - return insertResult != int.MinValue; - } - - var modified = model; - modified.Id = entity.Id; - - var globalSettings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings), Id = entity.Id }; - globalSettings.Content = EncryptSettings(globalSettings); - var result = await Repo.UpdateAsync(globalSettings); - - return result; - } - - public bool Delete(T model) - { - var entity = Repo.Get(EntityName); - if (entity != null) - { - return Repo.Delete(entity); - } - - // Entity does not exist so nothing to delete - return true; - } - - public async Task DeleteAsync(T model) - { - var entity = Repo.Get(EntityName); - if (entity != null) - { - return await Repo.DeleteAsync(entity); - } - - return true; - } - - private string EncryptSettings(GlobalSettings settings) - { - return StringCipher.Encrypt(settings.Content, settings.SettingsName); - } - - private string DecryptSettings(GlobalSettings settings) - { - return StringCipher.Decrypt(settings.Content, settings.SettingsName); - } - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SettingsServiceV2.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion + +using System.Threading.Tasks; +using Newtonsoft.Json; + +using PlexRequests.Core.SettingModels; +using PlexRequests.Helpers; +using PlexRequests.Store; +using PlexRequests.Store.Models; +using PlexRequests.Store.Repository; + +namespace PlexRequests.Core +{ + public class SettingsServiceV2 : ISettingsService + where T : Settings, new() + { + + public SettingsServiceV2(ISettingsRepository repo) + { + Repo = repo; + EntityName = typeof(T).Name; + } + + private ISettingsRepository Repo { get; set; } + private string EntityName { get; set; } + + public T GetSettings() + { + var result = Repo.Get(EntityName); + if (result == null) + { + return new T(); + } + result.Content = DecryptSettings(result); + var obj = string.IsNullOrEmpty(result.Content) ? null : JsonConvert.DeserializeObject(result.Content, SerializerSettings.Settings); + + var model = obj; + + return model; + } + + public async Task GetSettingsAsync() + { + var result = await Repo.GetAsync(EntityName); + if (result == null) + { + return new T(); + } + result.Content = DecryptSettings(result); + return string.IsNullOrEmpty(result.Content) ? null : JsonConvert.DeserializeObject(result.Content, SerializerSettings.Settings); + } + + public bool SaveSettings(T model) + { + var entity = Repo.Get(EntityName); + + if (entity == null) + { + var newEntity = model; + + var settings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(newEntity, SerializerSettings.Settings) }; + settings.Content = EncryptSettings(settings); + var insertResult = Repo.Insert(settings); + + return insertResult != long.MinValue; + } + + + var modified = model; + modified.Id = entity.Id; + + var globalSettings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings), Id = entity.Id }; + globalSettings.Content = EncryptSettings(globalSettings); + var result = Repo.Update(globalSettings); + + return result; + } + + public async Task SaveSettingsAsync(T model) + { + var entity = await Repo.GetAsync(EntityName); + + if (entity == null) + { + var newEntity = model; + + var settings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(newEntity, SerializerSettings.Settings) }; + settings.Content = EncryptSettings(settings); + var insertResult = await Repo.InsertAsync(settings); + + return insertResult != int.MinValue; + } + + var modified = model; + modified.Id = entity.Id; + + var globalSettings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings), Id = entity.Id }; + globalSettings.Content = EncryptSettings(globalSettings); + var result = await Repo.UpdateAsync(globalSettings); + + return result; + } + + public bool Delete(T model) + { + var entity = Repo.Get(EntityName); + if (entity != null) + { + return Repo.Delete(entity); + } + + // Entity does not exist so nothing to delete + return true; + } + + public async Task DeleteAsync(T model) + { + var entity = Repo.Get(EntityName); + if (entity != null) + { + return await Repo.DeleteAsync(entity); + } + + return true; + } + + private string EncryptSettings(GlobalSettings settings) + { + return StringCipher.Encrypt(settings.Content, settings.SettingsName); + } + + private string DecryptSettings(GlobalSettings settings) + { + return StringCipher.Decrypt(settings.Content, settings.SettingsName); + } + } +} diff --git a/PlexRequests.UI/Views/Search/Index.cshtml b/PlexRequests.UI/Views/Search/Index.cshtml index a37b099ae..d81fa8a5e 100644 --- a/PlexRequests.UI/Views/Search/Index.cshtml +++ b/PlexRequests.UI/Views/Search/Index.cshtml @@ -9,7 +9,7 @@ } }
-

@UI.Search_Title

+

@UI.Search_Title

@UI.Search_Paragraph


@@ -19,14 +19,14 @@ @if (Model.SearchForMovies) { } @if (Model.SearchForTvShows) {
  • - @UI.Search_TvShows + @UI.Search_TvShows
  • } diff --git a/PlexRequests.UI/Views/UserLogin/Index.cshtml b/PlexRequests.UI/Views/UserLogin/Index.cshtml index 0c04b8f7b..ad8bf59fc 100644 --- a/PlexRequests.UI/Views/UserLogin/Index.cshtml +++ b/PlexRequests.UI/Views/UserLogin/Index.cshtml @@ -13,7 +13,7 @@
    - +

    @@ -24,7 +24,7 @@
    - +

    diff --git a/PlexRequests.sln b/PlexRequests.sln index 3aa64d8b8..f806ea2f7 100644 --- a/PlexRequests.sln +++ b/PlexRequests.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.UI", "PlexRequests.UI\PlexRequests.UI.csproj", "{68F5F5F3-B8BB-4911-875F-6F00AAE04EA6}" EndProject @@ -37,6 +37,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Updater", "Ple EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Helpers.Tests", "PlexRequests.Helpers.Tests\PlexRequests.Helpers.Tests.csproj", "{0E6395D3-B074-49E8-898D-0EB99E507E0E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Automation", "PlexRequests.Automation\PlexRequests.Automation.csproj", "{40DC5C6C-2860-44D0-9F91-DEB84C22D103}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Automation", "Automation", "{F9F1B821-AF59-447A-993B-2B328F7274D4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Automation.Pages", "PlexRequests.Automation.Pages\PlexRequests.Automation.Pages.csproj", "{F8D4A7A7-F0FB-4D04-81DB-637C953E0707}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequestes.Automation.Helpers", "PlexRequestes.Automation.Helpers\PlexRequestes.Automation.Helpers.csproj", "{DC8BACEF-C284-4A8F-A9AA-7F49EFABA288}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -70,11 +78,9 @@ Global {A930E2CF-79E2-45F9-B06A-9A719A254CE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A930E2CF-79E2-45F9-B06A-9A719A254CE4}.Debug|Any CPU.Build.0 = Debug|Any CPU {A930E2CF-79E2-45F9-B06A-9A719A254CE4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A930E2CF-79E2-45F9-B06A-9A719A254CE4}.Release|Any CPU.Build.0 = Release|Any CPU {FCFECD5D-47F6-454D-8692-E27A921BE655}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FCFECD5D-47F6-454D-8692-E27A921BE655}.Debug|Any CPU.Build.0 = Debug|Any CPU {FCFECD5D-47F6-454D-8692-E27A921BE655}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FCFECD5D-47F6-454D-8692-E27A921BE655}.Release|Any CPU.Build.0 = Release|Any CPU {566EFA49-68F8-4716-9693-A6B3F2624DEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {566EFA49-68F8-4716-9693-A6B3F2624DEA}.Debug|Any CPU.Build.0 = Debug|Any CPU {566EFA49-68F8-4716-9693-A6B3F2624DEA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -86,7 +92,6 @@ Global {EAADB4AC-064F-4D3A-AFF9-64A33131A9A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EAADB4AC-064F-4D3A-AFF9-64A33131A9A7}.Debug|Any CPU.Build.0 = Debug|Any CPU {EAADB4AC-064F-4D3A-AFF9-64A33131A9A7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EAADB4AC-064F-4D3A-AFF9-64A33131A9A7}.Release|Any CPU.Build.0 = Release|Any CPU {EBE6FC1C-7B4B-47E9-AF54-0EE0604A2BE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EBE6FC1C-7B4B-47E9-AF54-0EE0604A2BE5}.Debug|Any CPU.Build.0 = Debug|Any CPU {EBE6FC1C-7B4B-47E9-AF54-0EE0604A2BE5}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -94,11 +99,24 @@ Global {0E6395D3-B074-49E8-898D-0EB99E507E0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0E6395D3-B074-49E8-898D-0EB99E507E0E}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E6395D3-B074-49E8-898D-0EB99E507E0E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0E6395D3-B074-49E8-898D-0EB99E507E0E}.Release|Any CPU.Build.0 = Release|Any CPU + {40DC5C6C-2860-44D0-9F91-DEB84C22D103}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40DC5C6C-2860-44D0-9F91-DEB84C22D103}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40DC5C6C-2860-44D0-9F91-DEB84C22D103}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8D4A7A7-F0FB-4D04-81DB-637C953E0707}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8D4A7A7-F0FB-4D04-81DB-637C953E0707}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8D4A7A7-F0FB-4D04-81DB-637C953E0707}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {40DC5C6C-2860-44D0-9F91-DEB84C22D103} = {F9F1B821-AF59-447A-993B-2B328F7274D4} + {F8D4A7A7-F0FB-4D04-81DB-637C953E0707} = {F9F1B821-AF59-447A-993B-2B328F7274D4} + {DC8BACEF-C284-4A8F-A9AA-7F49EFABA288} = {F9F1B821-AF59-447A-993B-2B328F7274D4} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution RESX_PrefixTranslations = False EndGlobalSection