Exemple #1
0
        public void Create_ThrowsUnsupportedValueExceptionWithExpectedMessage_WhenBrandNameIsNull()
        {
            var brandToCreate            = new BrandDto();
            var expectedExceptionMessage = new UnsupportedValueException(null);

            var exception = Assert.Throws <UnsupportedValueException>(() => brandService.Create(brandToCreate));

            Assert.AreEqual(expectedExceptionMessage.Message, exception.Message);
        }
Exemple #2
0
        public void Create_ThrowsUnsupportedValueExceptionWithExpectedMessage_WhenBrandNameIsNotUnique()
        {
            var brandToCreate = new BrandDto()
            {
                Name = FirstBrandName
            };
            var expectedExceptionMessage = new UnsupportedValueException(brandToCreate.Name);

            unitOfWorkMock.Setup(x => x.Brands.Get(It.IsAny <Expression <Func <BrandEntity, bool> > >(), It.IsAny <string[]>()))
            .Returns(new List <BrandEntity>()
            {
                new BrandEntity()
                {
                    Name = FirstBrandName
                }
            }.AsQueryable);

            var exception = Assert.Throws <UnsupportedValueException>(() => brandService.Create(brandToCreate));

            Assert.AreEqual(expectedExceptionMessage.Message, exception.Message);
        }