public void UpdateAsync_ThrowsValidationException()
        {
            StudentRepoMock.Setup(repo => repo.GetAsync(It.IsAny <int>()))
            .Returns(GetExceptionTest());

            Assert.ThrowsAsync <ValidationException>(async() => await StudentHomeworkUpdater
                                                     .UpdateAsync(_homework, StudentHomeworkUpdater.UpdateType.AddHomework));
        }
        public async Task UpdateAsync_ThreeMessagesWillBeSent_ValidCall()
        {
            await StudentHomeworkUpdater.UpdateAsync(_homework, StudentHomeworkUpdater.UpdateType.AddHomework);

            StudentRepoMock.Verify(m => m.GetAsync(It.IsAny <int>()));
            StudentRepoMock.Verify(m => m.Update(It.IsAny <Student>()));
            MessageServiceAccessorMock.Verify(m => m.Invoke(It.IsAny <string>())
                                              .Send(It.IsAny <Student>(), new NullLoggerFactory().CreateLogger("")), Times.Exactly(3));
        }
        public async Task UpdateAsync_NoMessagesWillBeSent_ValidCall()
        {
            StudentRepoMock.Setup(repo => repo.GetAsync(It.IsAny <int>()))
            .Returns(GetStudentWithoutSendingMessages());
            await StudentHomeworkUpdater.UpdateAsync(_homework, StudentHomeworkUpdater.UpdateType.AddHomework);

            StudentRepoMock.Verify(m => m.GetAsync(It.IsAny <int>()));
            StudentRepoMock.Verify(m => m.Update(It.IsAny <Student>()));
            MessageServiceAccessorMock.Verify(m => m.Invoke(It.IsAny <string>())
                                              .Send(It.IsAny <Student>(), new NullLoggerFactory().CreateLogger("")), Times.Exactly(0));
        }
        public void SetUp()
        {
            MessageServiceAccessorMock = new Mock <Func <string, IMessageSender> >();
            MessageSender = new Mock <IMessageSender>();
            MessageServiceAccessorMock.Setup(_ => _.Invoke(It.IsAny <string>()))
            .Returns(MessageSender.Object);

            StudentRepoMock = new Mock <IRepository <Student> >();
            StudentRepoMock.Setup(repo => repo.GetAsync(It.IsAny <int>()))
            .Returns(GetStudentWithSendingMessages());

            StudentHomeworkUpdater = new StudentHomeworkUpdater(StudentRepoMock.Object,
                                                                MessageServiceAccessorMock.Object,
                                                                new NullLoggerFactory());
        }