public void GivenGetSingleParkingLot_WhenRequestingSingleParkingLot_ReturnRequestedParkingLot() { using (var context = new ParkSharkDbContext(CreateNewInMemoryDatabase())) { var city = City.CreateCity(2050, "Antwerpen", "Belgium"); var service = new ParkingLotService(context); var parkingLot = ParkingLotBuilder.CreateNewParkingLot() .WithName("test") .WithAddress(Address.CreateAddress("Parkinglotstraat", "20a", city)) .WithContactPerson(ContactPerson.CreateNewContactPerson("Bas", "Adriaans", Address.CreateAddress("Contactpersoonstraat", "30", city), "*****@*****.**", "000000", "")) .WithCapacity(20) .WithDivision(Guid.NewGuid()) .WithPricePerHour(4.5m) .Build(); context.Set <ParkingLot>().Add(parkingLot); var id = parkingLot.ParkingLotID; context.SaveChanges(); var result = service.GetSingleParkingLot(id); Assert.IsType <ParkingLot>(result); Assert.Equal(id, result.ParkingLotID); Assert.Equal("test", result.Name); } }
public void GivenGetAllParkingLots_WhenRequestingAllParkingLots_ThenReturnListOfAllParkingLots() { using (var context = new ParkSharkDbContext(CreateNewInMemoryDatabase())) { var city = City.CreateCity(2050, "Antwerpen", "Belgium"); var parkingLot1 = ParkingLotBuilder.CreateNewParkingLot() .WithName("test") .WithAddress(Address.CreateAddress("Parkinglotstraat", "20a", city)) .WithContactPerson(ContactPerson.CreateNewContactPerson("Bas", "Adriaans", Address.CreateAddress("Contactpersoonstraat", "30", city), "*****@*****.**", "000000", "")) .WithCapacity(20) .WithDivision(Guid.NewGuid()) .WithPricePerHour(4.5m) .Build(); var parkingLot2 = ParkingLotBuilder.CreateNewParkingLot() .WithName("test2") .WithAddress(Address.CreateAddress("Parkinglotstraat", "20a", city)) .WithContactPerson(ContactPerson.CreateNewContactPerson("Bas", "Adriaans", Address.CreateAddress("Contactpersoonstraat", "30", city), "*****@*****.**", "000000", "")) .WithCapacity(20) .WithDivision(Guid.NewGuid()) .WithPricePerHour(4.5m) .Build(); context.Set <ParkingLot>().Add(parkingLot1); context.Set <ParkingLot>().Add(parkingLot2); context.SaveChanges(); var service = new ParkingLotService(context); var result = context.ParkingLots.CountAsync(); Assert.Equal(2, result.Result); } }
public void GivenCreateParkingLotDTOReturnFromParkingLot_WhenGivenParkinglotDTOReturnToCreate_ThenCreateParkingLotDTOReturn() { var memstub = Substitute.For <IMemberServices>(); var stubpark = Substitute.For <IParkingLotMapper>(); var stubAddress = Substitute.For <IAddressMapper>(); AddressMapper addressmap = new AddressMapper(new CityMapper(memstub)); ParkingLotMapper parkmap = new ParkingLotMapper(new AddressMapper(new CityMapper(memstub)), new ContactPersonMapper(new AddressMapper(new CityMapper(memstub)))); var city = City.CreateCity(2050, "Antwerpen", "Belgium"); var contactPerson = ContactPerson.CreateNewContactPerson("lasr", "peelman", Address.CreateAddress("test", "5", city), "*****@*****.**", "5454548564", "5456456456"); var parkinglot = ParkingLotBuilder.CreateNewParkingLot() .WithBuildingType(BuildingType.AboveGround) .WithCapacity(5) .WithContactPerson(contactPerson) .WithDivision(new Guid()) .WithName("lasr") .WithPricePerHour(5.00M) .WithAddress(Address.CreateAddress("test", "5", city)) .Build(); var result = parkmap.FromParkingLotToParkingLotDTOReturn(parkinglot); Assert.IsType <ParkingLotDTO_Return>(result); }
public ContactPerson FromContactPersonDTOTOContactPerson(ContactPersonDTO contactPersonDTO) { ContactPerson contactPerson = ContactPerson.CreateNewContactPerson( contactPersonDTO.FirstName, contactPersonDTO.LastName, _addressMapper.DTOToAddress(contactPersonDTO.Address), contactPersonDTO.Email, contactPersonDTO.PhoneNumber, contactPersonDTO.MobilePhoneNumber); return(contactPerson); }
public void GivenFromContactPersonTOContactPersonDTO_WhenGivenContactPerson_ThenCreateContactPersonDTO() { var memstub = Substitute.For <IMemberServices>(); var stubMapper = Substitute.For <IContactPersonMapper>(); ContactPersonMapper cmapper = new ContactPersonMapper(new AddressMapper(new CityMapper(memstub))); var city = City.CreateCity(2050, "Antwerpen", "Belgium"); var contactPerson = ContactPerson.CreateNewContactPerson("lasr", "peelman", Address.CreateAddress("test", "5", city), "*****@*****.**", "5454548564", "5456456456"); var result = cmapper.FromContactPersonTOContactPersonDTO(contactPerson); Assert.IsType <ContactPersonDTO>(result); }
public void GivenParkingLot_WhenPriceIsBelow0_ThenWholeObjectIsNull() { var city = City.CreateCity(2050, "Antwerpen", "Belgium"); var parkinglot = ParkingLotBuilder.CreateNewParkingLot() .WithName("Name") .WithBuildingType(BuildingType.AboveGround) .WithCapacity(2) .WithAddress(Address.CreateAddress("test", "test", city)) .WithPricePerHour(-5) .WithContactPerson(ContactPerson.CreateNewContactPerson("x", "x", Address.CreateAddress("x", "x", city), "*****@*****.**", "x", "x")) .Build(); Assert.Null(parkinglot); }
public void GivenHappyPath2_WhenAddingNewParkingLotToDb_ObjectIsAddedToDb() { using (var context = new ParkSharkDbContext(CreateNewInMemoryDatabase())) { var city = City.CreateCity(2050, "Antwerpen", "Belgium"); var parkingLot = ParkingLotBuilder.CreateNewParkingLot() .WithName("test") .WithAddress(Address.CreateAddress("Parkinglotstraat", "20a", city)) .WithContactPerson(ContactPerson.CreateNewContactPerson("Bas", "Adriaans", Address.CreateAddress("Contactpersoonstraat", "30", city), "*****@*****.**", "000000", "")) .WithCapacity(20) .WithDivision(Guid.NewGuid()) .WithPricePerHour(4.5m) .Build(); var service = new ParkingLotService(context); var result = service.CreateParkingLot(parkingLot); Assert.Single(context.ParkingLots); } }