PageRenderTime 57ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/Atlassian.Jira.Test/CustomFieldCollectionTest.cs

https://bitbucket.org/yyo/atlassian.net-sdk-v2.0
C# | 47 lines | 41 code | 4 blank | 2 comment | 0 complexity | 204fc0e5baa01c50d7e8b1efd7c18f09 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Xunit;
  6. using Atlassian.Jira.Remote;
  7. using Moq;
  8. namespace Atlassian.Jira.Test
  9. {
  10. public class CustomFieldCollectionTest
  11. {
  12. [Fact]
  13. public void IndexByName_ShouldReturnRemoteValue()
  14. {
  15. //arrange
  16. var jira = TestableJira.Create();
  17. jira.SoapService
  18. .Setup(c => c.GetIssuesFromJqlSearch(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()))
  19. .Returns(new RemoteIssue[]
  20. {
  21. new RemoteIssue() { key = "123" }
  22. });
  23. jira.SoapService.Setup(c => c.GetFieldsForEdit(It.IsAny<string>(), "123")).Returns(new RemoteField[] {
  24. new RemoteField(){ id="123", name= "CustomField" }});
  25. var issue = new RemoteIssue()
  26. {
  27. project = "bar",
  28. key = "foo",
  29. customFieldValues = new RemoteCustomFieldValue[]{
  30. new RemoteCustomFieldValue(){
  31. customfieldId = "123",
  32. values = new string[] {"abc"}
  33. }
  34. }
  35. }.ToLocal(jira);
  36. //assert
  37. Assert.Equal("abc", issue["CustomField"]);
  38. Assert.Equal("123", issue.CustomFields["CustomField"].Id);
  39. issue["customfield"] = "foobar";
  40. Assert.Equal("foobar", issue["customfield"]);
  41. }
  42. }
  43. }