コード例 #1
0
		public void WillUnAssignUserFromCard()
		{
			Board board = GetSampleBoard();

			board.Lanes[0].Cards[0].AssignedUsers = new List<AssignedUserInfo>
			{new AssignedUserInfo {AssignedUserId = 1, AssignedUserName = "******", GravatarLink = "", SmallGravatarLink = ""}};

			_apiMock.Expect(x => x.GetBoard(1)).Return(board);
			_apiMock.Expect(x => x.CheckForUpdates(1, 0)).Return(new BoardUpdates
			{
				HasUpdates = true,
				AffectedLanes = new List<Lane>
				{
					new Lane
					{
						Id = 1,
						Title = "Lane 1",
						Cards = new List<CardView>
						{
							new CardView
							{
								Id = 1,
								Title = "Card 1",
								LaneId = 1,
								Description = "some desc 1",
								Type =
									new CardType
									{
										Id = 1,
										Name = "Card type 1",
										IconPath = @"C:\"
									}
							},
							new CardView
							{
								Id = 2,
								Title = "Card 2",
								LaneId = 1,
								Description = "some desc 2",
								Type =
									new CardType
									{
										Id = 1,
										Name = "Card type 1",
										IconPath = @"C:\"
									}
							},
						},
					}
				},
				CurrentBoardVersion = 3,
				Events = new List<BoardHistoryEvent>
				{
					new BoardHistoryEvent
					{
						CardId = 1,
						ToLaneId = 1,
						AssignedUserId = 1,
						IsUnassigning = true,
						UserId = 1,
						EventType = "LeanKit.Core.Events.UserAssignmentEvent"
					},
				}
			});

			_integration = new LeanKitIntegration(1, _apiMock);
			_integration.ShouldContinue = false;
			_integration.BoardChanged += ((object sender, BoardChangedEventArgs eventArgs) =>
			{
				Assert.NotNull(eventArgs);
				Assert.AreEqual(1, eventArgs.UnAssignedUsers.Count);
			});

			_integration.StartWatching();
			var affectedBoard = _integration.GetBoard();
			Assert.NotNull(affectedBoard.GetLaneById(1).Cards.First(x => x.Id == 1));
			Assert.IsNull(affectedBoard.GetLaneById(1).Cards.First(x => x.Id == 1).AssignedUsers);
		}
コード例 #2
0
		public void WillOverrideUserWip()
		{
			Board board = GetSampleBoard();

			_apiMock.Expect(x => x.GetBoard(1)).Return(board);
			_apiMock.Expect(x => x.CheckForUpdates(1, 0)).Return(new BoardUpdates
			{
				HasUpdates = true,
				AffectedLanes = new List<Lane>
				{
					new Lane
					{
						Id = 1,
						Title = "Lane 1",
						Cards = new List<CardView>
						{
							new CardView
							{
								Id = 1,
								Title = "Card 1",
								LaneId = 1,
								Comments =
									new List<Comment>
									{
										new Comment
										{
											Id = 1,
											PostDate =
												DateTime.Now.
													ToShortDateString(),
											PostedById = 1,
											Text = "Hello, All"
										}
									},
								Description = "some desc 1",
								Type =
									new CardType
									{
										Id = 1,
										Name = "Card type 1",
										IconPath = @"C:\"
									}
							},
							new CardView
							{
								Id = 2,
								Title = "Card 2",
								LaneId = 1,
								Description = "some desc 2",
								Type =
									new CardType
									{
										Id = 1,
										Name = "Card type 1",
										IconPath = @"C:\"
									}
							},
						},
					}
				},
				CurrentBoardVersion = 3,
				Events = new List<BoardHistoryEvent>
				{
					new BoardHistoryEvent
					{
						CardId = 1,
						WipOverrideUser = 1,
						UserId = 1,
						EventType = "LeanKit.Core.Events.UserWipOverrideEvent"
					},
				}
			});

			_integration = new LeanKitIntegration(1, _apiMock);
			_integration.ShouldContinue = false;
			_integration.BoardChanged += ((object sender, BoardChangedEventArgs eventArgs) =>
			{
				Assert.NotNull(eventArgs);
				Assert.AreEqual(1, eventArgs.UserWipOverrides.Count);
			});

			_integration.StartWatching();
		}
コード例 #3
0
		public void WillMoveCardByEvent()
		{
			_apiMock.Expect(x => x.GetBoard(1)).Return(GetSampleBoard());
			_apiMock.Expect(x => x.CheckForUpdates(1, 0)).Return(new BoardUpdates
			{
				HasUpdates = true,
				AffectedLanes = new List<Lane>
				{
					new Lane
					{
						Id = 1,
						Title = "Lane 1",
						Cards = new List<CardView>
						{
							new CardView
							{
								Id = 2,
								Title = "Card 2",
								LaneId = 2,
								Description = "some desc 2"
							}
						},
					},
					new Lane
					{
						Id = 2,
						Title = "Lane 2",
						Cards = new List<CardView>
						{
							new CardView
							{
								Id = 1,
								Title = "Card 1",
								LaneId = 2,
								Description = "some desc 1"
							},
							new CardView
							{
								Id = 3,
								Title = "Card 3",
								LaneId = 2,
								Description = "some desc 3"
							}
						}
					}
				},
				CurrentBoardVersion = 2,
				Events = new List<BoardHistoryEvent>
				{
					new BoardHistoryEvent
					{
						CardId = 1,
						ToLaneId = 2,
						FromLaneId = 1,
						UserId = 1,
						EventType = "LeanKit.Core.Events.CardMoveEvent"
					}
				}
			});

			_integration = new LeanKitIntegration(1, _apiMock);
			_integration.ShouldContinue = false;
			_integration.BoardChanged += ((object sender, BoardChangedEventArgs eventArgs) =>
			{
				Assert.NotNull(eventArgs);
				Assert.AreEqual(1, eventArgs.MovedCards.Count);
			});

			_integration.StartWatching();
			var affectedBoard = _integration.GetBoard();
			Assert.Null(affectedBoard.GetLaneById(1).Cards.FirstOrDefault(x => x.Id == 1));
			Assert.NotNull(affectedBoard.GetLaneById(2).Cards.First(x => x.Id == 1));
		}
コード例 #4
0
		public void WillCreateCard()
		{
			Board board = GetSampleBoard();
			_apiMock.Expect(x => x.GetBoard(1)).Return(board);
			_apiMock.Expect(x => x.CheckForUpdates(1, 0)).Return(new BoardUpdates
			{
				HasUpdates = true,
				AffectedLanes = new List<Lane>
				{
					new Lane
					{
						Id = 1,
						Title = "Lane 1",
						Cards = new List<CardView>
						{
							new CardView
							{
								Id = 1,
								Title = "Card 1",
								LaneId = 1,
								Description = "some desc 1",
								Type =
									new CardType
									{
										Id = 1,
										Name = "Card type 1",
										IconPath = @"C:\"
									}
							},
							new CardView
							{
								Id = 2,
								Title = "Card 2",
								LaneId = 1,
								Description = "some desc 2",
								Type =
									new CardType
									{
										Id = 1,
										Name = "Card type 1",
										IconPath = @"C:\"
									}
							},
							new CardView
							{
								Id = 4,
								Title = "Card 4",
								LaneId = 1,
								Description = "some desc 4",
								Type =
									new CardType
									{
										Id = 1,
										Name = "Card type 1",
										IconPath = @"C:\"
									}
							}
						},
					}
				},
				CurrentBoardVersion = 3,
				Events = new List<BoardHistoryEvent>
				{
					new BoardHistoryEvent
					{
						CardId = 4,
						ToLaneId = 1,
						UserId = 1,
						EventType = "LeanKit.Core.Events.CardCreationEvent"
					},
				}
			});

			_integration = new LeanKitIntegration(1, _apiMock);
			_integration.ShouldContinue = false;
			_integration.BoardChanged += ((object sender, BoardChangedEventArgs eventArgs) =>
			{
				Assert.NotNull(eventArgs);
				Assert.AreEqual(1, eventArgs.AddedCards.Count);
				Assert.AreEqual(0, eventArgs.MovedCards.Count);
				var affectedBoard = _integration.GetBoard();
				Assert.NotNull(affectedBoard.GetLaneById(1).Cards.First(x => x.Id == 4));
			});
			_integration.StartWatching();
		}
コード例 #5
0
		public void CallWillDeleteCard()
		{
			Board board = GetSampleBoard();
			_apiMock.Expect(x => x.GetBoard(1)).Return(board);
			_apiMock.Expect(x => x.DeleteCard(Arg<long>.Is.Anything, Arg<long>.Is.Anything)).Return(1);

			_integration = new LeanKitIntegration(1, _apiMock);
			_integration.ShouldContinue = false;
			_integration.StartWatching();

			_integration.DeleteCard(1);

			_integration.GetCard(1);
		}
コード例 #6
0
		public void CallWillMoveCard()
		{
			Board board = GetSampleBoard();
			_apiMock.Expect(x => x.GetBoard(1)).Return(board);
			_apiMock.Expect(
				x => x.MoveCard(Arg<long>.Is.Anything, Arg<long>.Is.Anything, Arg<long>.Is.Anything, Arg<int>.Is.Anything))
				.Return(1);

			_integration = new LeanKitIntegration(1, _apiMock);
			_integration.ShouldContinue = false;
			_integration.StartWatching();

			_integration.MoveCard(1, 2, 1);

			Card card = _integration.GetCard(1);
			Assert.NotNull(card);
			Assert.AreEqual(2, card.LaneId);
			Assert.AreEqual(1, board.GetLaneById(2).Cards[0].Id);
			Assert.IsNull(board.GetLaneById(1).Cards.FirstOrDefault(x => x.Id == 1));
		}
コード例 #7
0
		public void CallWillAddCard()
		{
			Board board = GetSampleBoard();
			_apiMock.Expect(x => x.GetBoard(1)).Return(board);
			Card cardToAdd = new Card
			{
				Id = 1,
				Title = "Card 1 Updated",
				LaneId = 1,
				Description = "some desc 1",
				TypeId = 1,
				ExternalCardID = "123"
			};
			Lane affectedLane = new Lane
			{
				Id = 1,
				Title = "Lane 1",
				Cards = new List<CardView>
				{
					new CardView
					{
						Id = 1,
						Title = "Card 1",
						LaneId = 1,
						Description = "some desc 1",
						Type = new CardType {Id = 1, Name = "Card type 1", IconPath = @"C:\"}
					},
					new CardView
					{
						Id = 2,
						Title = "Card 2",
						LaneId = 1,
						Description = "some desc 2",
						Type = new CardType {Id = 1, Name = "Card type 1", IconPath = @"C:\"}
					},
					new CardView
					{
						Id = 4,
						Title = "Card 4",
						LaneId = 1,
						Description = "some desc 4",
						Type = new CardType {Id = 1, Name = "Card type 1", IconPath = @"C:\"}
					},
				},
			};
			CardAddResult result = new CardAddResult {BoardVersion = 1, CardId = 4, Lane = affectedLane};

			_apiMock.Expect(x => x.AddCard(Arg<long>.Is.Anything, Arg<Card>.Is.Anything)).Return(result);

			_integration = new LeanKitIntegration(1, _apiMock);
			_integration.ShouldContinue = false;
			_integration.StartWatching();

			_integration.AddCard(cardToAdd);

			Card card = _integration.GetCard(4);
			Assert.NotNull(card);
			Assert.AreEqual("Card 4", card.Title);
		}
コード例 #8
0
		public void CallWillUpdateCard()
		{
			Board board = GetSampleBoard();
			_apiMock.Expect(x => x.GetBoard(1)).Return(board);
			Card cardToUpdate = new Card
			{
				Id = 1,
				Title = "Card 1 Updated",
				LaneId = 1,
				Description = "some desc 1",
				TypeId = 1,
				ExternalCardID = "123"
			};
			CardUpdateResult result = new CardUpdateResult {BoardVersion = 1, CardDTO = cardToUpdate.ToCardView()};

			_apiMock.Expect(x => x.UpdateCard(Arg<long>.Is.Anything, Arg<Card>.Is.Anything)).Return(result);

			_integration = new LeanKitIntegration(1, _apiMock);
			_integration.ShouldContinue = false;
			_integration.StartWatching();


			_integration.UpdateCard(cardToUpdate);
			Card card = _integration.GetCard(1);
			Assert.NotNull(card);
			Assert.AreEqual("Card 1 Updated", card.Title);
		}
コード例 #9
0
		public void CallWillGetCardByExternalIdWithoutPrefix()
		{
			Board board = GetSampleBoard();
			_apiMock.Expect(x => x.GetBoard(1)).Return(board);
			_integration = new LeanKitIntegration(1, _apiMock);
			_integration.ShouldContinue = false;
			_integration.StartWatching();
			Card card = _integration.GetCardByExternalId(1, "123");
			Assert.NotNull(card);
			Assert.AreEqual("Card 1", card.Title);
		}