Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Collections.Generic;
using System.Text;
using CursoOnline.Dominio.Cursos;
using CursoOnline.DominioTest.Cursos;
namespace CursoOnline.DominioTest._Builders
{
public class CursoBuilder
{
private string _nome = "Informática básica";
private double _cargaHoraria = 80;
private PublicoAlvo _publicoAlvo = PublicoAlvo.Estudante;
private double _valor = 950;
private string _descricao = "Uma descrição";
private int _id;
public static CursoBuilder Novo()
{
return new CursoBuilder();
}
public CursoBuilder ComNome(string nome)
{
_nome = nome;
return this;
}
public CursoBuilder ComDescricao(string descricao)
{
_descricao = descricao;
return this;
}
public CursoBuilder ComCargaHoraria(double cargaHoraria)
{
_cargaHoraria = cargaHoraria;
return this;
}
public CursoBuilder ComValor(double valor)
{
_valor = valor;
return this;
}
public CursoBuilder ComPublicoAlvo(PublicoAlvo publicoAlvo)
{
_publicoAlvo = publicoAlvo;
return this;
}
public CursoBuilder ComId(int id)
{
_id = id;
return this;
}
public Curso Build()
{
return new Curso(_nome, _descricao, _cargaHoraria, _publicoAlvo, _valor);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment