PSDTextTests.cs 1.2 KB

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