public void BuildRoomOverload() { HotelBuilder hb = new HotelBuilder(); hb.RoomFactory.RegisterComponent("Empty", new EmptyRoomFactoryComponent()); Assert.IsTrue(hb.RoomFactory.BuildRoom(-1, "Empty", new Point(0, 0), new Point(1, 1)) is EmptyRoom); }
/// <summary> /// Metodo para formar un <see cref="Hotel" /> a partir de un <see cref="DataRow" />. /// El <see cref="DataRow" /> debe cumplir con un orden especifico de parametros para funcionar, /// el cual es respetado por todos las funciones almancenadas relacionadas al modulo de Hotel. /// </summary> /// <param name="row"> /// Fila en donde se encuentran los datos para generar el <see cref="Hotel" /> /// </param> /// <returns><see cref="Hotel" /> segun los datos recibidos</returns> /// <exception cref="IndexOutOfRangeException"> /// Lanzado si el DataRow no devuelve la cantidad de atributos necesarios /// </exception> /// <exception cref="FormatException"> /// Lanzado si algun elemento del DataRow no esta en el orden correcto y por lo tanto no se /// puede convertir al tipo de dato correspondiente para el <see cref="Hotel" /> /// </exception> private static Hotel ExtractHotelFromRow(DataRow row) { var id = Convert.ToInt32(row[0]); var name = row[1].ToString(); var amountOfRooms = Convert.ToInt32(row[2]); var roomCapacity = Convert.ToInt32(row[3]); var isActive = Convert.ToBoolean(row[4]); var addressSpecs = row[5].ToString(); var pricePerRoom = Convert.ToDecimal(row[6]); var website = row[7].ToString(); var phone = row[8].ToString(); var picture = row[9].ToString(); var stars = Convert.ToInt32(row[10]); var locationId = Convert.ToInt32(row[11]); return(HotelBuilder.Create() .IdentifiedBy(id) .WithName(name) .WithAmountOfRooms(amountOfRooms) .WithCapacityPerRoom(roomCapacity) .WithPricePerRoom(pricePerRoom) .WithPhone(phone) .WithWebsite(website) .WithStars(stars) .WithPictureUrl(picture) .LocatedAt(locationId) .WithStatus(isActive) .WithAddressDescription(addressSpecs) .Build()); }
public static void MyClassInitialize(TestContext testContext) { rooms = new List <Room>(); rooms.Add(new ElevatorShaft(0, new Point(0, 0))); rooms.Add(new ElevatorShaft(1, new Point(0, 1))); rooms.Add(new ElevatorShaft(2, new Point(0, 2))); rooms.Add(new Lobby(3, new Point(1, 0), new Point(1, 1))); rooms.Add(new Lobby(4, new Point(2, 0), new Point(1, 1))); rooms.Add(new Lobby(5, new Point(3, 0), new Point(1, 1))); rooms.Add(new Lobby(6, new Point(4, 0), new Point(1, 1))); rooms.Add(new Staircase(7, new Point(5, 0))); rooms.Add(new Staircase(8, new Point(5, 1))); rooms.Add(new Staircase(9, new Point(5, 2))); for (int i = 1; i < 5; i++) { for (int j = 1; j < 3; j++) { rooms.Add(new GuestRoom(j * i + 9, new Point(i, j), new Point(1, 1), 1)); } } HotelBuilder builder = new HotelBuilder(); foreach (Room r in rooms) { builder.PlaceRoom(r); } }
public void PoolRoomOverload() { HotelBuilder hb = new HotelBuilder(); hb.RoomFactory.RegisterComponent("Pool", new PoolFactoryComponent()); Assert.IsTrue(hb.RoomFactory.BuildRoom(-1, "Pool", new Point(0, 0), new Point(1, 1)) is Pool); }
public HotelTest() { if (ServiceLocator.Get <ConfigLoader>() == null) { ServiceLocator.Add <ConfigLoader>(new ConfigLoader("")); } rooms = new List <Room>(); rooms.Add(new EmptyRoom(-1, new Point(-1, 0), new Point(1, 1))); (rooms[0] as EmptyRoom).Entrance = true; rooms.Add(new ElevatorShaft(0, new Point(0, 0))); rooms.Add(new ElevatorShaft(1, new Point(0, 1))); rooms.Add(new ElevatorShaft(2, new Point(0, 2))); rooms.Add(new Lobby(3, new Point(1, 0), new Point(1, 1))); rooms.Add(new Lobby(4, new Point(2, 0), new Point(1, 1))); rooms.Add(new Lobby(5, new Point(3, 0), new Point(1, 1))); rooms.Add(new Lobby(6, new Point(4, 0), new Point(1, 1))); rooms.Add(new Staircase(7, new Point(5, 0))); rooms.Add(new Staircase(8, new Point(5, 1))); rooms.Add(new Staircase(9, new Point(5, 2))); for (int i = 1; i < 5; i++) { for (int j = 1; j < 3; j++) { rooms.Add(new GuestRoom(j * i + 9, new Point(i, j), new Point(1, 1), 1)); } } HotelBuilder builder = new HotelBuilder(); foreach (Room r in rooms) { builder.PlaceRoom(r); } }
private static Structure CreateHotel() { StructureBuilder HotelBuilder = new HotelBuilder(); Director dir = new Director(); Structure Hotel = dir.GenerateStructure(HotelBuilder); Console.WriteLine("A hotel was created."); Console.WriteLine(); return(Hotel); }
public void Deveria_cadastrar_reserva_com_um_clientes() { var hotel = HotelBuilder.Start().Build(); var customer = CustomerBuilder.Start().Build(); var hotelReservation = HotelReservationBuilder.Start().WithHotel(hotel).WithCustomer(customer).Build(); var result = hotelReservation.CanRegister(); result.Should().Be("Cadastro validado"); }
public void FitnessBuilding() { HotelBuilder hb = new HotelBuilder(); hb.RoomFactory.RegisterComponent("Fitness", new FitnessFactoryComponent()); Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("ID", "1"); data.Add("AreaType", "Fitness"); data.Add("Position", "1,1"); data.Add("Dimension", "2,2"); Assert.IsTrue(hb.RoomFactory.BuildRoom(data) is Fitness); }
public void EmptyBuilding() { HotelBuilder hb = new HotelBuilder(); hb.RoomFactory.RegisterComponent("Empty", new EmptyRoomFactoryComponent()); Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("ID", "1"); data.Add("AreaType", "Empty"); data.Add("Position", "1,1"); data.Add("Dimension", "1,1"); Assert.IsTrue(hb.RoomFactory.BuildRoom(data) is EmptyRoom); }
public void CinemaBuilding() { HotelBuilder hb = new HotelBuilder(); hb.RoomFactory.RegisterComponent("Cinema", new CinemaFactoryComponent()); Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("ID", "1"); data.Add("AreaType", "Cinema"); data.Add("Position", "2,2"); data.Add("Dimension", "2,2"); Assert.IsTrue(hb.RoomFactory.BuildRoom(data) is Cinema); }
public void Setup() { _hotel = HotelBuilder.Create() .WithName("Hotel Cagua") .WithAmountOfRooms(2000) .WithCapacityPerRoom(2) .WithPricePerRoom(200) .WithPhone("04243240208") .WithWebsite("HC.com") .WithStars(2) .LocatedAt(HotelTestSetup.LOCATION_ID) .WithStatus(true) .WithAddressDescription("Calle Los Almendrones") .WithPictureUrl("alguncodigoenbase64") .Build(); }
public void RestaurantBuilding() { HotelBuilder hb = new HotelBuilder(); hb.RoomFactory.RegisterComponent("Restaurant", new CafeFactoryComponent()); Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("ID", "1"); data.Add("AreaType", "Restaurant"); data.Add("Position", "1,1"); data.Add("Dimension", "1,2"); data.Add("Capacity", "4"); Assert.IsTrue(hb.RoomFactory.BuildRoom(data) is Cafe); }
public void GuestRoomBuilding() { HotelBuilder hb = new HotelBuilder(); hb.RoomFactory.RegisterComponent("Room", new GuestRoomFactoryComponent()); Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("ID", "1"); data.Add("AreaType", "Room"); data.Add("Position", "1,1"); data.Add("Dimension", "1,1"); data.Add("Classification", "1 Star"); Assert.IsTrue(hb.RoomFactory.BuildRoom(data) is GuestRoom); }
public void HotelBuider_RequiredAttributeException() { Assert.Throws <RequiredAttributeException>(() => { _hotel = HotelBuilder.Create() .WithName("Hotel herick") .WithAmountOfRooms(2000) .WithCapacityPerRoom(2) .WithPricePerRoom(200) .WithPhone("04243240208") .WithWebsite("HC.com") .WithStars(2) .LocatedAt(0) .Build(); }); }
public void Nao_deveria_cadastrar_reserva_com_cliente_ja_cadastrado(int value1, int value2) { var customerRegistered = CustomerBuilder.Start().WithName("Dienisson").Build(); var hotelReservationRegistered = HotelReservationBuilder.Start().WithCustomer(customerRegistered).Build(); var hotel = HotelBuilder.Start().WithHotelReservation(hotelReservationRegistered).Build(); var customer = CustomerBuilder.Start().WithId(value1).WithName("Dienisson").Build(); var customeTwo = CustomerBuilder.Start().WithId(value2).Build(); var hotelReservationTwho = HotelReservationBuilder.Start() .WithCustomer(customer) .WithCustomer(customeTwo) .WithHotel(hotel) .Build(); var result = hotelReservationTwho.CanRegister(); result.Should().Be("Vaga já cadastrado: Dienisson"); }
public static Hotel CreateHotel(int id, string name, int amountOfRooms, int roomCapacity, bool isActive, string addressSpecs, decimal pricePerRoom, string website, string phone, string picture, int stars, int locationId) { return(HotelBuilder.Create() .IdentifiedBy(id) .WithName(name) .WithAmountOfRooms(amountOfRooms) .WithCapacityPerRoom(roomCapacity) .WithPricePerRoom(pricePerRoom) .WithPhone(phone) .WithWebsite(website) .WithStars(stars) .WithPictureUrl(picture) .LocatedAt(locationId) .WithStatus(isActive) .WithAddressDescription(addressSpecs) .BuildSinVaidar()); }
public static void PopulateTestData(eFlightDbContext dbContext) { var flight = FlightBuilder.Start().WithVacancies(40).Build(); var hotel = HotelBuilder.Start().Build(); var car = CarBuilder.Start().Build(); var travelPackage = TravelPackageBuilder.Start().Build(); dbContext.Flight.Add(flight); dbContext.Hotel.Add(hotel); dbContext.Car.Add(car); dbContext.TravelPackage.Add(travelPackage); dbContext.FlightReservation.Add(FlightReservationBuilder.Start().WithFlight(flight).Build()); dbContext.HotelReservation.Add(HotelReservationBuilder.Start().WithHotel(hotel).Build()); dbContext.CarReservation.Add(CarReservationBuilder.Start().WithCar(car).Build()); dbContext.TravelPackageReservation.Add(TravelPackageReservationBuilder.Start().WithTravelPackage(travelPackage).Build()); dbContext.SaveChanges(); }
public async void Test_Flight_Controller_GetAsync_ShouldBeOk() { //arrange int expectedCount = 1; List <Hotel> hotels = new List <Hotel>() { HotelBuilder.Start().Build() }; _fakeMediator.Setup(mdtr => mdtr.Send(It.IsAny <HotelLoadAllQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(hotels); //action var callback = await _controller.Get(); //assert var response = callback.Should().BeOfType <List <Hotel> >().Subject; response.Count.Should().Be(expectedCount); }
public void Setup() { _hotelsController = new HotelsController(null); _insertedHotels = new List <int>(); _hotelentity = HotelBuilder.Create() .WithName("Hotel Cagua") .WithAmountOfRooms(2000) .WithCapacityPerRoom(2) .WithPricePerRoom(200) .WithPhone("04243240208") .WithWebsite("HC.com") .WithStars(2) .LocatedAt(HotelTestSetup.LOCATION_ID) .WithStatus(true) .WithAddressDescription("Calle Los Almendrones") .WithPictureUrl("alguncodigoenbase64") .Build(); HotelMapper _HotelMapper = MapperFactory.createHotelMapper(); _hotel = _HotelMapper.CreateDTO(_hotelentity); }
public PersonTest() { if (ServiceLocator.Get <ConfigLoader>() == null) { ServiceLocator.Add <ConfigLoader>(new ConfigLoader("")); } if (rooms != null) { return; } rooms = new List <Room>(); rooms.Add(new ElevatorShaft(0, new Point(0, 0))); rooms.Add(new ElevatorShaft(1, new Point(0, 1))); rooms.Add(new ElevatorShaft(2, new Point(0, 2))); rooms.Add(new Lobby(3, new Point(1, 0), new Point(1, 1))); rooms.Add(new Lobby(4, new Point(2, 0), new Point(1, 1))); rooms.Add(new Lobby(5, new Point(3, 0), new Point(1, 1))); rooms.Add(new Lobby(6, new Point(4, 0), new Point(1, 1))); rooms.Add(new Staircase(7, new Point(5, 0))); rooms.Add(new Staircase(8, new Point(5, 1))); rooms.Add(new Staircase(9, new Point(5, 2))); for (int i = 1; i < 5; i++) { for (int j = 1; j < 3; j++) { rooms.Add(new GuestRoom(j * (i + 1) + 9, new Point(i, j), new Point(1, 1), 1)); } } HotelBuilder builder = new HotelBuilder(); foreach (Room r in rooms) { builder.PlaceRoom(r); } }
public void BuildHotel() { ServiceLocator.Remove <ConfigLoader>(); // This test requires a config file to work. // Make sure there is a config file present! ServiceLocator.Add <ConfigLoader>(new ConfigLoader(@"C:\Users\Thom\Source\Repos\ThemeHotelHHS\Hotel Simulator Debug\Config.cfg")); HotelBuilder hb = new HotelBuilder(); // Register components to the roomfactory hb.RoomFactory.RegisterComponent("Room", new GuestRoomFactoryComponent()); hb.RoomFactory.RegisterComponent("Cinema", new CinemaFactoryComponent()); hb.RoomFactory.RegisterComponent("Restaurant", new CafeFactoryComponent()); hb.RoomFactory.RegisterComponent("Empty", new EmptyRoomFactoryComponent()); hb.RoomFactory.RegisterComponent("Lobby", new LobbyFactoryComponent()); hb.RoomFactory.RegisterComponent("ElevatorShaft", new ElevatorShaftFactoryComponent()); hb.RoomFactory.RegisterComponent("Staircase", new StaircaseFactoryComponent()); hb.RoomFactory.RegisterComponent("Fitness", new FitnessFactoryComponent()); hb.RoomFactory.RegisterComponent("Pool", new PoolFactoryComponent()); List <Room> hotel = hb.BuildHotel(); Assert.IsNotNull(hotel); }
public void RunFailedBuild() { HotelBuilder hb = new HotelBuilder(); Assert.IsTrue(hb.RoomFactory.BuildRoom(-1, "kaas", new Point(0, 0), new Point(1, 1)) == null); }
public void HotelBuilderConstructor() { HotelBuilder hb = new HotelBuilder(); Assert.IsNotNull(hb); }