public void Shoud_return_no_broken_rules() { IRegistration registration = CreateSUT("userName", "PASSWORD"); IRichList <IBrokenRule> brokenRules = ListFactory.From(registration.BrokenRules( )); Assert.AreEqual(0, brokenRules.Count); }
public void Correctly_Finds_All() { IRichList <int> ints = new RichList <int>(new int[] { 5, 10, 20 }); IRichList <int> smallInts = ints.FindAll(delegate(int i) { return(i < 11); }); Assert.That(smallInts, Is.EqualTo(new RichList <int>(new int[] { 5, 10 }))); }
public void Should_return_at_least_one_available_slip_for_the_dock() { ISlipsRepository repository = CreateSUT( ); IDock dock = new Dock(1, string.Empty, null, null); IRichList <ISlip> slipsFound = ListFactory.From(repository.AllAvailableSlipsFor(dock)); Assert.IsTrue(slipsFound.Count > 0); }
public void Should_not_allow_blank_username() { string blankUserName = string.Empty; IRegistration registration = CreateSUT(blankUserName, "password"); IRichList <IBrokenRule> brokenRules = ListFactory.From(registration.BrokenRules( )); Assert.IsFalse(registration.IsValid( )); Assert.AreEqual("Username cannot be blank", brokenRules[0].Message( )); }
public void Correctly_Gets_Range() { int[] ints = new int[] { 5, 10, 20 }; IRichList <int> list = new RichList <int>(ints); IRichList <int> range = list.GetRange(1, 2); Assert.That(range, Is.EqualTo(new RichList <int>(new int[] { 10, 20 }))); }
public void Should_return_3_boats() { long customerId = CustomerMother.CreateCustomerRecord( ); BoatMother.AddBoatsFor(customerId); IRichList <IBoat> boats = ListFactory.From(CreateSUT( ).AllBoatsFor(customerId)); Assert.AreEqual(3, boats.Count); }
public void Should_return_all_leases_for_a_specific_customer() { long customerId = CustomerMother.CreateCustomerRecord( ); LeaseMother.CreateLeaseFor(customerId); IRichList <ISlipLease> leasesForCustomer = ListFactory.From(CreateSUT( ).AllLeasesFor(customerId)); Assert.AreEqual(1, leasesForCustomer.Count); }
public void Should_be_able_to_insert_new_leases_for_customer() { long customerId = CustomerMother.CreateCustomerRecord( ); IList <ISlipLease> leases = new List <ISlipLease>( ); leases.Add(new SlipLease(new Slip(1000, null, 100, 100, true), LeaseDurations.Daily)); ILeaseDataMapper mapper = CreateSUT( ); mapper.Insert(leases, customerId); IRichList <ISlipLease> foundLeases = ListFactory.From(mapper.AllLeasesFor(customerId)); Assert.AreEqual(1, foundLeases.Count); }
public void Correctly_Converts_Items() { int[] ints = new int[] { 5, 10 }; long[] longs = new long[] { 5, 10 }; IRichList <int> list = new RichList <int>(ints); IRichList <long> longList = list.ConvertAll <long>( delegate(int input) { return((long)input); }); Assert.That(longList, Is.EqualTo(longs)); Assert.That(longList[0], Is.TypeOf(typeof(long))); Assert.That(longList[1], Is.TypeOf(typeof(long))); }
public void Should_be_able_to_register_an_unregistered_boat() { string registrationNumber = "435535"; string manufacturer = "YAMAHA"; DateTime yearOfModel = new DateTime(1990, 01, 01); long lengthInFeet = 100; ICustomer customer = CreateSUT( ); customer.RegisterBoat(registrationNumber, manufacturer, yearOfModel, lengthInFeet); IRichList <IBoat> boats = ListFactory.From(customer.RegisteredBoats( )); Assert.AreEqual(1, boats.Count); Assert.AreEqual(registrationNumber, boats[0].RegistrationNumber( )); Assert.AreEqual(manufacturer, boats[0].Manufacturer( )); Assert.AreEqual(yearOfModel, boats[0].YearOfModel( )); Assert.AreEqual(lengthInFeet, boats[0].LengthInFeet( )); }
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)); } }
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)); }
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!"))); } }
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)); }
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)); } }
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)); } }
public void Returns_Rich_List() { IRichList <int> richList = EnumerableHelper.ToRichList(new int[0]); Assert.That(richList, Is.TypeOf(typeof(RichList <int>))); }