Skip to content

Instantly share code, notes, and snippets.

Stephany Henrique Batista StephanyBatista

Block or report user

Report or block StephanyBatista

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@StephanyBatista
StephanyBatista / Startup.cs
Created Jun 23, 2018
Configuring the cookie
View Startup.cs
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>()
@StephanyBatista
StephanyBatista / ContextFactory.cs
Created Jun 23, 2018
Factory need to use migration in .Net Core 2.1
View ContextFactory.cs
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()
View CidadeBuilder.cs
var cidade = FluentBuilder<Cidade>.New().With(c => c.Nome, "Campo Grande").Build();
View CursoTeste.cs
[Theory]
[InlineData("")]
[InlineData(null)]
public void NaoDeveCursoTerUmNomeInvalido(string nomeInvalido)
{
Assert.Throws<ExcecaoDeDominio>(() =>
CursoBuilder.Novo().ComNome(nomeInvalido).Build())
.ComMensagem(Resource.NomeInvalido);
}
View CursoBuilder.cs
using System;
using System.Collections.Generic;
using System.Text;
using CursoOnline.Dominio.Cursos;
using CursoOnline.DominioTest.Cursos;
namespace CursoOnline.DominioTest._Builders
{
public class CursoBuilder
{
View CursoTeste.cs
[Fact]
public void DeveCriarCurso()
{
var cursoEsperado = new
{
Nome = _nome,
CargaHoraria = _cargaHoraria,
PublicoAlvo = _publicoAlvo,
Valor = _valor,
Descricao = _descricao
View Startup.cs
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
View ProductController.cs
public class ProductController : Controller
{
private readonly ProductRepository _productRepository;
public ProductController(ProductRepository productRepository)
{
_productRepository = productRepository;
}
public IActionResult Index()
View ProductController.cs
public class ProductController : Controller
{
private ProductRepository _productRepository;
public ProductController()
{
}
}
View ProductController.cs
public class ProductController : Controller
{
public IActionResult Index()
{
var applicationDbContext = new ApplicationDbContext(null);
var repository = new ProductRepository(applicationDbContext);
return View(repository.GetAll());
}
}
You can’t perform that action at this time.