PSDTextTests.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.IO;
  3. using Xunit;
  4. namespace PSDTextTests
  5. {
  6. public class PSDTextTests
  7. {
  8. private const string TestFile = "./testFiles/test.psd";
  9. private const string NoTextPSD = "./testFiles/noText.psd";
  10. [Fact]
  11. public void ReadXMLFromPSD()
  12. {
  13. var test = new PSDText.PSDText(TestFile);
  14. Assert.NotEmpty(test.ExtractedStrings);
  15. }
  16. [Fact]
  17. public void SaveAsXML()
  18. {
  19. var test = new PSDText.PSDText(TestFile);
  20. var destination = "./test.xml";
  21. test.SaveAsXML(destination);
  22. Assert.True(File.Exists(destination));
  23. File.Delete(destination);
  24. }
  25. [Fact]
  26. public void SaveAsXMLWrongPath()
  27. {
  28. var test = new PSDText.PSDText(TestFile);
  29. Assert.Throws<ArgumentNullException>(() => test.SaveAsXML(null));
  30. }
  31. [Fact]
  32. public void NoText()
  33. {
  34. Assert.Throws<Exception>(() => new PSDText.PSDText(NoTextPSD));
  35. }
  36. [Fact]
  37. public void SaveAsJSON()
  38. {
  39. var test = new PSDText.PSDText(TestFile);
  40. var destination = "./test.json";
  41. test.SaveAsJSON(destination);
  42. Assert.True(File.Exists(destination));
  43. File.Delete(destination);
  44. }
  45. [Fact]
  46. public void SaveAsJSONWrongPath()
  47. {
  48. var test = new PSDText.PSDText(TestFile);
  49. Assert.Throws<ArgumentNullException>(() => test.SaveAsJSON(null));
  50. }
  51. }
  52. }