private void confirmButton_Click(object sender, EventArgs e) { RentItem item = (RentItem)RentBox.SelectedItem; DateTime newDate = item.expireDate.AddDays((int)extraDays.Value); String conString = @"Data Source=SHERIF\SQLEXPRESS;Initial Catalog=PopCornia;Persist Security Info=True;User ID=sa;Password=123456"; SqlConnection connection = new SqlConnection(conString); connection.Open(); SqlCommand query = new SqlCommand(); query.CommandText = "UPDATE Rents SET ExpireDate = '" + newDate + "', Paid = '" + (item.Price + (int)extraDays.Value * 4) + "'WHERE User_ID = '" + ID + "' AND Movie_ID = '" + item.Key + "';"; query.Connection = connection; query.CommandType = CommandType.Text; if (query.ExecuteNonQuery() != 0) { int MoneyLeft = (int)(item.expireDate.Date - DateTime.Now.Date).TotalDays * 4; MessageBox.Show("Extended \"" + item.Name + "\" Successfully, new Expire Date: " + newDate.ToShortDateString() + ", Extra paid: " + (int)extraDays.Value * 4 + "$"); } else { MessageBox.Show("Error"); } extraMoney.ResetText(); label20.Visible = false; extraDays.Visible = false; extraMoney.Visible = false; confirmButton.Visible = false; ExtendButton.Enabled = true; DeleteRent.Enabled = true; updateRentBox(); }
public void CallsREpostitoryAddWithCorrectRentItemWithAnImageInImageList() { //Arrange var mockeRepository = new Mock <IGenericEfRepository <RentItem> >(); mockeRepository.Setup(x => x.Add(It.IsAny <RentItem>())).Verifiable(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapingService>(); var rentItemStub = new RentItem(); var imageStub = new Image(); mockedMapper.Setup(x => x.Map <RentItem>(It.IsAny <RentItemDtoModel>())).Returns(rentItemStub); mockedMapper.Setup(x => x.Map <Image>(It.IsAny <ImagesDtoModel>())).Returns(imageStub); mockedMapper.Setup(x => x.Map <RentItem>(It.IsAny <RentItemDtoModel>())).Returns(rentItemStub); var rentItemService = new RentItemService(mockeRepository.Object, mockedUnitOfWork.Object, mockedMapper.Object); var imagesListWithAnImage = new List <ImagesDtoModel>() { new ImagesDtoModel() }; //Act rentItemService.Add(new RentItemDtoModel(), imagesListWithAnImage); rentItemStub.Images.Add(imageStub); //Assert mockeRepository.Verify(x => x.Add(It.Is <RentItem>(y => y.Equals(rentItemStub))), Times.Once); }
public void RentItem2()//ctor { Journal journal = new Journal("mark", 7, "sfari", 56, "04/07/2010", "lll", 0); RentItem rent = new RentItem(journal); Assert.IsNotNull(rent.RentedItem); }
public RentItemInput(RentItem rentItem) { Quantity = rentItem.quantity; LaptopId = rentItem.laptopId; Laptop = rentItem.laptop; RentId = rentItem.rentId; Rent = rentItem.rent; }
public ExtendRentForm(RentItem rent) { InitializeComponent(); _rentsRepository = new SqlRentsRepository(_connString); // Accept parameter. _rent = rent; }
public void UpdateReturn() { Journal journal = new Journal("mark", 7, "sfari", 56, "04/07/2010", "lll", 0); User user = new User("mushky", "kkk", "0586191191", "lod", "02/02/1997", CodeOccupation.Customer); RentItem rent = new RentItem(journal); user.UpdateRent(rent); user.UpdateReturn(rent); Assert.IsTrue(user.RentedItems.Count == 0); }
public IEnumerable <RentItem> SelectAll() { var rents = new List <RentItem>(); // Get data from database. using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandType = CommandType.Text; command.CommandText = getAllRentsQuery; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var rentItem = new RentItem() { Id = (int)reader["Id"], Customer = new Customer() { Id = (int)reader["CustomerId"], FirstName = (string)reader["CustomerFirstName"], LastName = (string)reader["CustomerLastName"], Phone = (string)reader["CustomerPhone"] }, SportsHall = new SportsHall() { Id = (int)reader["ClassId"], Type = new SportsHallType() { Id = (int)reader["ClassTypeId"], Name = (string)reader["ClassName"] }, Area = (int)reader["ClassArea"], Rate = (decimal)reader["ClassRate"] }, DateStart = (DateTime)reader["DateStart"], DateEnd = (DateTime)reader["DateEnd"], Cost = (decimal)reader["Cost"], Deleted = (bool)reader["Deleted"] }; rents.Add(rentItem); } } } } return(rents); }
public RentItem GetRentById(int rentId) { var rents = new List <RentItem>(); using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandType = CommandType.Text; command.CommandText = getRentByIdQuery; command.Parameters.AddWithValue("@rentId", rentId); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var rentItem = new RentItem() { Id = (int)reader["Id"], Customer = new Customer() { Id = (int)reader["CustomerId"], FirstName = (string)reader["CustomerFirstName"], LastName = (string)reader["CustomerLastName"], Phone = (string)reader["CustomerPhone"] }, SportsHall = new SportsHall() { Id = (int)reader["ClassId"], Type = new SportsHallType() { Id = (int)reader["ClassTypeId"], Name = (string)reader["ClassName"] }, Area = (int)reader["ClassArea"], Rate = (decimal)reader["ClassRate"] }, DateStart = (DateTime)reader["DateStart"], DateEnd = (DateTime)reader["DateEnd"], Cost = (decimal)reader["Cost"], Deleted = (bool)reader["Deleted"] }; rents.Add(rentItem); } } } } return((rents.Count > 0) ? rents[0] : null); }
public IEnumerable <RentItem> GetRentsOnDate(DateTime inputDate) { var rents = new List <RentItem>(); using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "spGetRents"; command.Parameters.AddWithValue("@Date", inputDate); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var rentItem = new RentItem() { Id = (int)reader["Id"], Customer = new Customer() { Id = (int)reader["CustomerId"], FirstName = (string)reader["CustomerFirstName"], LastName = (string)reader["CustomerLastName"], Phone = (string)reader["CustomerPhone"] }, SportsHall = new SportsHall() { Id = (int)reader["ClassId"], Type = new SportsHallType() { Id = (int)reader["ClassTypeId"], Name = (string)reader["ClassName"] }, Area = (int)reader["ClassArea"], Rate = (decimal)reader["ClassRate"] }, DateStart = (DateTime)reader["DateStart"], DateEnd = (DateTime)reader["DateEnd"], Cost = (decimal)reader["Cost"], Deleted = (bool)reader["Deleted"] }; rents.Add(rentItem); } } } } return(rents); }
public void SetRentItem_Corectly() { //Arrange var mockedItem = new RentItem(); var sut = new Comment(); //Act sut.Item = mockedItem; //Assert Assert.AreEqual(mockedItem, sut.Item); }
public void SetCorectly() { //Arrange var mockedLocation = "location"; var mockedItem = new RentItem(); var sut = new Image(mockedLocation); //Act sut.RentItem = mockedItem; //Assert Assert.AreEqual(mockedItem, sut.RentItem); }
public void AddNewRentItemToCollection_AndReturnsTheSame() { //Arrange var fixture = new Fixture(); var name = fixture.Create <string>().Substring(0, 10); var category = new Category(name); var item = new RentItem(); //Act category.Items.Add(item); //Assert Assert.AreEqual(item, category.Items.First()); }
public void ReturnsCollectionofImages() { //Arrange& Act var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; var sut = new RentItem(user, category, desciption, location); //Assert Assert.IsInstanceOf <ICollection <Image> >(sut.Images); }
public void ReturnNewInstanceOf_RentItem() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString();; var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; //Act var item = new RentItem(user, category, desciption, location); //Assert Assert.IsInstanceOf <RentItem>(item); }
public void Sets_Owner() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString();; var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; //Act var item = new RentItem(user, category, desciption, location); //Assert Assert.AreEqual(user, item.OwnerId); }
private void buttonForReturn_Click(object sender, RoutedEventArgs e) { if (listBox.SelectedItem != null) { RentItem rentItem = _user.RentedItems[listBox.SelectedIndex]; _user.UpdateReturn(rentItem); MainPage.Items.ReturnItem(rentItem.RentedItem); MessageSuccess(); LoadCombobox(); } else { MessageNoItemChoosen(); } }
public void Initialize_CommentsCollection() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString();; var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; //Act var item = new RentItem(user, category, desciption, location); //Assert Assert.IsNotNull(item.Comments); }
public void SetIsDeletedToFalseAnd_ReturnsFalse() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString();; var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; //Act var item = new RentItem(user, category, desciption, location); //Assert Assert.AreEqual(false, item.IsDeleted); }
public void SetAndGetCorectly() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; var sut = new RentItem(user, category, desciption, location); var mockedOwner = new User(); //Act sut.Owner = mockedOwner; //Assert Assert.AreEqual(mockedOwner, sut.Owner); }
public void SetItemCorectly() { //Arrange var fixture = new Fixture(); var itemId = fixture.Create <Guid>(); var userId = fixture.Create <Guid>(); var startDate = new DateTime(2017, 03, 11); var endDate = new DateTime(2017, 04, 11); var lease = new Lease(itemId, userId, startDate, endDate); var mockedItem = new RentItem(); //Act lease.Item = mockedItem; //Assert Assert.AreEqual(mockedItem, lease.Item); }
public void SetAndGetCorectly() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; var sut = new RentItem(user, category, desciption, location); var mockedAvailableFrom = new DateTime(2017, 03, 20); //Act sut.AvailableFrom = mockedAvailableFrom; //Assert Assert.AreEqual(mockedAvailableFrom, sut.AvailableFrom); }
public void AddComment_AndItIsSame() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var location = "new Location"; var desciption = "random string"; var item = new RentItem(user, category, desciption, location); var comment = new Comment(); //Act item.Comments.Add(comment); //Assert Assert.AreEqual(comment, item.Comments.FirstOrDefault()); }
public void ItemsAndItShouldHaveTheSameItem() { //Arange var fixture = new Fixture(); Guid guid = fixture.Create <Guid>(); var address = fixture.Create <string>().Substring(0, 10); var randomString = fixture.Create <string>().Substring(0, 10); var dateOfbirth = fixture.Create <DateTime>(); var user = new User(randomString, randomString, randomString, dateOfbirth, randomString, address); var item = new RentItem(); //Act user.Items.Add(item); //Assert Assert.AreEqual(item, user.Items.FirstOrDefault()); }
public void ChangeDescription() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; var item = new RentItem(user, category, desciption, location); var newDescription = "new Descripion"; //Act item.Description = newDescription; //Assert Assert.AreEqual(newDescription, item.Description); }
public void IsDeletedToTrue() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var location = "new Location"; var desciption = "random string"; var comment = new Comment(); var item = new RentItem(user, category, desciption, location); //Act item.IsDeleted = true; //Assert Assert.AreEqual(true, item.IsDeleted); }
public void SetAndGetCorectly() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; var sut = new RentItem(user, category, desciption, location); decimal mockedPrice = 10.20M; //Act sut.Price = mockedPrice; //Assert Assert.AreEqual(mockedPrice, sut.Price); }
private void RentBox_SelectedIndexChanged(object sender, EventArgs e) { if (RentBox.SelectedIndex == -1) { clearRentLabels(); return; } RentItem item = (RentItem)RentBox.SelectedItem; rentTitle.Text = item.Name; rentSDate.Text = item.startDate.ToShortDateString(); rentRDate.Text = item.expireDate.ToShortDateString(); rentDaysLeft.Text = (item.expireDate.Date - DateTime.Now.Date).TotalDays.ToString(); rentPrice.Text = item.Price.ToString(); DeleteRent.Enabled = true; ExtendButton.Enabled = true; }
public void AddLease() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var location = "new Location"; var desciption = "random string"; var item = new RentItem(user, category, desciption, location); var lease = new Lease(); //Act item.Leases.Add(lease); //Assert Assert.AreEqual(1, item.Leases.Count()); }
public void SetAndGetCorectly() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "random string"; var item = new RentItem(user, category, desciption, location); var nameMocked = "new Descripion"; //Act item.Name = nameMocked; //Assert Assert.AreEqual(nameMocked, item.Name); }
public void SetDeletedOnAndREturnSameValue() { //Arrange var fixture = new Fixture(); var user = fixture.Create <Guid>().ToString(); var category = fixture.Create <Guid>(); var desciption = "random string"; var location = "new Location"; var item = new RentItem(user, category, desciption, location); var comment = new Comment(); var deletedOn = new DateTime(); //Act item.DeletedOn = deletedOn; //Assert Assert.AreEqual(deletedOn, item.DeletedOn); }