Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Add new Color Values #58

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
517 changes: 275 additions & 242 deletions TrelloNet.Tests/ActionTests.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions TrelloNet.Tests/App.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ApplicationKey" value="a325eddf477b6e614e5cb84deef472c1"/>
<add key="MemberReadToken" value="a0f05ce01f11b4dceb1127e244bdc9c45705d44f3ec1b349f3f4a4c306e20fcf"/>
<add key="MemberWriteToken" value="83fd8988ae4945f24d3a61c31188f3c1979ebe5da660f2cddb0dfc71c7cc2957"/>
<add key="ApplicationKey" value="f5cc38bc34583d25a38f8230e040f0fc"/>
<add key="MemberReadToken" value="4f1ecd33625aab4a75c3d19622b09dbe03e9944a9ec8c97adec2c1e9eaf585c3"/>
<add key="MemberWriteToken" value="1ef62e020b70dceda641b29c9e0ea65940302701df61428b1a8de355b75b80fb"/>
</appSettings>
</configuration>
111 changes: 61 additions & 50 deletions TrelloNet.Tests/BoardTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TrelloNet.Tests
[TestFixture]
public class BoardTests : TrelloTestBase
{
private readonly IBoardId _welcomeBoardWritable = new BoardId("4f41e4803374646b5c74bd69");
private readonly IBoardId _welcomeBoardWritable = new BoardId(Constants.WelcomeBoardId);

[Test]
public void WithId_TheWelcomeBoard_ReturnsExpectedWelcomeBoard()
Expand Down Expand Up @@ -59,15 +59,15 @@ public void ForMember_Me_ReturnsTheWelcomeBoard()
{
var boards = _trelloReadOnly.Boards.ForMember(new Me());

Assert.That(boards, Has.Some.Matches<Board>(b => b.Name == "Welcome Board"));
Assert.That(boards, Has.Some.Matches<Board>(b => b.Name == Constants.TestBoardName));
}

[Test]
public void ForMe_Always_ReturnsTheWelcomeBoard()
{
var boards = _trelloReadOnly.Boards.ForMe();

Assert.That(boards, Has.Some.Matches<Board>(b => b.Name == "Welcome Board"));
Assert.That(boards, Has.Some.Matches<Board>(b => b.Name == Constants.TestBoardName));
}

[Test]
Expand All @@ -86,8 +86,9 @@ public void ForMember_MeAndClosed_ReturnsTheClosedBoard()
{
var boards = _trelloReadOnly.Boards.ForMember(new Me(), BoardFilter.Closed);

Assert.That(boards, Has.Count.EqualTo(2));
Assert.That(boards, Has.Some.Matches<Board>(b => b.Name == "A closed board"));
// I have multiple boards and regularly close them...
Assert.That(boards, Has.Count.GreaterThan(2));
Assert.That(boards, Has.Some.Matches<Board>(b => b.Name == "Trello.NET Test Board"));
}

[Test]
Expand Down Expand Up @@ -120,7 +121,7 @@ public void ForChecklist_TheChecklistInTheLastCardOfTheBasicsList_ReturnsTheWelc
{
var expectedBoard = CreateExpectedWelcomeBoard();

var board = _trelloReadOnly.Boards.ForChecklist(new ChecklistId("4f2b8b4d4f2cb9d16d3684c7"));
var board = _trelloReadOnly.Boards.ForChecklist(new ChecklistId(Constants.ChecklistId));

expectedBoard.ShouldMatch(board);
Assert.That(board.LabelNames, Is.EquivalentTo(CreateExpectedWelcomeBoardLabels()));
Expand Down Expand Up @@ -158,17 +159,22 @@ public void ForOrganization_TestOrganization_ReturnsTheWelcomeBoard()

var boards = _trelloReadOnly.Boards.ForOrganization(new OrganizationId(Constants.TestOrganizationId));

Assert.That(boards.Count(), Is.EqualTo(1));
expectedBoard.ShouldMatch(boards.First());
Assert.That(boards.First().LabelNames, Is.EquivalentTo(CreateExpectedWelcomeBoardLabels()));
Assert.That(boards.Count(), Is.EqualTo(3));
foreach(var b in boards) {
if (b.Name.StartsWith("Trello"))
{
expectedBoard.ShouldMatch(b);
Assert.That(b.LabelNames, Is.EquivalentTo(CreateExpectedWelcomeBoardLabels()));
}
}
}

[Test]
public void ForOrganization_TestOrganizationAndClosed_ReturnsNoBoards()
{
var boards = _trelloReadOnly.Boards.ForOrganization(new OrganizationId(Constants.TestOrganizationId), BoardFilter.Closed);

Assert.That(boards.Count(), Is.EqualTo(0));
Assert.That(boards.Count(), Is.EqualTo(1));
}

[Test]
Expand All @@ -185,7 +191,6 @@ public void Scenario_AddAndClose()

Assert.That(newBoard, Is.Not.Null);
Assert.That(newBoard.Name, Is.EqualTo("A new board"));
Assert.That(newBoard.Desc, Is.EqualTo("the description"));

_trelloReadWrite.Boards.Close(newBoard);

Expand Down Expand Up @@ -218,43 +223,28 @@ public void Scenario_ChangeName()

Assert.That(boardwithChangedName.Name, Is.EqualTo("A new name"));

_trelloReadWrite.Boards.ChangeName(_welcomeBoardWritable, "Welcome Board");
}

[Test]
public void Scenario_ChangeDescription()
{
_trelloReadWrite.Boards.ChangeDescription(_welcomeBoardWritable, "A new description");

var boardwithChangedDescription = _trelloReadWrite.Boards.WithId(_welcomeBoardWritable.GetBoardId());

Assert.That(boardwithChangedDescription.Desc, Is.EqualTo("A new description"));

_trelloReadWrite.Boards.ChangeDescription(_welcomeBoardWritable, "");
_trelloReadWrite.Boards.ChangeName(_welcomeBoardWritable, Constants.TestBoardName);
}

[Test]
public void Scenario_UpdateNameDescriptionAndClosed()
{
var board = _trelloReadWrite.Boards.WithId("4f41e4803374646b5c74bd69");
var board = _trelloReadWrite.Boards.WithId(Constants.AClosedBoardId);

board.Name = "Updated name";
board.Desc = "Updated description";
board.Closed = true;
board.Closed = false;

_trelloReadWrite.Boards.Update(board);

var boardAfterUpdate = _trelloReadWrite.Boards.WithId(board.Id);

board.Name = "Welcome Board";
board.Desc = "";
board.Closed = false;
board.Name = Constants.TestBoardName;
board.Closed = true;

_trelloReadWrite.Boards.Update(board);

Assert.That(boardAfterUpdate.Name, Is.EqualTo("Updated name"));
Assert.That(boardAfterUpdate.Desc, Is.EqualTo("Updated description"));
Assert.That(boardAfterUpdate.Closed, Is.EqualTo(true));
Assert.That(boardAfterUpdate.Closed, Is.EqualTo(false));
}

[Test]
Expand All @@ -270,28 +260,28 @@ public void Scenario_ChangePermissionLevel()
[Test]
public void Scenario_AddAndRemoveMember()
{
var member = new MemberId(Constants.MeId);
var member = new MemberId(Constants.DevelopmentId);

_trelloReadWrite.Boards.AddMember(_welcomeBoardWritable, member);
var membersAfterAddMember = _trelloReadWrite.Members.ForBoard(_welcomeBoardWritable);

_trelloReadWrite.Boards.RemoveMember(_welcomeBoardWritable, member);
var membersAfterRemoveMember = _trelloReadWrite.Members.ForBoard(_welcomeBoardWritable);

Assert.That(membersAfterAddMember.Any(x => x.Id.Equals(Constants.MeId)));
Assert.That(!membersAfterRemoveMember.Any(x => x.Id.Equals(Constants.MeId)));
Assert.That(membersAfterAddMember.Any(x => x.Id.Equals(Constants.DevelopmentId)));
Assert.That(!membersAfterRemoveMember.Any(x => x.Id.Equals(Constants.DevelopmentId)));
}

[Test]
public void Scenario_ChangeLabelName()
{
var board = _welcomeBoardWritable;
_trelloReadWrite.Boards.ChangeLabelName(board, Color.Red, "Bug");
_trelloReadWrite.Boards.ChangeLabelName(board, "red", "Bug");

var boardAfterChange = _trelloReadWrite.Boards.WithId(board.GetBoardId());
_trelloReadWrite.Boards.ChangeLabelName(board, Color.Red, null);
_trelloReadWrite.Boards.ChangeLabelName(board, "red", null);

Assert.That(boardAfterChange.LabelNames[Color.Red], Is.EqualTo("Bug"));
Assert.That(boardAfterChange.LabelNames["red"], Is.EqualTo("Bug"));
}

[Test]
Expand Down Expand Up @@ -369,11 +359,11 @@ private static ExpectedObject CreateExpectedWelcomeBoard()
return new
{
Closed = false,
Name = "Welcome Board",
Desc = "A test description",
Name = Constants.TestBoardName,
IdOrganization = Constants.TestOrganizationId,
Pinned = true,
Url = "https://trello.com/b/J9JUdoYV/welcome-board",
Pinned = false,
Starred = true,
Url = "https://trello.com/b/UTWsO3Jc/trello-net-test-board",
Id = Constants.WelcomeBoardId,
Prefs = new BoardPreferences
{
Expand All @@ -385,17 +375,38 @@ private static ExpectedObject CreateExpectedWelcomeBoard()
}.ToExpectedObject();
}

private static Dictionary<Color, string> CreateExpectedWelcomeBoardLabels()
private static Dictionary<String, string> CreateExpectedWelcomeBoardLabels()
{
return new Dictionary<Color, string>
return new Dictionary<String, string>
{
{ Color.Yellow, "" },
{ Color.Red, "" },
{ Color.Purple, "" },
{ Color.Orange, "" },
{ Color.Green, "label name" },
{ Color.Blue, "" },
{ "yellow", "I am yellow" },
{ "red", "Bug" },
{ "purple", "I am purple" },
{ "orange", "I am amber" },
{ "green", "I am green" },
{ "blue", "I am blue" },
{ "sky", "" },
{ "lime", "" },
{ "pink", "" },
{ "black", "" }
};
}

private static Dictionary<String, string> CreateExpectedWelcomeBoardLabelsWithNoNames()
{
return new Dictionary<String, string>
{
{ "yellow", "" },
{ "red", "" },
{ "purple", "" },
{ "orange", "" },
{ "green", "" },
{ "blue", "" },
{ "sky", "" },
{ "lime", "" },
{ "pink", "" },
{ "black", "" }
};
}
}
}
Loading