コード例 #1
0
ファイル: LeaseTasks.cs プロジェクト: xlgmokha/sait
        public DisplayResponseLineDTO RequestLeaseUsing(SubmitLeaseRequestDTO request)
        {
            ICustomer customer = _customers.FindBy(request.CustomerId);

            try {
                customer.Lease(_slips.FindBy(request.SlipId), LeaseDurations.FindBy(request.Duration));
                _customers.Save(customer);
                return(new DisplayResponseLineDTO("Success!"));
            }
            catch (SlipIsAlreadyLeasedException) {
                return(new DisplayResponseLineDTO("Slip is already leased!"));
            }
        }
コード例 #2
0
ファイル: LeaseTasksTest.cs プロジェクト: xlgmokha/sait
        public void customer_should_attempt_to_lease_slip()
        {
            long customerId = 87;
            long slipId     = 32;

            string duration = "weekly";
            SubmitLeaseRequestDTO request = new SubmitLeaseRequestDTO(customerId, slipId, duration);
            ISlip     slip     = _mockery.DynamicMock <ISlip>( );
            ICustomer customer = _mockery.DynamicMock <ICustomer>( );

            using (_mockery.Record( )) {
                SetupResult.For(_customers.FindBy(customerId)).Return(customer);
                SetupResult.For(_slips.FindBy(slipId)).Return(slip);

                customer.Lease(slip, LeaseDurations.FindBy(duration));
            }

            using (_mockery.Playback( )) {
                CreateSUT( ).RequestLeaseUsing(request);
            }
        }