NewsTests.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Copyright 2011 - 2022 Adrian Popescu
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. using System.Collections.Specialized;
  14. using Padi.RedmineApi.Tests.Infrastructure;
  15. using Redmine.Net.Api;
  16. using Redmine.Net.Api.Types;
  17. using Xunit;
  18. namespace Padi.RedmineApi.Tests.Tests.Sync
  19. {
  20. [Trait("Redmine-Net-Api", "News")]
  21. #if !(NET20 || NET40)
  22. [Collection("RedmineCollection")]
  23. #endif
  24. public class NewsTests
  25. {
  26. public NewsTests(RedmineFixture fixture)
  27. {
  28. this.fixture = fixture;
  29. }
  30. private readonly RedmineFixture fixture;
  31. [Fact, Order(1)]
  32. public void Should_Get_All_News()
  33. {
  34. const int NUMBER_OF_NEWS = 2;
  35. var news = fixture.RedmineManager.GetObjects<News>();
  36. Assert.NotNull(news);
  37. Assert.True(news.Count == NUMBER_OF_NEWS, "News count(" + news.Count + ") != " + NUMBER_OF_NEWS);
  38. }
  39. [Fact, Order(2)]
  40. public void Should_Get_News_By_Project_Id()
  41. {
  42. const string PROJECT_ID = "redmine-net-testq";
  43. const int NUMBER_OF_NEWS_BY_PROJECT_ID = 1;
  44. var news =
  45. fixture.RedmineManager.GetObjects<News>(new NameValueCollection {{RedmineKeys.PROJECT_ID, PROJECT_ID}});
  46. Assert.NotNull(news);
  47. Assert.True(news.Count == NUMBER_OF_NEWS_BY_PROJECT_ID,
  48. "News count(" + news.Count + ") != " + NUMBER_OF_NEWS_BY_PROJECT_ID);
  49. }
  50. }
  51. }