Ejemplo n.º 1
0
        public async Task GetAdDetails_IfAdNotFound_ShouldReturnError()
        {
            Ad ad = null;

            _mockAdRepository.Setup(mr => mr.GetAdDetailsAsync(It.IsAny <Guid>()))
            .ReturnsAsync(ad);

            AdManager adManager = new AdManager(_mockAdRepository.Object, _mockMapper.Object, _mockUnitOfWork.Object);

            var result = await adManager.GetAdDetailsAsync(new Guid());

            Assert.True(result.Success == false);
            Assert.True(result.StatusCode == HttpStatusCode.NotFound);
            Assert.True(result.Message == Messages.AdNotFound);
        }
Ejemplo n.º 2
0
        public async Task GetAdDetails_IfAdNotFound_ShouldReturnSuccess()
        {
            Ad ad = new Ad
            {
                Id       = new Guid(),
                Title    = "Ad title",
                Category = new Category
                {
                    Id   = new Guid(),
                    Name = "Category Name"
                }
            };

            _mockAdRepository.Setup(ar => ar.GetAdDetailsAsync(It.IsAny <Guid>()))
            .ReturnsAsync(ad);

            AdManager adManager = new AdManager(_mockAdRepository.Object, _mockMapper.Object, _mockUnitOfWork.Object);

            var result = await adManager.GetAdDetailsAsync(new Guid());

            Assert.True(result.Success);
            Assert.True(result.StatusCode == HttpStatusCode.OK);
        }