Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        public void Equals_Sign_Where_Both_Null_Result_Is_True()
        {
            ESInv.Domain.Money _value1 = null;
            ESInv.Domain.Money _value2 = null;

            Assert.IsTrue(_value1 == _value2);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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;
        }
Ejemplo n.º 14
0
        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;
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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());
        }
Ejemplo n.º 18
0
        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());
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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());
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        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;
        }
Ejemplo n.º 24
0
        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;
        }
Ejemplo n.º 25
0
        public void Greater_Than_Where_Second_Is_Null_Results_In_An_Exception()
        {
            var _euro100 = new ESInv.Domain.Money("EUR", 100M);

            var _result = _euro100 > null;
        }
Ejemplo n.º 26
0
        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;
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
        public void Plus_Where_Second_Is_Null_Results_In_An_Exception()
        {
            var _euro100 = new ESInv.Domain.Money("EUR", 100M);

            var _result = _euro100 + null;
        }
Ejemplo n.º 30
0
        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;
        }
Ejemplo n.º 31
0
        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);
        }
Ejemplo n.º 32
0
        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);
        }
Ejemplo n.º 33
0
        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);
        }
Ejemplo n.º 34
0
        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);
        }
Ejemplo n.º 35
0
        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);
        }
Ejemplo n.º 36
0
        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);
        }
Ejemplo n.º 37
0
        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);
        }
Ejemplo n.º 38
0
        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;
        }