Beispiel #1
0
        public void Should_be_able_to_insert_new_boats_for_customer()
        {
            IBoat firstBoat  = new Boat("reg1", "TOYOTA", new DateTime(2001, 1, 1), 100);
            IBoat secondBoat = new Boat("reg2", "YAMAHA", new DateTime(2005, 1, 1), 200);

            IList <IBoat> boats = new List <IBoat>( );

            boats.Add(firstBoat);
            boats.Add(secondBoat);

            long            customerId = CustomerMother.CreateCustomerRecord( );
            IBoatDataMapper mapper     = CreateSUT( );

            mapper.Insert(boats, customerId);

            IRichList <IBoat> insertedBoats = ListFactory.From(mapper.AllBoatsFor(customerId));

            Assert.AreEqual(2, insertedBoats.Count);
            Assert.IsTrue(insertedBoats.Contains(firstBoat));
            Assert.IsTrue(insertedBoats.Contains(secondBoat));
        }
Beispiel #2
0
        public void Should_leverage_mapper_to_convert_from_table_to_a_domain_object()
        {
            ISlip unleasedSlip = _mockery.DynamicMock <ISlip>( );
            ISlip leasedSlip   = _mockery.DynamicMock <ISlip>( );

            IList <ISlip> slips = new List <ISlip>( );

            slips.Add(unleasedSlip);
            slips.Add(leasedSlip);

            using (_mockery.Record( )) {
                SetupResult.For(unleasedSlip.IsLeased( )).Return(false);
                SetupResult.For(leasedSlip.IsLeased( )).Return(true);

                Expect.Call(_mockMapper.AllSlips( )).Return(new RichEnumerable <ISlip>(slips));
            }

            using (_mockery.Playback( )) {
                IRichList <ISlip> foundSlips = ListFactory.From(CreateSUT( ).AllAvailableSlips( ));

                Assert.IsTrue(foundSlips.Contains(unleasedSlip));
                Assert.IsFalse(foundSlips.Contains(leasedSlip));
            }
        }
Beispiel #3
0
        public void Should_leverage_mapper_to_convert_to_dto()
        {
            long            customerId = 99;
            ICustomer       customer   = _mockery.DynamicMock <ICustomer>( );
            ISlipLease      lease      = _mockery.DynamicMock <ISlipLease>( );
            DisplayLeaseDTO dto        = new DisplayLeaseDTO("", "", "");

            using (_mockery.Record( )) {
                SetupResult.For(customer.Leases( )).Return(ListFactory.For(lease));
                SetupResult.For(_customers.FindBy(customerId)).Return(customer);
                Expect.Call(_mapper.MapFrom(lease)).Return(dto);
            }

            using (_mockery.Playback( )) {
                IRichList <DisplayLeaseDTO> returnedDtos = ListFactory.From(CreateSUT( ).FindAllLeasesFor(customerId));
                Assert.AreEqual(1, returnedDtos.Count);
                Assert.IsTrue(returnedDtos.Contains(dto));
            }
        }
Beispiel #4
0
        public void Should_insert_new_boats_for_customer()
        {
            long          customerId = CustomerMother.CreateCustomerRecord( );
            IList <IBoat> boats      = CreateBoats( );

            IBoatDataMapper mapper = CreateSUT( );

            mapper.Insert(boats, customerId);

            IBoat thirdBoat = new Boat("reg3", "HONDA", new DateTime(1999, 1, 1), 300);

            boats.Add(thirdBoat);

            mapper.Update(boats, customerId);

            IRichList <IBoat> insertedBoats = ListFactory.From(mapper.AllBoatsFor(customerId));

            Assert.AreEqual(3, insertedBoats.Count);
            Assert.IsTrue(insertedBoats.Contains(thirdBoat));
        }
Beispiel #5
0
        public void Should_return_a_success_message_if_there_are_no_broken_rules()
        {
            IRegistration registration = _mockery.CreateMock <IRegistration>( );

            ICustomer customer = _mockery.DynamicMock <ICustomer>( );

            using (_mockery.Record( )) {
                Expect.Call(_mockCustomerRepository.NewCustomer( )).Return(customer);
                SetupResult.For(customer.Registration( )).Return(registration);
                Expect
                .Call(registration.IsValid( ))
                .Return(true);
            }

            using (_mockery.Playback( )) {
                IRichList <DisplayResponseLineDTO> lineItems =
                    ListFactory.From(CreateSUT( ).RegisterNew(RegisterCustomerDTO( )));
                Assert.IsTrue(lineItems.Contains(new DisplayResponseLineDTO("Success!")));
            }
        }
Beispiel #6
0
        public void Should_leverage_repository_to_find_dock()
        {
            long  dockId = 1;
            IDock dock   = _mockery.DynamicMock <IDock>( );
            ISlip slip   = _mockery.DynamicMock <ISlip>( );

            IList <ISlip> availableSlipsForDock = new List <ISlip>( );

            availableSlipsForDock.Add(slip);

            SlipDisplayDTO dto = ObjectMother.SlipDisplayDTO( );

            using (_mockery.Record( )) {
                Expect.Call(_dockRepository.FindBy(dockId)).Return(dock);
                Expect.Call(_slipRepository.AllAvailableSlipsFor(dock)).Return(availableSlipsForDock);
                Expect.Call(_slipMapper.MapFrom(slip)).Return(dto);
            }

            using (_mockery.Playback( )) {
                IRichList <SlipDisplayDTO> slipsFound = ListFactory.From(CreateSUT( ).GetAvailableSlipsForDockBy(dockId));
                Assert.IsTrue(slipsFound.Contains(dto));
            }
        }