public void Get() { var actual = discussionResultService.Get(1); var expected = DtoConverters.GetDiscussionResultDto(discussionResults.TestDiscussionResult1); Assert.AreEqual(expected, actual); }
public void GetById() { var actual = cardService.Get(1); var expected = DtoConverters.GetCardDto(cards.CardOne); Assert.AreEqual(expected, actual); }
public void Get() { var expected = DtoConverters.GetDeckDto(decks.PrivateDeck); var actual = deckService.Get(2); Assert.AreEqual(expected, actual); }
public void Get() { var expected = DtoConverters.GetRoomDto(rooms.TestRoom1); var actual = roomService.Get(1, TestOwner); Assert.AreEqual(expected, actual); }
/// <summary> /// Находит результаты обсуждений по имени пользователя. /// </summary> /// <param name="owner">Имя пользователя.</param> /// <returns>Коллекцию ДТО результатов.</returns> public IEnumerable <DiscussionResultDto> GetByName(string owner) { var discussionResults = this.resultRepository.GetAll() .Where(dr => dr.UsersCards.Where(uc => uc.User.Name == owner).ToArray().Length > 0); return(DtoConverters.GetDiscussionResultsDtos(discussionResults)); }
public void GetAvailableWithPrivate() { var expected = DtoConverters.GetDecksDtos(new List <Deck> { decks.BaseDeck, decks.PrivateDeck }); var actual = deckService.GetAvailable(TestOwner); Assert.AreEqual(expected, actual); }
public void GetAvailableOnlyCommon() { var expected = DtoConverters.GetDecksDtos(new List <Deck> { decks.BaseDeck }); var actual = deckService.GetAvailable(null); Assert.AreEqual(expected, actual); }
public void GetByName() { var expected = DtoConverters.GetDiscussionResultsDtos(new List <DiscussionResult> { discussionResults.TestDiscussionResult1, discussionResults.TestDiscussionResult2 }); var actual = discussionResultService.GetByName(TestOwner); Assert.AreEqual(expected, actual); }
public void GetAvailableWithPrivate() { var actual = cardService.GetAvailable(TestOwner); var expected = DtoConverters.GetCardsDtos(new List <Card> { cards.CardOne, cards.CardFive, cards.CardSeven, cards.CardCoffee, cards.CardEight, cards.CardTen }); Assert.AreEqual(expected, actual); }
public void GetAll() { var expected = DtoConverters.GetUsersDtos(new List <User> { users.JohnUser, users.ValeraUser, users.BorkaUser }); var actual = userService.GetAll(); Assert.AreEqual(expected, actual); }
public void GetAll() { var expected = DtoConverters.GetRoomsDtos(new List <Room> { rooms.TestRoom1 }); var actual = roomService.GetAll(); Assert.AreEqual(expected, actual); }
public void GetAvailableOnlyCommon() { var actual = cardService.GetAvailable(null); var expected = DtoConverters.GetCardsDtos(new List <Card> { cards.CardOne, cards.CardFive, cards.CardSeven, cards.CardCoffee }); Assert.AreEqual(expected, actual); }
/// <summary> /// Находит доступные колоды. /// </summary> /// <param name="owner">Владелец колод.</param> /// <returns>Коллекцию ДТО колод.</returns> public IEnumerable <DeckDto> GetAvailable(string owner) { var decks = this.deckRepo.GetAll().Where(d => d.Owner == null).ToList(); if (owner != null) { decks.AddRange(this.deckRepo.GetAll().Where(d => d.Owner == owner)); } return(DtoConverters.GetDecksDtos(decks)); }
/// <summary> /// Доступные карты. /// </summary> /// <param name="owner">Имя владельца.</param> /// <returns>Коллекцию ДТО карт.</returns> public IEnumerable <CardDto> GetAvailable(string owner) { List <Card> cards = this.repository.GetAll().Where(c => c.Owner == null).ToList(); if (owner != null) { cards.AddRange(this.repository.GetAll().Where(c => c.Owner == owner).ToList()); } return(DtoConverters.GetCardsDtos(cards)); }
public void Save() { cardService.Save(cards.CardTwo, TestOwner); var expected = DtoConverters.GetCardDto(cards.CardTwo); var actual = cardService.Get(7); var expectedMethod = "UpdateCards"; var actualMethod = InvokedSignalRMethod; Assert.AreEqual(expectedMethod, actualMethod); Assert.AreEqual(expected, actual); }
/// <summary> /// Показывает комнату, если пользователь вошел в нее. /// </summary> /// <param name="id">ИД комнаты.</param> /// <param name="loggedUser">Залогиненный пользователь.</param> /// <returns>ДТО комнаты.</returns> public RoomDto Get(long id, string loggedUser) { var room = this.roomRepository.Get(id); if (room.Users.Select(u => u.Name).Contains(loggedUser)) { //this.AddConnectionIdToGroup(loggedUser, room.Id).Wait(); //this.SendUpdateRoomToClients(room, "UpdateUsersInRoom").Wait(); return(DtoConverters.GetRoomDto(room)); } throw new AccessViolationException("Сначала нужно войти в комнату"); }
public void Create() { roomService.Create(TestOwner, "pass", "RoomToInsert", "10", "1"); var expectedMethod = "UpdateRooms"; var actualMethod = InvokedSignalRMethod; Assert.AreEqual(expectedMethod, actualMethod); var expected = DtoConverters.GetRoomDto(rooms.RoomToInsert); var actual = roomService.Get(2, TestOwner); Assert.AreEqual(expected, actual); }
/// <summary> /// Добавляет пользователя в комнату и показывает комнату. /// </summary> /// <param name="id">ИД комнаты.</param> /// <param name="loggedUser">Имя пользователя.</param> /// <param name="password">Пароль к комнате.</param> /// <returns>ДТО комнаты.</returns> public RoomDto AddUserToRoomAndGet(long id, string loggedUser, string password) { var room = this.roomRepository.Get(id); var user = this.GetUserByName(loggedUser); if (room.Password == password) { if (!room.Users.Contains(user)) { this.AddUserToRoom(user, room); this.SendUpdateRoomToClients(room, "UpdateUsersInRoom").Wait(); } //this.AddConnectionIdToGroup(loggedUser, room.Id).Wait(); return(DtoConverters.GetRoomDto(this.roomRepository.Get(room.Id))); } throw new AccessViolationException("Неверный пароль к комнате"); }
/// <summary> /// Находит колоду по ИД. /// </summary> /// <param name="id">ИД колоды.</param> /// <returns>ДТО колоды.</returns> public DeckDto Get(long id) { return(DtoConverters.GetDeckDto(this.deckRepo.Get(id))); }
/// <summary> /// Выдает список всех пользователей. /// </summary> /// <returns>Коллекцию ДТО пользователей.</returns> public IEnumerable <UserDto> GetAll() { return(DtoConverters.GetUsersDtos(this.repository.GetAll())); }
/// <summary> /// Показывает все комнаты. /// </summary> /// <returns>Коллекцию ДТО комнат.</returns> public IEnumerable <RoomDto> GetAll() { return(DtoConverters.GetRoomsDtos(this.roomRepository.GetAll())); }
/// <summary> /// Все результаты обсуждения. /// </summary> /// <returns>Коллекцию ДТО результатов.</returns> public IEnumerable <DiscussionResultDto> GetAll() { return(DtoConverters.GetDiscussionResultsDtos(this.resultRepository.GetAll())); }
/// <summary> /// Ищет результат обсуждения по ИД. /// </summary> /// <param name="id">ИД результата.</param> /// <returns>ДТО результата.</returns> public DiscussionResultDto Get(long id) { return(DtoConverters.GetDiscussionResultDto(this.resultRepository.Get(id))); }
/// <summary> /// Возвращает карту по ИД. /// </summary> /// <param name="id">ИД карты.</param> /// <returns>ДТО карты.</returns> public CardDto Get(long id) { return(DtoConverters.GetCardDto(this.repository.Get(id))); }