This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public HttpResponseMessage CreateCustomer(string name, string billingInfo) | |
{ | |
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo); | |
Result<CustomerName> customerNameResult = CustomerName.Create(name); | |
return Result.Combine(billingInfoResult, customerNameResult) | |
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value)) | |
.OnSuccess(() => new Customer(customerNameResult.Value)) | |
.OnSuccess( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student : Entity | |
{ | |
public string FirstName { get; private set; } | |
public string LastName { get; private set; } | |
public int FavoriteCourseId { get; private set; } // Foreign key | |
} | |
public class Course : Entity | |
{ | |
public string Title { get; private set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Customer | |
{ | |
public CustomerName Name { get; private set; } | |
public Email Email { get; private set; } | |
public Customer(CustomerName name, Email email) | |
{ | |
if (name == null) | |
throw new ArgumentNullException("name"); | |
if (email == null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Create(string name, string email, string billingInfo) | |
{ | |
Result<CustomerName> nameResult = CustomerName.Create(name); | |
Result<Email> emailResult = Email.Create(email); | |
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo); | |
return Result.Combine(nameResult, emailResult, billingInfoResult) | |
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value)); | |
/* Other OnSuccess, OnFailure, OnBoth methods */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Customer customer = await session.GetAsync<Customer>(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person : Entity | |
{ | |
public virtual string Name { get; set; } | |
private readonly DocumentContainer _document; | |
public virtual Document Document | |
{ | |
get => _document.Document; | |
set => _document.Document = value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class PoolType : ValueObject | |
{ | |
public static readonly PoolType Quant = new QuantPoolType(); | |
public static readonly PoolType Verbal = new VerbalPoolType(); | |
public static readonly PoolType IR = new IRPoolType(); | |
public static readonly PoolType Awa = new AwaPoolType(); | |
public static readonly PoolType[] AllTypes = { Quant, Verbal, IR, Awa }; | |
public abstract int Id { get; } | |
public abstract int Size { get; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class ValueObject<T> | |
where T : ValueObject<T> | |
{ | |
public override bool Equals(object obj) | |
{ | |
var valueObject = obj as T; | |
if (ReferenceEquals(valueObject, null)) | |
return false; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Industry : Entity | |
{ | |
public const string CarsIndustry = "Cars"; | |
public const string PharmacyIndustry = "Pharmacy"; | |
public const string MediaIndustry = "Media"; | |
public string Name { get; private set; } | |
} | |
public class Customer : Entity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void Parser_parses_xml_in_correct_order() | |
{ | |
// Arrange : input values | |
string xml = "<outer><inner /></outer>"; | |
var parser = new Parser(); | |
// Arrange : record expectations | |
var mocks = new MockRepository(); | |
IHandler handler = mocks.CreateMock<IHandler>(); |
NewerOlder