Beispiel #1
0
 public Produto(string v1, string empty, bool v2, int v3, Guid guid, DateTime now, string v4, Dimensoes dimensoes)
 {
     this.v1        = v1;
     this.empty     = empty;
     this.v2        = v2;
     this.v3        = v3;
     this.guid      = guid;
     this.now       = now;
     this.v4        = v4;
     this.dimensoes = dimensoes;
 }
Beispiel #2
0
        public Produto(string nome, string descricao, bool ativo, decimal valor, Guid categoriaId, DateTime dataCadastro, string imagem, Dimensoes dimensoes)
        {
            Nome         = nome;
            Descricao    = descricao;
            Ativo        = ativo;
            Valor        = valor;
            CategoriaId  = categoriaId;
            DataCadastro = dataCadastro;
            Imagem       = imagem;
            Dimensoes    = dimensoes;

            Validar();
        }
Beispiel #3
0
        public void Produto_validar_ValidacoesDevemRetornarExceptionsComMensagens()
        {
            // Arrange

            Dimensoes dimensoes = new  Dimensoes(2, 2, 2);

            // Act
            var ex = Assert.Throws <DomainException>(() => new Produto(string.Empty, "Descricao", true, 10, DateTime.UtcNow, "imagem", Guid.NewGuid(), dimensoes)
                                                     );

            //Assert
            Assert.Equal($"o camo {nameof(Produto.Nome)} está vazio", ex.Message);

            // Act
            ex = Assert.Throws <DomainException>(() => new Produto("produto 1", string.Empty, true, 10, DateTime.UtcNow, "imagem", Guid.NewGuid(), dimensoes)
                                                 );
            //Assert
            Assert.Equal($"o camo {nameof(Produto.Descricao)} está vazio", ex.Message);

            // Act
            ex = Assert.Throws <DomainException>(() => new Produto("produto 1", "Descricao", true, 10, DateTime.UtcNow, "imagem", Guid.Empty, dimensoes)
                                                 );
            //Assert
            Assert.Equal($"O campo  {nameof(Produto.CategoriaID)} não pode ser vazio", ex.Message);

            // Act
            ex = Assert.Throws <DomainException>(() => new Produto("produto", "Descricao", true, 10, DateTime.UtcNow, string.Empty, Guid.NewGuid(), dimensoes)
                                                 );
            //Assert
            Assert.Equal($"o camo {nameof(Produto.Imagem)} está vazio", ex.Message);

            // Act
            ex = Assert.Throws <DomainException>(() => new Produto("produto", "Descricao", true, 0, DateTime.UtcNow, "imagem", Guid.NewGuid(), dimensoes)
                                                 );
            //Assert
            Assert.Equal($"O campo  {nameof(Produto.Valor)} não pode ser menor ou igual a 0", ex.Message);
        }