Skip to content

Instantly share code, notes, and snippets.

View StephanyBatista's full-sized avatar

Stephany Henrique Batista StephanyBatista

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Text;
using CursoOnline.Dominio.Cursos;
using CursoOnline.DominioTest.Cursos;
namespace CursoOnline.DominioTest._Builders
{
public class CursoBuilder
{
[Theory]
[InlineData("")]
[InlineData(null)]
public void NaoDeveCursoTerUmNomeInvalido(string nomeInvalido)
{
Assert.Throws<ExcecaoDeDominio>(() =>
CursoBuilder.Novo().ComNome(nomeInvalido).Build())
.ComMensagem(Resource.NomeInvalido);
}
var cidade = FluentBuilder<Cidade>.New().With(c => c.Nome, "Campo Grande").Build();
@StephanyBatista
StephanyBatista / ContextFactory.cs
Created June 23, 2018 18:34
Factory need to use migration in .Net Core 2.1
using System.IO;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace StoreOfBuild.Data.Contexts
{
public class ContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
{
public ApplicationDbContext CreateDbContext()
@StephanyBatista
StephanyBatista / Startup.cs
Created June 23, 2018 18:55
Configuring the cookie
services.AddIdentity<ApplicationUser, IdentityRole>(config => {
config.Password.RequireDigit = false;
config.Password.RequiredLength = 3;
config.Password.RequireLowercase = false;
config.Password.RequireNonAlphanumeric = false;
config.Password.RequireUppercase = false;
//Does not work in Core 2.1.
//config.Cookies.ApplicationCookie.LoginPath = "/Account/Login";
})
.AddEntityFrameworkStores<ApplicationDbContext>()
[Fact]
public void DeveCriarCurso()
{
var curso = new Curso(nomeEsperado, descricaoEsperada, valorEsperado);
Assert.Equal(nomeEsperado, curso.Nome);
Assert.Equal(descricaoEsperada, curso.Descricao);
Assert.Equal(valorEsperado, curso.Valor);
}
[Fact]
public void DeveCriarCursoComNome()
{
var curso = new Curso(nomeEsperado, descricaoEsperada, valorEsperado);
Assert.Equal(nomeEsperado, curso.Nome);
}
[Fact]
public void DeveCriarCursoComDescricao()
[Fact]
public void DeveCriarUmCurso()
{
var cursoEsperado = new
{
Nome = _nome,
Valor = _valor,
Descricao = _descricao
};
var fake = new Faker();
_cursoDto = new CursoDto
{
Nome = fake.Random.Words(),
Descricao = fake.Lorem.Paragraph(),
CargaHoraria = fake.Random.Double(50, 1000),
PublicoAlvo = "Estudante",
Valor = fake.Random.Double(1000, 2000)
};
var nomeEsperado = "Teste";
var precoEsperado = 1;
var curso = new Curso("Teste", 1);