public Order GetOrder(int id) { string query = $"SELECT * FROM Orders WHERE ID={id}"; DataTable dt = cdb.execute(query); Order tempOrder = new Order(); DataTableReader reader = new DataTableReader(dt); while (reader.Read()) { int tempId = Convert.ToInt32(reader["OrderID"]); DateTime tempOrderDate = (DateTime)reader["OrderDate"]; DateTime tempDeliverDate = (DateTime)reader["DeliverDate"]; int tempBikeId = Convert.ToInt32(reader["ID"]); string tempDescription = (string)reader["BikeDescription"]; BikeKind tempKind = (BikeKind)reader["Kind"]; decimal tempPricePerDay = (decimal)reader["PricePerDay"]; int tempRenteeId = Convert.ToInt32(reader["ID"]); string tempName = (string)reader["Name"]; string tempPhoneNumber = (string)reader["PhoneNumber"]; string tempPhysAddress = (string)reader["PhysAddress"]; DateTime tempRegisterDate = (DateTime)reader["RegisterDate"]; Rentee tempRentee = new Rentee(tempName, tempPhysAddress, tempPhoneNumber, tempRegisterDate, tempId); Bike tempBike = new Bike(tempPricePerDay, tempDescription, tempKind, tempId); tempOrder = new Order(tempBike, tempRentee, tempOrderDate, tempDeliverDate, tempId); } return(tempOrder); }
public Bike(decimal pricePerDay, string bikeDescription, BikeKind kind, int id) { this.pricePerDay = pricePerDay; this.bikeDescription = bikeDescription; this.kind = kind; this.id = id; }
//Constructors public Bike(int iD, BikeKind kind, string bikeDescription, decimal pricePerDay) { ID = iD; Kind = kind; BikeDescription = bikeDescription; PricePerDay = pricePerDay; }
public void ConstructorTest() { // ARRANGE int id = 1; // Used for constructors (bik, rentee, order) DateTime rentDate = new DateTime(); DateTime deliveryDate = new DateTime(); // Creates Bike object for the constructor decimal pricePerDay = 20.5M; string bikeDescription = "Some description of the bike"; BikeKind kind = BikeKind.Mountain; Bike bike = new Bike(pricePerDay, bikeDescription, kind, id); // Creates Rentee object for the constructor string name = "John Doe"; string address = "StreetName 101"; string phoneNumber = "12345678"; DateTime registerDate = new DateTime(); Rentee rentee = new Rentee(name, address, phoneNumber, registerDate, id); // ACT Order order = new Order(bike, rentee, rentDate, deliveryDate, id); Bike actualBike = order.Bike; Rentee actualRentee = order.Rentee; DateTime actualRentDate = order.RentDate; DateTime actualDeliveryDate = order.DeliveryDate; int actualId = order.Id; // ASSERT Assert.IsNotNull(order, "Order is null"); Assert.AreEqual(bike, actualBike, "Bike not equal"); Assert.AreEqual(rentee, actualRentee, "Rentee not equal"); Assert.AreEqual(rentDate, actualRentDate, "RentDate not equal"); Assert.AreEqual(deliveryDate, actualDeliveryDate, "DeliveryDate not equal"); }
public ObservableCollection <Order> GetAllOrders() { string query = $"SELECT Orders.OrderID, Orders.OrderDate, Orders.DeliverDate, Bikes.ID, Bikes.Kind, Bikes.PricePerDay, Bikes.BikeDescription, Renters.ID, Renters.Name, Renters.PhoneNumber, Renters.PhysAddress, Renters.RegisterDate FROM Bikes INNER JOIN Orders ON Bikes.ID = Orders.BikeID INNER JOIN Renters ON Orders.RenteeID = Renters.ID"; DataTable dt = cdb.execute(query); ObservableCollection <Order> OCOrder = new ObservableCollection <Order>(); DataTableReader reader = new DataTableReader(dt); while (reader.Read()) { int tempId = Convert.ToInt32(reader["OrderID"]); DateTime tempOrderDate = (DateTime)reader["OrderDate"]; DateTime tempDeliverDate = (DateTime)reader["DeliverDate"]; int tempBikeId = Convert.ToInt32(reader["ID"]); string tempDescription = (string)reader["BikeDescription"]; BikeKind tempKind = (BikeKind)reader["Kind"]; decimal tempPricePerDay = (decimal)reader["PricePerDay"]; int tempRenteeId = Convert.ToInt32(reader["ID"]); string tempName = (string)reader["Name"]; string tempPhoneNumber = (string)reader["PhoneNumber"]; string tempPhysAddress = (string)reader["PhysAddress"]; DateTime tempRegisterDate = (DateTime)reader["RegisterDate"]; Rentee tempRentee = new Rentee(tempName, tempPhysAddress, tempPhoneNumber, tempRegisterDate, tempId); Bike tempBike = new Bike(tempPricePerDay, tempDescription, tempKind, tempId); Order tempOrder = new Order(tempBike, tempRentee, tempOrderDate, tempDeliverDate, tempId); OCOrder.Add(tempOrder); } return(OCOrder); }
public void GetPriceTest() { // ARRANGE int id = 1; // Used for constructors (bik, rentee, order) // Creates Bike object decimal pricePerDay = 20.5M; string bikeDescription = "Some description of the bike"; BikeKind kind = BikeKind.Mountain; Bike bike = new Bike(pricePerDay, bikeDescription, kind, id); // Creates Rentee object string name = "John Doe"; string address = "StreetName 101"; string phoneNumber = "12345678"; DateTime registerDate = new DateTime(); Rentee rentee = new Rentee(name, address, phoneNumber, registerDate, id); // Creates Order object DateTime rentDate = new DateTime(2018, 1, 1); DateTime deliveryDate = new DateTime(2018, 1, 5); Order order = new Order(bike, rentee, rentDate, deliveryDate, id); TimeSpan daysRented = deliveryDate - rentDate; decimal expected = (pricePerDay * daysRented.Days); // ACT decimal actual = order.GetPrice(); // ASSERT Assert.AreEqual(expected, actual, "Price not equal"); }
public void ToStringTest() { // ARRANGE int id = 1; // Used for constructors (bik, rentee, order) // Creates Bike object decimal pricePerDay = 20.5M; string bikeDescription = "Some description of the bike"; BikeKind kind = BikeKind.Mountain; Bike bike = new Bike(pricePerDay, bikeDescription, kind, id); // Creates Rentee object string name = "John Doe"; string address = "StreetName 101"; string phoneNumber = "12345678"; DateTime registerDate = new DateTime(); Rentee rentee = new Rentee(name, address, phoneNumber, registerDate, id); // Creates Order object DateTime rentDate = new DateTime(2018, 1, 1); DateTime deliveryDate = new DateTime(2018, 1, 5); Order order = new Order(bike, rentee, rentDate, deliveryDate, id); string expected = $"Bike: {order.Bike.Kind}, Rentee: {order.Rentee.Name}, Rent Date: {order.RentDate.Date}, Delivery Date: {order.DeliveryDate.Date}, ID: {order.Id}"; // ACT string actual = order.ToString(); // ASSERT Assert.AreEqual(expected, actual, "String not equal"); }
public Bike(decimal pPerDay, string desc, BikeKind kind, int id) { PricePerDay = pPerDay; BikeDescription = desc; Kind = kind; Id = id; }
public Bike(decimal pricePerDay, string bikeDesc, BikeKind kind, int id) { PricePerDay = pricePerDay; BikeDesc = bikeDesc; Kind = kind; ID = id; }
public Bike(decimal pricePerDay, string bikeDescription, BikeKind kind, int id) { PricePerDay = pricePerDay; BikeDescription = bikeDescription; Kind = kind; Id = id; }
public Bike GetBike(int id) { string query = $"SELECT * FROM Bikes WHERE ID={id}"; DataTable dt = cdb.execute(query); Bike tempBike = new Bike(); DataTableReader reader = new DataTableReader(dt); while (reader.Read()) { int tempId = Convert.ToInt32(reader["ID"]); string tempDescription = (string)reader["BikeDescription"]; BikeKind tempKind = (BikeKind)reader["Kind"]; decimal tempPricePerDay = (decimal)reader["PricePerDay"]; tempBike = new Bike(tempPricePerDay, tempDescription, tempKind, tempId); } return(tempBike); }
public void ToStringTest() { // ARRANGE decimal pricePerDay = 20.5M; string bikeDescription = "Some description of the bike"; BikeKind kind = BikeKind.Mountain; int id = 1; Bike bike = new Bike(pricePerDay, bikeDescription, kind, id); string expected = $"Kind: {kind}, Description: {bikeDescription}, Price: {pricePerDay}, ID: {id}"; // ACT string actual = bike.ToString(); // ASSERT Assert.AreEqual(expected, actual, "String not equal"); }
public ObservableCollection <Bike> GetAllBikes() { string query = $"SELECT * FROM Bikes"; DataTable dt = cdb.execute(query); ObservableCollection <Bike> OCBike = new ObservableCollection <Bike>(); DataTableReader reader = new DataTableReader(dt); while (reader.Read()) { int tempId = Convert.ToInt32(reader["ID"]); string tempDescription = (string)reader["BikeDescription"]; BikeKind tempKind = (BikeKind)reader["Kind"]; decimal tempPricePerDay = (decimal)reader["PricePerDay"]; Bike tempBike = new Bike(tempPricePerDay, tempDescription, tempKind, tempId); OCBike.Add(tempBike); } return(OCBike); }
public void ConstructorTest() { // ARRANGE decimal pricePerDay = 20.5M; string bikeDescription = "Some description of the bike"; BikeKind kind = BikeKind.Mountain; int id = 1; // ACT Bike bike = new Bike(pricePerDay, bikeDescription, kind, id); decimal actualPricePerDay = bike.PricePerDay; string actualBikeDescription = bike.BikeDescription; BikeKind actualKind = bike.Kind; int actualId = bike.Id; // ASSERT Assert.IsNotNull(bike, "Bike is null"); Assert.AreEqual(pricePerDay, actualPricePerDay, "PricePerDay not equal"); Assert.AreEqual(bikeDescription, actualBikeDescription, "BikeDescription not equal"); Assert.AreEqual(kind, actualKind, "Kind not equal"); Assert.AreEqual(id, actualId, "Id not equal"); }
public Bike(BikeKind kind, string bikeDescription, decimal pricePerDay) { Kind = kind; BikeDescription = bikeDescription; PricePerDay = pricePerDay; }