public void Throw_WhenIdParameterIsInvalid()
        {
            // Arrange
            var brands         = new Mock <IEfGenericRepository <Brand> >();
            var invalidBrandId = 0;
            var brandsService  = new BrandsService(brands.Object);

            //Act & Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => brandsService.GetById(invalidBrandId));
        }
        public void ReturnNull_WhenRepositoryMethodGetById_ReturnsNull()
        {
            //Arrange
            var brands  = new Mock <IEfGenericRepository <Brand> >();
            var brandId = 1;

            brands.Setup(x => x.GetById(It.IsAny <int>())).Returns(() => null);
            var brandsService = new BrandsService(brands.Object);

            //Act
            var result = brandsService.GetById(brandId);

            //Assert
            Assert.IsNull(result);
        }
        public void ReturnCorrectInstance()
        {
            //Arrange
            var brands  = new Mock <IEfGenericRepository <Brand> >();
            var brand   = DataHelper.GetBrand();
            var brandId = brand.Id;

            brands.Setup(x => x.GetById(It.IsAny <int>())).Returns(brand);
            var brandsService = new BrandsService(brands.Object);

            //Act
            var result = brandsService.GetById(brandId);

            //Assert
            Assert.IsInstanceOf <Brand>(result);
        }
        public void InvokeRepositoryMethosGetByIdOnce()
        {
            //Arrange
            var brands  = new Mock <IEfGenericRepository <Brand> >();
            var brand   = DataHelper.GetBrand();
            var brandId = brand.Id;

            brands.Setup(x => x.GetById(It.IsAny <int>())).Returns(brand);
            var brandsService = new BrandsService(brands.Object);

            //Act
            var result = brandsService.GetById(brandId);

            //Assert
            brands.Verify(x => x.GetById(It.IsAny <int>()), Times.Once);
        }
        public void ReturnCorrectModelWithRightProperties()
        {
            //Arrange
            var brands  = new Mock <IEfGenericRepository <Brand> >();
            var brand   = DataHelper.GetBrand();
            var brandId = brand.Id;

            brands.Setup(x => x.GetById(It.IsAny <int>())).Returns(brand);
            var brandsService = new BrandsService(brands.Object);

            //Act
            var result = brandsService.GetById(brandId);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(result, brand);
            Assert.AreEqual(result.Id, brand.Id);
            Assert.AreEqual(result.Name, brand.Name);
            Assert.AreEqual(result.WebSite, brand.WebSite);
        }