PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/MalApi.Tests/MyAnimeListApiTests.cs

https://bitbucket.org/LHCGreg/mal-api
C# | 54 lines | 36 code | 3 blank | 15 comment | 0 complexity | 96b4b0aed5bd354d9a854f4ba3f9fb6f MD5 | raw file
Possible License(s): Apache-2.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using NUnit.Framework;
  6. using System.Reflection;
  7. using System.IO;
  8. namespace MalApi.Tests
  9. {
  10. [TestFixture]
  11. public class MyAnimeListApiTests
  12. {
  13. [Test]
  14. public void TestScrapeAnimeDetailsFromHtml()
  15. {
  16. string thisAssemblyPath = Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "");
  17. Console.WriteLine(thisAssemblyPath);
  18. string htmlFilePath = Path.Combine(Path.GetDirectoryName(thisAssemblyPath), "Eureka_Seven.htm");
  19. string html = File.ReadAllText(htmlFilePath);
  20. using (MyAnimeListApi api = new MyAnimeListApi())
  21. {
  22. AnimeDetailsResults results = api.ScrapeAnimeDetailsFromHtml(html, 237);
  23. List<Genre> expectedGenres = new List<Genre>()
  24. {
  25. new Genre(2, "Adventure"),
  26. new Genre(8, "Drama"),
  27. new Genre(18, "Mecha"),
  28. new Genre(22, "Romance"),
  29. new Genre(24, "Sci-Fi"),
  30. new Genre(27, "Shounen")
  31. };
  32. Assert.That(results.Genres, Is.EquivalentTo(expectedGenres));
  33. }
  34. }
  35. }
  36. }
  37. /*
  38. Copyright 2012 Greg Najda
  39. Licensed under the Apache License, Version 2.0 (the "License");
  40. you may not use this file except in compliance with the License.
  41. You may obtain a copy of the License at
  42. http://www.apache.org/licenses/LICENSE-2.0
  43. Unless required by applicable law or agreed to in writing, software
  44. distributed under the License is distributed on an "AS IS" BASIS,
  45. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  46. See the License for the specific language governing permissions and
  47. limitations under the License.
  48. */