コード例 #1
0
        public void AddProduct_ProductAlreadyExists_ThrowException()
        {
            var product = ProductHelperTest.CreateProductExisting();

            var ex = Assert.Throws <RepositoryException>(() => this.repository.Add(product));

            Assert.That(ex.Message, Is.EqualTo("Produto 'CAMISA' já existe."));
        }
コード例 #2
0
        public void UpdateProduct_ProductUpdatedAlreadyExists_ThrowException()
        {
            var product = ProductHelperTest.CreateProductValid();

            this.repository.Add(product);
            var productUpdated = this.repository.GetAll()[1];

            productUpdated.Description = "CAMISA";

            var ex = Assert.Throws <RepositoryException>(() => this.repository.Update(productUpdated));

            Assert.That(ex.Message, Is.EqualTo("Produto 'CAMISA' já existe."));
        }
コード例 #3
0
        public void AddProduct_ProductIsValid_GetAllProductAdded()
        {
            var product = ProductHelperTest.CreateProductValid();

            this.repository.Add(product);

            var products = this.repository.GetAll();

            Assert.That(products.Count, Is.EqualTo(2));

            Assert.That(products[0].Description, Is.EqualTo("CAMISA"));
            Assert.That(products[1].Description, Is.EqualTo("CAMISETA"));
        }