public void GivenMessageQuackedThenGetMessageThenReturnTheMessage() { var messageQuacked = new MessageQuacked(MessageId.Generate(), new UserId("*****@*****.**"), "Hello"); _eventsStore.Store(messageQuacked); var message = _repository.Get(messageQuacked.Id); var eventsPublisher = new EventPublisherFake(); message.Requack(eventsPublisher, new UserId("*****@*****.**")); Check.That(eventsPublisher.Events.Cast <MessageRequacked>().Single().Id).IsEqualTo(messageQuacked.Id); }
public void Delete() { var repo = new MessagesRepository(fixture.Db); repo.Delete(3); Assert.Throws <MessageNotFoundException>(() => repo.Get(3)); }
[Fact] void Get() { var repo = new MessagesRepository(fixture.Db); var message = repo.Get(1); Assert.Equal(1, message.Id); }
public IActionResult GetById(long id) { Message msg = null; try { msg = _msgRepo.Get(id); } catch (MessageNotFoundException) { return(NotFound()); } return(Ok(msg)); }
public async Task <IHttpActionResult> GetMessageAsync(Guid messageId) { var entity = await _messagesRepository.Get(messageId); var message = new MessageReadModel { Id = entity.Id, Subject = entity.Subject, Content = entity.Content, SentOn = entity.SentOn.ToString("dd.MM.yyyy"), RecipientNames = entity.MessageRecipients.Select(y => y.Recipient.UserName).ToList() }; return(Ok(message)); }
public void ShouldGetMessage() { //arrange var user = new User { Name = "testCharUser", Picture = new byte[] {} }; var login = "******"; var password = "******"; var title = "chatTitle"; var pic = new byte[] {}; string msg = "TestText of msg"; //act var userRepository = new UsersRepository(ConnectionString); var resultUser = userRepository.Create(user, login, password); var userIds = new List <Guid> { resultUser.Id }; _tempUsers.AddRange(userIds); var chatRepository = new ChatsRepository(ConnectionString); var resultChat = chatRepository.Create(title, userIds, pic); _tempChats.Add(resultChat.Id); var messageRepository = new MessagesRepository(ConnectionString); var resultMsg = messageRepository.Send(msg, resultUser.Id, resultChat.Id); var getMsg = messageRepository.Get(resultMsg.Id); _tempMessages.Add(getMsg.Id); //asserts Assert.AreEqual(msg, getMsg.Text); Assert.AreEqual(resultUser.Id, getMsg.Sender.Id); }
public async Task <IEnumerable <MessageDTO> > Get() { var messages = await _repository.Get(); return(_mapper.Map <IEnumerable <MessageDTO> >(messages)); }
// GET: MessagesController/Edit/5 public ActionResult Edit(int id) { var model = messagesRepository.Get(id); return(View(model)); }
[Fact] void GetNonExistant() { var repo = new MessagesRepository(fixture.Db); Assert.Throws <MessageNotFoundException>(() => repo.Get(100)); }