PageRenderTime 26ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/UnitTests/GitUI.Tests/Theming/ThemeFileReaderTests.cs

https://github.com/gitextensions/gitextensions
C# | 41 lines | 36 code | 5 blank | 0 comment | 0 complexity | 6a2ca99dfecc300e744276bf1d165e7a MD5 | raw file
Possible License(s): GPL-3.0
  1. using System.IO;
  2. using FluentAssertions;
  3. using GitUI.Theming;
  4. using NUnit.Framework;
  5. namespace GitUITests.Theming
  6. {
  7. [TestFixture]
  8. public class ThemeFileReaderTests
  9. {
  10. [Test]
  11. public void Should_return_file_text()
  12. {
  13. const string mockThemeContent = "test content";
  14. ThemeFileReader reader = new();
  15. var tempPath = Path.GetTempFileName();
  16. try
  17. {
  18. File.WriteAllText(tempPath, mockThemeContent);
  19. reader.ReadThemeFile(tempPath).Should().Be(mockThemeContent);
  20. }
  21. finally
  22. {
  23. File.Delete(tempPath);
  24. }
  25. }
  26. [Test]
  27. public void Should_throw_ThemeException_if_file_does_not_exist()
  28. {
  29. string nonExistingFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "non_existing_theme.css");
  30. ThemeFileReader reader = new();
  31. reader.Invoking(_ => _.ReadThemeFile(nonExistingFile))
  32. .Should().Throw<ThemeException>()
  33. .Which.InnerException.Should().BeOfType<FileNotFoundException>();
  34. }
  35. }
  36. }