public void Should_GetVenue() { Venue testVenue = new Venue { Id = 1, Address1 = "Addr1", Address2 = "Addr2", Address3 = "Addr3", Address4 = "Addr4", Address5 = "Addr5", Description = "Test", ContactPhone = "01234567898", Image = "", LatLong = "0,0", Name = "Test", Instagram = "inst", Facebook = "fb", Twitter = "tw" }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.Venues.GetById(1)).Returns(testVenue); VenuesController controller = new VenuesController(mock.Object); var venue = controller.GetVenue(1); Assert.IsType <OkObjectResult>(venue); }
public void TestAuthorize_WithValidPremission_ShouldPass() { this.firstUser = new User("Pesho", "sdqwe123", Roles.VenueAdmin); this.venuesController = new VenuesController(this.db, this.firstUser); this.venuesController.Add("Zdrrrrrr", "Zdrrrr", "Nqmam opisanie"); }
public void TestAuthorize_NoSufficientRights_ShouldReturnException() { var database = new HotelBookingSystemData(); var controller = new VenuesController(database, new User("No admin", "admina", Roles.User)); controller.Add("No name", "No address", "No description"); }
public void TestAuthorize_ValidUser_ShouldPass() { var database = new HotelBookingSystemData(); var controller = new VenuesController(database, new User("No admin", "admina", Roles.VenueAdmin)); controller.Add("No name", "No address", "No description"); }
public void Authorize_ValidUser_ShouldPass() { var user = new User("admin", "123456", Roles.VenueAdmin); var controller = new VenuesController(this.data, user); controller.Add("nqma ime", "nqma adres", "nqma opisanie"); }
private async void BtnSaveChanges_Click(object sender, EventArgs e) { VenuesController vCtrl = new VenuesController(); DashboardGUI dGUI = DashboardGUI.Instance; if (TextBoxesHasValues()) { if (create) { Venue newVenue = new Venue { Name = tbName.Text, Address = tbAddress.Text, Zip = Int32.Parse(tbZip.Text), City = tbCity.Text }; await vCtrl.Create(newVenue); this.Visible = false; dGUI.AddVenueStats(); } else if (!create) { MessageBox.Show("Method not implemented"); this.Visible = false; /*int id = editedVenue.Id; * //Venue changedVenue = new Venue { Id = Int32.Parse(tbVenueID.Text), Name = tbName.Text, Address = tbAddress.Text, Zip = Int32.Parse(tbZip.Text), City = tbCity.Text }; * Venue updatedVenue = await vCtrl.Get(editedVenue.Id); * await vCtrl.Update(updatedVenue.Id, updatedVenue); * this.Visible = false;*/ } } else { MessageBox.Show("Error...One or more fields are empty!");; } }
public void TestAuthorize_WithoutLoggedUser_ShouldThrowException() { this.firstUser = null; this.venuesController = new VenuesController(this.db, this.firstUser); this.venuesController.Add("Zdrrrrrr", "Zdrrrr", "Nqmam opisanie"); }
public void ShouldNot_PostVenue_ModelStateError() { Venue testVenue = new Venue { Id = 1, Address1 = "Addr1", Address2 = "Addr2", Address3 = "Addr3", Address4 = "Addr4", Address5 = "Addr5", Description = "Test", ContactPhone = "01234567898", Image = "", LatLong = "0,0", Name = "Test", Instagram = "inst", Facebook = "fb", Twitter = "tw" }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.Venues.Create(testVenue)).Returns(true); mock.Setup(f => f.Venues.GetById(1)).Returns(testVenue); VenuesController controller = new VenuesController(mock.Object); controller.ModelState.AddModelError("TestError", "Error"); var venues = controller.PostVenue(testVenue); Assert.IsType <BadRequestObjectResult>(venues); }
public void TestAuthorize_WithInvalidPremission_ShouldThrowException() { this.firstUser = new User("Pesho", "sdqwe123", Roles.User); this.venuesController = new VenuesController(this.db, this.firstUser); this.venuesController.Add("Zdrrrrrr", "Zdrrrr", "Nqmam opisanie"); }
public void AuthorizedUserCannotAddVenueIfHeIsNotAdminnistrator() { var user = new User("user12", "user12", Roles.User); var data = new HotelBookingSystemData(); var controller = new VenuesController(data, user); var view = controller.Add("venue one", "address one", "description one"); }
public void TestAuthorize_NoSufficientRights_ShouldPass() { var database = new HotelBookingSystemData(); var controller = new VenuesController(database, new User("Alex123", "alexredis", Roles.VenueAdmin)); controller.Add("No name", "Sofia", "Omg"); }
public void ShouldNot_PutVenue_IdMismatch() { Venue testVenue = new Venue { Id = 1, Address1 = "Addr1", Address2 = "Addr2", Address3 = "Addr3", Address4 = "Addr4", Address5 = "Addr5", Description = "Test", ContactPhone = "01234567898", Image = "", LatLong = "0,0", Name = "Test", Instagram = "inst", Facebook = "fb", Twitter = "tw" }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.Venues.Update(testVenue)).Returns(true); VenuesController controller = new VenuesController(mock.Object); var venues = controller.PutVenue(2, testVenue); Assert.IsType <BadRequestResult>(venues); }
public void TestAuthorize_NotLoggedUser_ShouldReturnException() { var database = new HotelBookingSystemData(); var controller = new VenuesController(database, null); controller.Details(1); }
public async void Edit() { TablePackagesController tpCtrl = new TablePackagesController(); VenuesController vCtrl = new VenuesController(); tablePackagesGUI = TablePackagesGUI.Instance; try { editedTablePackage = await tpCtrl.Get(tablePackagesGUI.idFromTable); // Finding venue from venueID on table and adding it to combobox. Venue venue = await vCtrl.Get(editedTablePackage.VenueId); // Creating a list because combobox demands it. var venuesList = new List <Venue>(); venuesList.Add(venue); lblTitle.Text = "Edit Table Package"; create = false; BtnSaveChanges.Text = "Save changes"; tbName.Text = editedTablePackage.Name; tbPrice.Text = "" + editedTablePackage.Price; cbVenue.DataSource = venuesList; } catch (Exception) { MessageBox.Show("No connection to service"); this.Visible = false; } // Resetting idFromTable to remove possibility to show other employees tables tablePackagesGUI.idFromTable = -1; }
public void Authorize_NoSufficientRights_ShouldThrow() { var user = new User("admin", "123456", Roles.User); var controller = new VenuesController(this.data, user); controller.Add("nqma ime", "nqma adres", "nqma opisanie"); }
public void ViewAll_NoVenuesWithLoggedUserAndNoData_ShouldReturnExpectedMessage() { var user = new User(UsernameOne, PasswordOne, Roles.User); var venuesController = new VenuesController(null, user); var view = venuesController.All(); }
public void WhenVenueGroningenIsRegistrated(string nameVenue) { VenuesController.Create(new VenueViewModel { DisplayName = nameVenue, Code = nameVenue }); }
public void GivenVenueAlmereExists(string nameVenue) { VenuesController.Create(new VenueViewModel { DisplayName = nameVenue, Code = nameVenue }); }
public void AllVenues_NoVenues_CorrectReturnString() { var user = new User("admin", "123456", Roles.VenueAdmin); var controller = new VenuesController(this.data, user); string expectedResult = Constants.NoVenuesToShowMsg; var result = controller.All().Display(); Assert.AreEqual(expectedResult, result); }
public void TestAllVenuesWithoutVenuesCorrectReturnString() { const string expected = "There are currently no venues to show."; var database = new HotelBookingSystemData(); var controller = new VenuesController(database, null); var result = controller.All().Display(); Assert.AreEqual(expected, result); }
public void TestAll_WithPresentVenuesAndInvalidPremissions_ShouldThrowException() { this.user = new User("Pesho", "asdasd", Roles.User); this.venuesController = new VenuesController(this.data, this.user); this.venuesController.Add("Venu1", "Address1", "No Description"); this.venuesController.Add("Venu2", "Address2", "No Description"); this.venuesController.Add("Venu2", "Address2", "No Description"); }
public void GivenAVenueNamedNAME(string name) { var model = new VenueViewModel { Code = name, DisplayName = name }; VenuesController.Create(model); }
public void GetAllVanuesWithoutDataMustReturnNoVanues() { var user = new User("admin1", "admin1", Roles.VenueAdmin); var data = new HotelBookingSystemData(); var controller = new VenuesController(data, user); var vanues = controller.All(); var expected = "There are currently no venues to show."; Assert.AreEqual(expected, vanues.Display()); }
public void Index_HasCorrectModelType_VenueList() { //Arrange ViewResult indexView = new VenuesController().Index() as ViewResult; //Act var result = indexView.ViewData.Model; //Assert Assert.IsTrue(result.GetType() == typeof(List <Venue>)); Assert.IsInstanceOfType(result, typeof(List <Venue>)); }
public void AllVenues_WithVenues_CorrectReturnString() { var user = new User("admin", "123456", Roles.VenueAdmin); var controller = new VenuesController(this.data, user); controller.Add("New venue", "Sofia", "nqma opisanie"); var expectedResult = "*[1] New venue, located at Sofia" + Environment.NewLine + "Free rooms: 0"; var result = controller.All().Display(); Assert.AreEqual(expectedResult, result); }
public void ViewAll_VenuesWithNotLoggedInUser_ShouldReturnExpectedMessage() { var data = new HotelBookingSystemData(); var venuesController = new VenuesController(data, null); var view = venuesController.All(); string actualResult = view.Display(); var expectedResult = "There are currently no venues to show."; Assert.AreEqual(expectedResult, actualResult, "All venues did not return expected view!"); }
public void TestAll_WithoutVenues_ShouldReturnErrorMessage() { const string ExpectedErrorMessage = "There are currently no venues to show."; this.user = new User("Pesho", "asdasd", Roles.User); this.venuesController = new VenuesController(this.data, this.user); var view = this.venuesController.All(); var result = view.Display(); Assert.AreEqual(ExpectedErrorMessage, result, "The view did not returned the expected error message"); }
public void ViewAll_NoVenuesWithLoggedUser_ShouldReturnExpectedMessage() { var data = new HotelBookingSystemData(); var user = new User(UsernameOne, PasswordOne, Roles.User); var venuesController = new VenuesController(data, user); var view = venuesController.All(); string actualResult = view.Display(); var expectedResult = "There are currently no venues to show."; Assert.AreEqual(expectedResult, actualResult, "All venues did not return expected view!"); }
public void ThenWeHaveTheFollowingVenues(Table table) { var viewResult = (ViewResult)VenuesController.Index(); var viewModel = (IEnumerable <VenueViewModel>)viewResult.Model; var venues = viewModel.ToList(); var expectedVenues = table.CreateSet <VenueViewModel>().ToList(); // TODO assert expected equals actual venues.Should().BeEquivalentTo(expectedVenues, options => options .WithStrictOrdering() .Including(model => model.DisplayName) ); }
public void ShouldNot_DeleteVenue_NotFound() { Venue testVenue = new Venue { Id = 10 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.Venues.GetById(10)).Returns((Venue)null); VenuesController controller = new VenuesController(mock.Object); var result = controller.DeleteVenue(10); Assert.IsType <NotFoundResult>(result); }
public void VenuesAllNoVenues_ShouldReturnCorrectResult() { // Arrange IHotelBookingSystemData data = new HotelBookingSystemData(); User user = new User("test user", "password", Roles.User); VenuesController controller = new VenuesController(data, user); // Act IView view = controller.All(); string result = view.Display(); string expected = "There are currently no venues to show."; // Assert Assert.AreEqual(expected, result); }
public async Task Get_Specific_Venue() { IRepository <Venue> customerRepository = Substitute.For <IRepository <Venue> >(); customerRepository.Get(Arg.Any <Guid>()).Returns(new Venue() { Id = Guid.NewGuid(), Address = "House Name, Street, City, PostCode", Rows = 10, RowLabelType = Code.Labels.Enums.LabelType.Alfabetic, Cols = 10, ColLabelType = Code.Labels.Enums.LabelType.Numeric }); var controller = new VenuesController(customerRepository); var result = await controller.Get(Arg.Any <Guid>()); Assert.AreEqual(result.Status, 200); Assert.AreEqual(((VenueViewModel)result.Data).Seats, 100); }
public void Should_DeleteVenue() { Venue testVenue = new Venue { Id = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.Venues.GetById(1)).Returns(testVenue); mock.Setup(f => f.Venues.Delete(testVenue)).Returns(true); VenuesController controller = new VenuesController(mock.Object); var result = controller.DeleteVenue(1); Assert.IsType <OkObjectResult>(result); }
private async void BtnSaveChanges_Click(object sender, EventArgs e) { EmployeesController eCtrl = new EmployeesController(); DashboardGUI dGUI = DashboardGUI.Instance; VenuesController vCtrl = new VenuesController(); if (TextBoxesHasValues()) { if (create) { //Venue currVenue = (Venue)cbVenueID.SelectedItem; //Debug.WriteLine("VenueId from tableGUI: " + currVenue.Id); string Password = HashingHelper.GenerateHash(tbPassword.Text); string Salt = HashingHelper.RandomString(20); try { Employee newEmployee = new Employee { Name = tbName.Text, Phone = tbPhone.Text, Email = tbEmail.Text, Password = Password, Salt = Salt, EmployeeNo = await eCtrl.GetNewEmployeeNo(), Title = tbEmployeeTitle.Text }; Venue newVenue = (Venue)cbVenueID.SelectedItem; Debug.WriteLine("newEmployee: " + newEmployee.Id + " " + newEmployee.Name); Debug.WriteLine("newVenue: " + newVenue.Id + " " + newVenue.Name); await eCtrl.Create(newEmployee, newVenue); this.Visible = false; dGUI.AddEmployeeStats(); } catch (Exception) { MessageBox.Show("No connection to service"); } } else if (!create) { MessageBox.Show("Method not implemented"); this.Visible = false; /*int id = editedTable.Id; * Table updatedTable = await tCtrl.Get(editedTable.Id); * await tCtrl.Update(updatedTable.Id, updatedTable); * this.Visible = false;*/ } } else { MessageBox.Show("Error...One or more fields are empty!");; } }
public void GetAllVanuesWithDataMustReturnThem() { var user = new User("admin1", "admin1", Roles.VenueAdmin); var data = new HotelBookingSystemData(); var venue = new Venue("one", "address one", "vanue with address one", user); data.RepositoryWithVenues.Add(venue); var controller = new VenuesController(data, user); var vanues = controller.All(); var expected = new StringBuilder(); expected.AppendFormat("*[{0}] {1}, located at {2}", venue.Id, venue.Name, venue.Address) .AppendLine() .AppendFormat("Free rooms: {0}", venue.Rooms.Count); Assert.AreEqual(expected.ToString(), vanues.Display()); }
public void ShouldNot_DeleteVenue_ModelStateError() { Venue testVenue = new Venue { Id = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.Venues.Delete(testVenue)).Returns(true); VenuesController controller = new VenuesController(mock.Object); controller.ModelState.AddModelError("TestError", "Error"); var result = controller.DeleteVenue(1); Assert.IsType <BadRequestObjectResult>(result); }
public void VenuesAll_VenuesInDataWithNoLoggedInUser_ShouldReturnExpectedView() { var data = new HotelBookingSystemData(); var venuesController = new VenuesController(data, null); venuesController.Add("Valentin", "Sveti", "Praznik, na koito vsichki praznuvat, no ne i az."); var view = venuesController.All(); string actualResult = view.Display(); var expectedResult = new StringBuilder(); expectedResult.AppendFormat($"*[{1}] {"Valentin"}, located at {"Sveti"}").AppendLine(); expectedResult.Append("Free rooms: 0"); Assert.AreEqual(expectedResult.ToString(), actualResult, "All venues did not return expected view!"); }
public async void Edit() { VenuesController vCtrl = new VenuesController(); venuesGUI = VenuesGUI.Instance; editedVenue = await vCtrl.Get(venuesGUI.idFromTable); lblBool.Text = "editedVenueID: " + editedVenue.Id; create = false; lblTitle.Text = "Edit Venue"; BtnSaveChanges.Text = "Save changes"; tbName.Text = editedVenue.Name; tbAddress.Text = editedVenue.Address; tbZip.Text = "" + editedVenue.Zip; tbCity.Text = editedVenue.City; tbVenueID.ReadOnly = true; tbVenueID.Text = "" + venuesGUI.idFromTable; }
public void VenuesAllThreeVenues_ShouldReturnCorrectResult() { // Arrange IHotelBookingSystemData data = new HotelBookingSystemData(); User user = new User("test user", "password", Roles.User); VenuesController controller = new VenuesController(data, user); // Act controller.Add("venue name1", "Pernik", "test"); controller.Add("venue name2", "Pernik", "test"); controller.Add("venue name3", "Pernik", "test"); IView view = controller.All(); string result = view.Display(); string expected = "*[1] venue name1, located at Pernik\r\nFree rooms: 0\r\n*[2] venue name2, located at Pernik\r\nFree rooms: 0\r\n*[3] venue name3, located at Pernik\r\nFree rooms: 0"; // Assert Assert.AreEqual(expected, result); }
public void VenuesAll_shouldReturnAllVenuesInDatabase() { var currentUser = new User("NormalUser", "122343434", Roles.VenueAdmin); var venuesController = new VenuesController(new HotelBookingSystemData(), currentUser); var venue = new Venue("SinCity", "SofiqNqkadeSi", string.Empty, currentUser); venuesController.Add("SinCity", "SofiqNqkadeSi", string.Empty); var result = venuesController.All().Display(); StringBuilder expectedViewResult = new StringBuilder(); expectedViewResult.AppendFormat("*[{0}] {1}, located at {2}", 1, venue.Name, venue.Address) .Append(Environment.NewLine) .AppendFormat("Free rooms: {0}", venue.Rooms.Count).Append(Environment.NewLine); Assert.AreEqual(expectedViewResult.ToString().Trim(), result); }
public void TestAll_WithPresentVenuesAndValidPremissions_ShouldPass() { const string ExpectedResult = @"*[1] Venu1, located at Address1 Free rooms: 0 *[2] Venu2, located at Address2 Free rooms: 0 *[3] Venu2, located at Address2 Free rooms: 0"; this.user = new User("Pesho", "asdasd", Roles.VenueAdmin); this.venuesController = new VenuesController(this.data, this.user); this.venuesController.Add("Venu1", "Address1", "No Description"); this.venuesController.Add("Venu2", "Address2", "No Description"); this.venuesController.Add("Venu2", "Address2", "No Description"); var view = this.venuesController.All(); var result = view.Display(); Assert.AreEqual(ExpectedResult, result, "The result views does not match"); }
public void UnAuthorizedUserCannotViewVanuesDetails() { var data = new HotelBookingSystemData(); var controller = new VenuesController(data, null); var view = controller.Details(1); }
public void VenuesAll_EmptyDatabase_ShouldReturnCorrectMessage() { var currentUser = new User("NormalUser", "122343434", Roles.VenueAdmin); var venuesController = new VenuesController(new HotelBookingSystemData(), currentUser); var result = venuesController.All().Display(); Assert.AreEqual("There are currently no venues to show.", result); }
public void UnAuthorizedUserCannotAddVenue() { var data = new HotelBookingSystemData(); var controller = new VenuesController(data, null); var view = controller.Add("venue one", "address one", "description one"); }
public void Authorize_NoLoggedUser_ShouldThrow() { var controller = new VenuesController(this.data, null); controller.Details(1); }