PSDTextTests.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.TextData);
  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 NoText()
  27. {
  28. Assert.Throws<Exception>(() => new PSDText.PSDText(NoTextPSD));
  29. }
  30. [Fact]
  31. public void SaveAsJSON()
  32. {
  33. var test = new PSDText.PSDText(TestFile);
  34. Assert.NotEmpty(test.TextData);
  35. var destination = "./test.json";
  36. Assert.True(test.SaveAsJSON(destination));
  37. Assert.True(File.Exists(destination));
  38. File.Delete(destination);
  39. }
  40. }
  41. }