public void ClearUncommitedChanges_Where_Order_Created_Event_Existed_Results_In_Order_With_No_Uncommited_Changes() { var _merchant = new ESInv.Domain.Merchant(12, "The merchant name"); var _cardNumber = 4242424242424242UL; var _saleValue = new ESInv.Domain.Money("EUR", 100M); var _cardNumberResolutionService = Substitute.For <ESInv.Domain.ICardNumberResolutionService>(); _cardNumberResolutionService.Resolve(_cardNumber).Returns("USD"); var _rateService = Substitute.For <ESInv.Domain.IRateService>(); _rateService.GetRate(_saleValue.Currency, "USD").Returns(1.27M); var _SUT = ESInv.Domain.OrderAggregate.CreateEmpty(); _SUT.Create( _merchant, _cardNumber, _saleValue, _cardNumberResolutionService, _rateService); _SUT.ClearUncommitedChanges(); Assert.AreEqual(0, _SUT.UncommittedChanges.Count()); }
public void Greater_Than_Or_Equal_Where_Good_Arguments_Result_Is_True() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _euro90 = new ESInv.Domain.Money("EUR", 90M); Assert.IsTrue(_euro100 >= _euro90); }
public void Equals_Sign_Where_Different_Values_Results_Is_False() { var _value1 = new ESInv.Domain.Money("EUR", 100M); var _value2 = new ESInv.Domain.Money("EUR", 99.99M); Assert.IsFalse(_value1 == _value2); }
public void Equals_Sign_Where_Same_Values_Result_Is_True() { var _value1 = new ESInv.Domain.Money("EUR", 100M); var _value2 = new ESInv.Domain.Money("EUR", 100M); Assert.IsTrue(_value1 == _value2); }
public void Equals_Sign_Where_One_Is_Null_Results_Is_False() { ESInv.Domain.Money _value1 = new ESInv.Domain.Money("EUR", 100M); ESInv.Domain.Money _value2 = null; Assert.IsFalse(_value1 == _value2); }
public void Greater_Than_Or_Equal_Where_Good_Arguments_Both_Are_Same_Value_Result_Is_False() { var _euro100_1 = new ESInv.Domain.Money("EUR", 100M); var _euro100_2 = new ESInv.Domain.Money("EUR", 100M); Assert.IsTrue(_euro100_1 >= _euro100_2); }
public void Greater_Than_Or_Equal_Where_Second_Is_Different_Currency_Results_In_An_Exception() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _US100 = new ESInv.Domain.Money("USD", 90M); var _result = _euro100 >= _US100; }
public void Less_Than_Where_Good_Arguments_Result_Is_False() { var _euro190 = new ESInv.Domain.Money("EUR", 190M); var _euro100 = new ESInv.Domain.Money("EUR", 100M); Assert.IsFalse(_euro190 < _euro100); }
public void Greater_Than_Or_Equal_Where_Good_Arguments_Result_Is_False() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _euro190 = new ESInv.Domain.Money("EUR", 190M); Assert.IsFalse(_euro100 >= _euro190); }
public void Equals_Sign_Where_Both_Null_Result_Is_True() { ESInv.Domain.Money _value1 = null; ESInv.Domain.Money _value2 = null; Assert.IsTrue(_value1 == _value2); }
public void Greater_Than_Where_Good_Arguments_Result_Is_True() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _euro90 = new ESInv.Domain.Money("EUR", 90M); Assert.IsTrue(_euro100 > _euro90); }
public void Plus_Where_Second_Is_Different_Currency_Results_In_An_Exception() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _US100 = new ESInv.Domain.Money("USD", 90M); var _result = _euro100 + _US100; }
public void Minus_Where_Second_Is_Greater_Than_First_Results_In_An_Exception() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _euro90 = new ESInv.Domain.Money("EUR", 190M); var _result = _euro100 - _euro90; }
public void Minus_Where_Second_Is_Smaller_Results_In_Good_Result() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _euro90 = new ESInv.Domain.Money("EUR", 90M); var _result = _euro100 - _euro90; Assert.AreEqual(new ESInv.Domain.Money("EUR", 10M), _result); }
public void Plus_Where_Good_Arguments_Results_In_Good_Result() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _euro90 = new ESInv.Domain.Money("EUR", 90M); var _result = _euro100 + _euro90; Assert.AreEqual(new ESInv.Domain.Money("EUR", 190M), _result); }
public void Create_Where_Good_Data_Results_In_Order_Creation() { // Start Billy and Noels build context // Parse and good var _merchant = new ESInv.Domain.Merchant(12, "The merchant name"); var _cardNumber = 4242424242424242UL; var _saleValue = new ESInv.Domain.Money("EUR", 100M); // Signature // Create a creation context // End Billy and Noels build context var _cardNumberResolutionService = Substitute.For <ESInv.Domain.ICardNumberResolutionService>(); _cardNumberResolutionService.Resolve(_cardNumber).Returns("USD"); var _rateService = Substitute.For <ESInv.Domain.IRateService>(); _rateService.GetRate(_saleValue.Currency, "USD").Returns(1.27M); var _SUT = ESInv.Domain.OrderAggregate.CreateEmpty(); // Start pipeline _SUT.Create( _merchant, _cardNumber, _saleValue, _cardNumberResolutionService, _rateService); Assert.AreEqual(1, _SUT.UncommittedChanges.Count()); Assert.IsInstanceOf <ESInv.Messages.OrderCreated>(_SUT.UncommittedChanges.First()); var _event = _SUT.UncommittedChanges.First() as ESInv.Messages.OrderCreated; Assert.AreEqual(_merchant.Id, _event.MerchantId); Assert.AreEqual(_saleValue.Currency, _event.SaleValue.Currency); Assert.AreEqual(_saleValue.Amount, _event.SaleValue.Amount); Assert.AreEqual(2, _event.Offers.Count()); var _nonDCCOffer = _event.Offers.First(); var _DCCOffer = _event.Offers.Skip(1).First(); Assert.AreEqual(1M, _nonDCCOffer.ExchangeRateIncludingMargin); Assert.AreEqual(_saleValue.Currency, _nonDCCOffer.PaymentValue.Currency); Assert.AreEqual(_saleValue.Amount, _nonDCCOffer.PaymentValue.Amount); Assert.AreNotEqual(1M, _DCCOffer.ExchangeRateIncludingMargin); Assert.AreNotEqual(_saleValue.Currency, _DCCOffer.PaymentValue.Currency); Assert.AreNotEqual(_saleValue.Amount, _DCCOffer.PaymentValue.Amount); Assert.AreEqual(1, _SUT.UncommittedChanges.Count()); }
public void Create_Where_Good_Data_Results_In_Order_Creation() { // Start Billy and Noels build context // Parse and good var _merchant = new ESInv.Domain.Merchant(12, "The merchant name"); var _cardNumber = 4242424242424242UL; var _saleValue = new ESInv.Domain.Money("EUR", 100M); // Signature // Create a creation context // End Billy and Noels build context var _cardNumberResolutionService = Substitute.For<ESInv.Domain.ICardNumberResolutionService>(); _cardNumberResolutionService.Resolve(_cardNumber).Returns("USD"); var _rateService = Substitute.For<ESInv.Domain.IRateService>(); _rateService.GetRate(_saleValue.Currency, "USD").Returns(1.27M); var _SUT = ESInv.Domain.OrderAggregate.CreateEmpty(); // Start pipeline _SUT.Create( _merchant, _cardNumber, _saleValue, _cardNumberResolutionService, _rateService); Assert.AreEqual(1, _SUT.UncommittedChanges.Count()); Assert.IsInstanceOf<ESInv.Messages.OrderCreated>(_SUT.UncommittedChanges.First()); var _event = _SUT.UncommittedChanges.First() as ESInv.Messages.OrderCreated; Assert.AreEqual(_merchant.Id, _event.MerchantId); Assert.AreEqual(_saleValue.Currency, _event.SaleValue.Currency); Assert.AreEqual(_saleValue.Amount, _event.SaleValue.Amount); Assert.AreEqual(2, _event.Offers.Count()); var _nonDCCOffer = _event.Offers.First(); var _DCCOffer = _event.Offers.Skip(1).First(); Assert.AreEqual(1M, _nonDCCOffer.ExchangeRateIncludingMargin); Assert.AreEqual(_saleValue.Currency, _nonDCCOffer.PaymentValue.Currency); Assert.AreEqual(_saleValue.Amount, _nonDCCOffer.PaymentValue.Amount); Assert.AreNotEqual(1M, _DCCOffer.ExchangeRateIncludingMargin); Assert.AreNotEqual(_saleValue.Currency, _DCCOffer.PaymentValue.Currency); Assert.AreNotEqual(_saleValue.Amount, _DCCOffer.PaymentValue.Amount); Assert.AreEqual(1, _SUT.UncommittedChanges.Count()); }
public void RoundTrip() { var _merchant = new ESInv.Domain.Merchant(12, "The merchant name"); var _cardNumber = 4242424242424242UL; var _saleValue = new ESInv.Domain.Money("EUR", 100M); var _cardNumberResolutionService = Substitute.For <ESInv.Domain.ICardNumberResolutionService>(); _cardNumberResolutionService.Resolve(_cardNumber).Returns("USD"); var _rateService = Substitute.For <ESInv.Domain.IRateService>(); _rateService.GetRate(_saleValue.Currency, "USD").Returns(1.27M); var _order = ESInv.Domain.OrderAggregate.CreateEmpty(); _order.Create( _merchant, _cardNumber, _saleValue, _cardNumberResolutionService, _rateService); _order.MakePayment( new ESInv.Domain.Money("EUR", 50M)); var _SUT = new ESInv.Data.Repository <ESInv.Domain.OrderAggregate>(); _SUT.Save(_order); var _retreivedOrder = _SUT.GetById(_order.Id); _retreivedOrder.MakePayment( new ESInv.Domain.Money("EUR", 50M)); _retreivedOrder.MakePayment( new ESInv.Domain.Money("EUR", 50M)); _SUT.Save(_retreivedOrder); }
public void RoundTrip() { var _merchant = new ESInv.Domain.Merchant(12, "The merchant name"); var _cardNumber = 4242424242424242UL; var _saleValue = new ESInv.Domain.Money("EUR", 100M); var _cardNumberResolutionService = Substitute.For<ESInv.Domain.ICardNumberResolutionService>(); _cardNumberResolutionService.Resolve(_cardNumber).Returns("USD"); var _rateService = Substitute.For<ESInv.Domain.IRateService>(); _rateService.GetRate(_saleValue.Currency, "USD").Returns(1.27M); var _order = ESInv.Domain.OrderAggregate.CreateEmpty(); _order.Create( _merchant, _cardNumber, _saleValue, _cardNumberResolutionService, _rateService); _order.MakePayment( new ESInv.Domain.Money("EUR", 50M)); var _SUT = new ESInv.Data.Repository<ESInv.Domain.OrderAggregate>(); _SUT.Save(_order); var _retreivedOrder = _SUT.GetById(_order.Id); _retreivedOrder.MakePayment( new ESInv.Domain.Money("EUR", 50M)); _retreivedOrder.MakePayment( new ESInv.Domain.Money("EUR", 50M)); _SUT.Save(_retreivedOrder); }
public void ClearUncommitedChanges_Where_Order_Created_Event_Existed_Results_In_Order_With_No_Uncommited_Changes() { var _merchant = new ESInv.Domain.Merchant(12, "The merchant name"); var _cardNumber = 4242424242424242UL; var _saleValue = new ESInv.Domain.Money("EUR", 100M); var _cardNumberResolutionService = Substitute.For<ESInv.Domain.ICardNumberResolutionService>(); _cardNumberResolutionService.Resolve(_cardNumber).Returns("USD"); var _rateService = Substitute.For<ESInv.Domain.IRateService>(); _rateService.GetRate(_saleValue.Currency, "USD").Returns(1.27M); var _SUT = ESInv.Domain.OrderAggregate.CreateEmpty(); _SUT.Create( _merchant, _cardNumber, _saleValue, _cardNumberResolutionService, _rateService); _SUT.ClearUncommitedChanges(); Assert.AreEqual(0, _SUT.UncommittedChanges.Count()); }
public void Ctor_Lower_Case_Currency_Paramter_Results_In_Object_Creation_With_Upper_Case_Currency() { var _SUT = new ESInv.Domain.Money("eur", 100M); Assert.AreEqual("EUR", _SUT.Currency); }
public void Greater_Than_Or_Equal_Where_Second_Is_Null_Results_In_An_Exception() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _result = _euro100 >= null; }
public void Greater_Than_Where_Second_Is_Null_Results_In_An_Exception() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _result = _euro100 > null; }
public void Less_Than_Or_Equal_Where_Second_Is_Null_Results_In_An_Exception() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _result = _euro100 <= null; }
public void Greater_Than_Where_Good_Arguments_Result_Is_False() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _euro190 = new ESInv.Domain.Money("EUR", 190M); Assert.IsFalse(_euro100 > _euro190); }
public void Plus_Where_Second_Is_Null_Results_In_An_Exception() { var _euro100 = new ESInv.Domain.Money("EUR", 100M); var _result = _euro100 + null; }
public void Less_Than_Or_Equal_Where_Good_Arguments_Result_Is_False() { var _euro190 = new ESInv.Domain.Money("EUR", 190M); var _euro100 = new ESInv.Domain.Money("EUR", 100M); Assert.IsFalse(_euro190 <= _euro100); }
public void NotEquals_Where_Same_Values_Results_Is_False() { var _value1 = new ESInv.Domain.Money("EUR", 100M); var _value2 = new ESInv.Domain.Money("EUR", 100M); Assert.IsFalse(_value1 != _value2); }
public void NotEquals_Where_One_Is_Null_Result_Is_True() { ESInv.Domain.Money _value1 = new ESInv.Domain.Money("EUR", 100M); ESInv.Domain.Money _value2 = null; Assert.IsTrue(_value1 != _value2); }
public void NotEquals_Where_Different_Values_Result_Is_True() { var _value1 = new ESInv.Domain.Money("EUR", 100M); var _value2 = new ESInv.Domain.Money("EUR", 99.99M); Assert.IsTrue(_value1 != _value2); }
public void Less_Than_Where_Good_Arguments_Result_Is_True() { var _euro90 = new ESInv.Domain.Money("EUR", 90M); var _euro100 = new ESInv.Domain.Money("EUR", 100M); Assert.IsTrue(_euro90 < _euro100); }