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 February 3, 2021 11:47
An anemic entity sample for blog posting.
public class Lead
{
public string Name { get; set; }
public string Email { get; set; }
public IList<Segment> Segments { get; set; }
public string Company { get; set; }
@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 20, 2023 12:24
[1º improvement] An anemic entity sample for blog posting.
public class Lead
{
// The minimum data needed to create a Lead instance.
// The name and e-mail are the minimum necessary for a Lead to exist. Remember?
public Lead(string name, string email)
{
Name = name;
Email = email;
}
@maiconheck
maiconheck / Lead.cs
Last active June 20, 2023 12:34
[2º improvement] An anemic entity sample for blog posting.
public class Lead
{
// Initializing Segments to avoid an exception.
public Lead(string name, string email)
{
Name = name;
Email = email;
_segments = new List<Segment>();
}
@maiconheck
maiconheck / Lead.cs
Last active June 20, 2023 13:45
[3º Improvement]
public class Lead
{
public Lead(string name, string email)
{
Name = name;
Email = email;
_segments = new List<Segment>();
}
public string Name { get; }
public class Name
{
public Name(string firstName, string lastName = "")
{
Guard.Against.NullOrWhiteSpace(firstName, nameof(firstName));
FirstName = firstName;
LastName = lastName;
}
public class PhoneNumber
{
public PhoneNumber(string ddd, string number)
{
Guard.Against
.NotMatch(ddd, @"^\d{2}$", nameof(ddd))
.NotMatch(number, @"^\d{8}$|^\d{9}$", nameof(number));
Ddd = ddd;
Number = number;
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));
[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"));
}