PageRenderTime 28ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/UnitTests/GitUI.Tests/Theming/ThemePathProviderPortableAppTests.cs

https://github.com/gitextensions/gitextensions
C# | 69 lines | 59 code | 9 blank | 1 comment | 0 complexity | bedd9664b4f32ef6982b0b98386192f2 MD5 | raw file
Possible License(s): GPL-3.0
  1. using System;
  2. using System.IO;
  3. using FluentAssertions;
  4. using GitCommands;
  5. using GitExtUtils.GitUI.Theming;
  6. using GitUI.Theming;
  7. using NUnit.Framework;
  8. namespace GitUITests.Theming
  9. {
  10. public class ThemePathProviderPortableAppTests
  11. {
  12. private string _originalAppExecutablePath;
  13. private Lazy<string> _originalAppDataPath;
  14. // appInstall and AppData paths are same for portable app
  15. private const string MockAppInstallPath = "c:\\portable\\GitExtensions";
  16. private const string MockAppDataPath = "c:\\portable\\GitExtensions";
  17. [OneTimeSetUp]
  18. public void OneTimeSetUp()
  19. {
  20. var testAccessor = AppSettings.GetTestAccessor();
  21. _originalAppExecutablePath = testAccessor.ApplicationExecutablePath;
  22. testAccessor.ApplicationExecutablePath = Path.Combine(MockAppInstallPath, "gitextensions.exe");
  23. _originalAppDataPath = testAccessor.ApplicationDataPath;
  24. testAccessor.ApplicationDataPath = new Lazy<string>(() => MockAppDataPath);
  25. }
  26. [OneTimeTearDown]
  27. public void OneTimeTearDown()
  28. {
  29. var testAccessor = AppSettings.GetTestAccessor();
  30. testAccessor.ApplicationExecutablePath = _originalAppExecutablePath;
  31. testAccessor.ApplicationDataPath = _originalAppDataPath;
  32. }
  33. [Test]
  34. public void AppThemesDirectory_should_be_inside_app_install()
  35. {
  36. new ThemePathProvider().AppThemesDirectory
  37. .Should().Be(Path.Combine(MockAppInstallPath, "Themes"));
  38. }
  39. [Test]
  40. public void UserThemesDirectory_should_be_null()
  41. {
  42. new ThemePathProvider().UserThemesDirectory
  43. .Should().BeNull();
  44. }
  45. [Test]
  46. public void GetThemePath_should_return_path_inside_app_install_When_theme_is_builtin()
  47. {
  48. new ThemePathProvider().GetThemePath(new ThemeId("arbitrary_name", isBuiltin: true))
  49. .Should().Be(Path.Combine(MockAppInstallPath, "Themes", "arbitrary_name.css"));
  50. }
  51. [Test]
  52. public void GetThemePath_should_throw_When_theme_is_not_builtin()
  53. {
  54. new ThemePathProvider().Invoking(_ =>
  55. _.GetThemePath(new ThemeId("arbitrary_name", isBuiltin: false)))
  56. .Should().Throw<InvalidOperationException>()
  57. .Which.Message.ToLower().Should().Contain("portable");
  58. }
  59. }
  60. }