public void AddUpdateDeleteUser() { userRepository = new MessagingRepository <User>(dbSettings); user = new User { Id = 1, Login = "******" }; userRepository.Add(user); userRepository.Save(); var userFromDb = userRepository.GetItem(1); Assert.IsNotNull(userFromDb); Assert.AreEqual(userFromDb.Id, 1); Assert.AreEqual(userFromDb.Login, "NK"); user.Login = "******"; userRepository.Update(user); userRepository.Save(); userFromDb = userRepository.GetItem(1); Assert.IsNotNull(userFromDb); Assert.AreEqual(userFromDb.Id, 1); Assert.AreEqual(userFromDb.Login, "neNK"); userRepository.DeleteItem(1); userRepository.Save(); userFromDb = userRepository.GetItem(1); Assert.IsNull(userFromDb); userRepository.Dispose(); }
public void AddUpdateDeleteMessage() { messageRepository = new MessagingRepository <Message>(dbSettings); message = new Message { Id = 1, UserId = 1, Text = "NK" }; messageRepository.Add(message); messageRepository.Save(); var messageFromDb = messageRepository.GetItem(1); Assert.IsNotNull(messageFromDb); Assert.AreEqual(messageFromDb.Id, 1); Assert.AreEqual(messageFromDb.UserId, 1); Assert.AreEqual(messageFromDb.Text, "NK"); message.Text = "neNK"; messageRepository.Update(message); messageRepository.Save(); messageFromDb = messageRepository.GetItem(1); Assert.IsNotNull(messageFromDb); Assert.AreEqual(messageFromDb.Id, 1); Assert.AreEqual(messageFromDb.UserId, 1); Assert.AreEqual(messageFromDb.Text, "neNK"); messageRepository.DeleteItem(1); messageRepository.Save(); messageFromDb = messageRepository.GetItem(1); Assert.IsNull(messageFromDb); messageRepository.Dispose(); }