This repository has been archived by the owner on Mar 8, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define the Hudson.Data.View class and start deserializing it off of t…
…he Root API call
- Loading branch information
R. Tyler Ballance
committed
Sep 6, 2009
1 parent
a14949e
commit 967ac4e
Showing
4 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Web.Script.Serialization; | ||
|
||
namespace Hudson.Data | ||
{ | ||
[Serializable] | ||
public class View | ||
{ | ||
#region "Member Variables" | ||
protected string description = null; | ||
protected List<Project> jobs = null; | ||
protected string name = null; | ||
protected string url = null; | ||
#endregion | ||
|
||
#region "Public Properties" | ||
public string Description | ||
{ | ||
get { return this.description; } | ||
set { this.description = value; } | ||
} | ||
|
||
public List<Project> Jobs | ||
{ | ||
get { return this.jobs; } | ||
set { this.jobs = value; } | ||
} | ||
|
||
public string Name | ||
{ | ||
get { return this.name; } | ||
set { this.name = value; } | ||
} | ||
|
||
public string Url | ||
{ | ||
get { return this.url; } | ||
set { this.url = value; } | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Web.Script.Serialization; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Web.Script.Serialization; | ||
|
||
using NUnit.Framework; | ||
|
||
using Hudson.Data; | ||
|
||
namespace Hudson.Tests.ViewTests | ||
{ | ||
[TestFixture] | ||
public class ViewTest : Hudson.Tests.TestBase | ||
{ | ||
protected readonly string sampleRootData = "{\"name\":\"All\",\"url\":\"http://localhost:8080/\"}"; | ||
protected readonly string sampleViewDetailData = "{\"description\":\"This is a secondary view\",\"jobs\":[{\"name\":\"Downstream\",\"url\":\"http://localhost:8080/job/Downstream/\",\"color\":\"blue\"},{\"name\":\"Sleeper\",\"url\":\"http://localhost:8080/job/Sleeper/\",\"color\":\"blue\"}],\"name\":\"TestView\",\"url\":\"http://localhost:8080/view/TestView/\"}"; | ||
|
||
[Test] | ||
public void BasicSimpleDeserialization() | ||
{ | ||
View view = this.json.Deserialize<View>(this.sampleRootData); | ||
Assert.IsNotNull(view, "Deserialized View object is null"); | ||
} | ||
|
||
[Test] | ||
public void BasicDetailedDeserialization() | ||
{ | ||
View view = this.json.Deserialize<View>(this.sampleViewDetailData); | ||
Assert.IsNotNull(view, "Deserialized (detailed) View object is null"); | ||
} | ||
|
||
[Test] | ||
public void VerifySimpleMembers() | ||
{ | ||
View view = this.json.Deserialize<View>(this.sampleRootData); | ||
|
||
Assert.AreEqual("All", view.Name, "Simple View.Name should be \"All\""); | ||
Assert.AreEqual("http://localhost:8080/", view.Url, "Simple View.Url is wrong"); | ||
|
||
Assert.IsNull(view.Description, "View.Description should be null for simple data"); | ||
} | ||
|
||
[Test] | ||
public void VerifyDetailedMembers() | ||
{ | ||
View view = this.json.Deserialize<View>(this.sampleViewDetailData); | ||
|
||
Assert.AreEqual("TestView", view.Name); | ||
Assert.AreEqual("This is a secondary view", view.Description); | ||
Assert.AreEqual(2, view.Jobs.Count); | ||
Assert.AreEqual("http://localhost:8080/view/TestView/", view.Url); | ||
} | ||
} | ||
} |