public void GetBalmById_ExpectingBalm_ResultShouldReturnBalmViewModel() { // arrance var mockBalmRepository = new Mock <IBalmRepository>(); var balm = new Balm() { Id = Guid.NewGuid(), Volume = 30, Brand = "Balm Brand 1", Description = "Balm Description 1", UnitQuantity = 100, UnitPrice = 30, URL = "img/balm1.jpg" }; mockBalmRepository.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(balm); var config = new MapperConfiguration(cfg => { cfg.CreateMap <Balm, BalmViewModel>(); }); var mapper = config.CreateMapper(); // act var balmService = new BalmService(mockBalmRepository.Object, mapper); var result = balmService.GetBalmById(Guid.NewGuid()); // assert result.Should().BeOfType(typeof(BalmViewModel)); }
public void GetBalmById_NotExpectingBalm_ResultShouldBeNull() { // arrance var mockBalmRepository = new Mock <IBalmRepository>(); var mockMapper = new Mock <IMapper>(); // act var balmService = new BalmService(mockBalmRepository.Object, mockMapper.Object); var result = balmService.GetBalmById(Guid.NewGuid()); // assert result.Should().BeNull(); }