Ejemplo n.º 1
0
 public void TearDown()
 {
     _mockContactsService = null;
     _fixture             = null;
     _target = null;
     _mapper = null;
 }
Ejemplo n.º 2
0
        public void When_InputIsNull_MapThrowsException()
        {
            ReadByIdQuery getReadByIdQuery = null;

            _target = _fixture.Freeze <ReadByIdQueryHandler>();
            Assert.ThrowsAsync <ArgumentNullException>(async() =>
                                                       await _target.Handle(getReadByIdQuery, default(CancellationToken)));
        }
Ejemplo n.º 3
0
        public void When_InputIsValid_HandlerContactSuccessfully()
        {
            var expected      = _fixture.Create <ContactDto>();
            var query         = _fixture.Create <ReadByIdQuery>();
            var expectedModel = _fixture.Create <Contact>();

            _mapper = _fixture.Freeze <Mock <IMapper> >();
            _mapper.Setup(x => x.Map <ContactDto>(It.IsAny <Contact>())).Returns(expected);

            _mockContactsService = _fixture.Freeze <Mock <IContactService> >();
            _mockContactsService.Setup(x => x.GetContactByIdAsync(It.IsAny <Guid>())).ReturnsAsync(expectedModel);

            _target = _fixture.Create <ReadByIdQueryHandler>();

            var actual = _target.Handle(query, default(CancellationToken));

            Assert.AreEqual(expected, actual.Result);

            _mapper.Verify(x => x.Map <ContactDto>(It.IsAny <Contact>()), Times.Once);

            _mockContactsService.Verify(x => x.GetContactByIdAsync(It.IsAny <Guid>()), Times.Once);
        }