PSDTextTests.cs 1.7 KB

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