public void All_AllVenuesWithExistingItems_ShouldReturnAllVenues()
        {
            var venues = new List<Venue>();
            var venue1 = new Venue("hotel1", "Address1", "description1", null);
            var venue2 = new Venue("hotel2", "Address2", "description2", null);
            var venue3 = new Venue("hotel3", "Address3", "description3", user);
            venues.Add(venue1);
            venues.Add(venue2);
            venues.Add(venue3);

            venuesController.Add("hotel1", "Address1", "description1");
            venuesController.Add("hotel2", "Address2", "description2");
            venuesController.Add("hotel3", "Address3", "description3");

            var idCounter = 1;
            StringBuilder expected = new StringBuilder();
            foreach (var venue in venues)
            {
                var venueInfo = string.Format("*[{0}] {1}, located at {2}", idCounter++, venue.Name, venue.Address);
                var venueFreeRoomsInfo = string.Format("Free rooms: {0}", venue.Rooms.Count);
                expected.AppendLine(venueInfo).AppendLine(venueFreeRoomsInfo);
            }

            var result = venuesController.All().Display();

            Assert.AreEqual(expected.ToString().Trim(), result);
        }
 public IView Add(string name, string address, string description)
 {
     this.Authorize(Roles.VenueAdmin);
     var newVenue = new Venue(name, address, description, this.CurrentUser);
     this.Data.RepositoryWithVenues.Add(newVenue);
     return this.View(newVenue);
 }
 public IView Add(string name, string address, string description)
 {
     //BUG only admin can add venues
     this.Authorize(Roles.VenueAdmin);
     var newVenue = new Venue(name, address, description, CurrentUser);
     this.Data.VenuesRepository.Add(newVenue);
     return View(newVenue);
 }
        public void TestInit()
        {
            var dataMock = new Mock<IHotelBookingSystemData>();
            var venuesRepoMock = new Mock<IRepository<Venue>>();
            var roomsRepoMock = new Mock<IRepository<Room>>();
            this.user = new User("admin", "Password1233", Roles.VenueAdmin);
            this.venue = new Venue("hotel Dreams", "addres Dreams", "desc Dreams", user);

            venuesRepoMock.Setup(v => v.Get(It.IsAny<int>())).Returns(this.venue);

            dataMock.Setup(d => d.VenuesRepository).Returns(venuesRepoMock.Object);
            dataMock.Setup(d => d.RoomsRepository).Returns(roomsRepoMock.Object);

            this.mockedData = dataMock.Object;
        }
        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 Details(Venue venue)
     : base(venue)
 {
 }
 public Add(Venue venue)
     : base(venue)
 {
 }
 public Rooms(Venue venue)
     : base(venue)
 {
 }