コード例 #1
0
        public void SendMessageOk()
        {
            var candidateId = Guid.NewGuid();

            var candidateServiceProvider = new CandidateServiceProvider(_candidateServiceMock.Object, null, null, null, _mapperMock.Object, null, null);

            _mapperMock.Setup(m => m.Map <ContactMessageViewModel, ContactMessage>(It.IsAny <ContactMessageViewModel>()))
            .Returns(new ContactMessage());

            var result = candidateServiceProvider.SendContactMessage(candidateId, new ContactMessageViewModel());

            result.Should().BeTrue();
            _candidateServiceMock.Verify(cs => cs.SubmitContactMessage(It.Is <ContactMessage>(cm => cm.UserId == candidateId)));
        }
コード例 #2
0
        public void SendMessageFail()
        {
            var candidateId = Guid.NewGuid();

            var candidateServiceProvider = new CandidateServiceProvider(_candidateServiceMock.Object, null, null, null, _mapperMock.Object, null, null);

            _mapperMock.Setup(m => m.Map <ContactMessageViewModel, ContactMessage>(It.IsAny <ContactMessageViewModel>()))
            .Returns(new ContactMessage());

            _candidateServiceMock.Setup(cs => cs.SubmitContactMessage(It.IsAny <ContactMessage>()))
            .Throws <ArgumentException>();

            var result = candidateServiceProvider.SendContactMessage(candidateId, new ContactMessageViewModel());

            result.Should().BeFalse();
        }