Skip to content

Instantly share code, notes, and snippets.

View maiconheck's full-sized avatar

Maicon Heck maiconheck

View GitHub Profile
@maiconheck
maiconheck / VS-Shortcuts-CheatSheet.md
Last active October 17, 2020 09:48
VS Shortcuts CheatSheet

My Visual Studio Shortcuts CheatSheet

The frequently used / custom shortcuts


Edit / File

Code Cleanup Format Document Insert Snippet Surround With
Ctrl+K, Ctrl+E Ctrl+K, Ctrl+D Ctrl+K, Ctrl+X Ctrl+K, Ctrl+S
@maiconheck
maiconheck / Lead.cs
Last active June 26, 2021 13:38
Capturar Leads Context
using System;
using System.Collections.Generic;
using System.Linq;
namespace DddBuildingBlocks.Domain.CapturarLeadsContext
{
public class Lead : Entity
{
private readonly List<Segment> _segments = new List<Segment>();
@maiconheck
maiconheck / Lead.cs
Last active June 23, 2023 18:24
Executar Campanha Context
public class Lead : Entity
{
private readonly List<Segment> _segments = new List<Segment>();
public Name Name { get; }
public Email Email { get; }
public IReadOnlyCollection<Segment> Segments => _segments.ToList();
}
var phoneNumber = new PhoneNumber("51", "25615006");
var address = new Address("79074-047", "Rua Júlio de Castilhos", 1234, "Centro");
var name = new Name("Lucas Luís", "Cruz");
var email = new Email("foo@domain.com");
var lead = new Lead(name, email);
lead.CompleteInfo(phoneNumber, address, false, new DateTime(2000, 12, 20));
@maiconheck
maiconheck / Lead.cs
Last active June 23, 2023 18:26
[4º Improvement]
public class Lead : Entity
{
private readonly List<Segment> _segments;
public Lead(Name name, Email email)
{
Guard.Against
.Null(name, nameof(name))
.Null(email, nameof(email));
[Trait("Category", nameof(Domain))]
public class AddressTest
{
[Theory]
[InlineData("79074-047")]
[InlineData("29725-972")]
public void Address_ValidZipCode_Valid(string zipCode)
{
Assert.DoesNotThrows(() => new Address(zipCode, "Rua Júlio de Castilhos", 1234, "Centro"));
}
[Trait("Category", nameof(Domain))]
public class PhoneNumberTest
{
[Theory]
[InlineData("11")]
[InlineData("51")]
public void PhoneNumber_ValidDdd_Valid(string ddd)
{
Assert.DoesNotThrows(() => new PhoneNumber(ddd, "25615006"));
}
[Trait("Category", "Domain")]
public class EmailTest
{
[Fact]
public void ToString_Email_String()
{
var expected = "foo@domain.com";
var email = new Email(expected);
var actual = email.ToString();
[Trait("Category", nameof(Domain))]
public class NameTest
{
[Theory]
[InlineData("Lucas Luís", "Cruz")]
[InlineData("Erick Oliveira", "")]
public void Name_ValidName_Valid(string firstName, string lastName)
{
Assert.DoesNotThrows(() => new Name(firstName, lastName));
}
public class Address
{
public Address(string zipCode, string street, int number, string neighborhood, string complement = "")
{
Guard.Against
.NotMatch(zipCode, @"^\d{5}-\d{3}$", nameof(zipCode))
.NullOrWhiteSpace(street, nameof(street))
.ZeroOrLess(number, nameof(number))
.NullOrWhiteSpace(neighborhood, nameof(neighborhood));