Example #1
0
        public void TestSendMessage()
        {
            var mock   = new Mock <IStorage>();
            var server = new MessengerServerService(mock.Object);

            mock.Setup(m => m.SendMessage("Andrew", "Vladimir", "Hi"));
            mock.Setup(m => m.CheckStatus("Vladimir")).Returns(false);
            server.SendMessage("Andrew", "Vladimir", "Hi");
            mock.Verify(m => m.SendMessage("Andrew", "Vladimir", "Hi"), Times.Once);
        }
Example #2
0
 public void TestSendMessageEx()
 {
     try
     {
         var mock   = new Mock <IStorage>();
         var server = new MessengerServerService(mock.Object);
         mock.Setup(m => m.SendMessage("Andrew", "Vladimir", "Hi"));
         mock.Setup(m => m.CheckStatus("Vladimir")).Returns(true);
         server.SendMessage("Andrew", "Vladimir", "Hi");
     }
     catch (Exception exeption)
     {
         Assert.That("Данный ключ отсутствует в словаре.", Is.EqualTo(exeption.Message));
     }
 }