Example #1
0
        /// <summary>
        /// Checks if the input for VenueId property is valid.
        /// </summary>
        /// <param name="value">VenueId to be updated.</param>
        /// <returns>True if valid, false if invalid.</returns>
        public bool VenueIsValid(int value)
        {
            // Event not initalised yet, temp. set it to true.
            if (this.DBObj.Event == null)
            {
                return(true);
            }

            Console.WriteLine("Clash: " + value + " " + this.Start + " " + this.End);
            List <DBLayer.SubEvent> list = DBLayer.DomainModels.SubEventModel.getAllByVenueIDAndTime(value, this.Start, this.End, this.DBObj.Event.Id);

            bool noClashResult = false;

            if (list != null && list.Count > 0)
            {
                base.AddError("VenueId", VENUE_ERROR_SLASH, false);
                noClashResult = false;
            }
            else
            {
                base.RemoveError("VenueId", VENUE_ERROR_SLASH);
                noClashResult = true;
            }

            DBLayer.Venue v         = DBLayer.DomainModels.VenueModel.getByID(value);
            bool          capResult = v.Capacity >= this.DBObj.Event.Capacity;

            if (!capResult)
            {
                base.AddError("VenueId", VENUE_ERROR_CAP, false);
            }
            else
            {
                base.RemoveError("VenueId", VENUE_ERROR_CAP);
            }

            Console.WriteLine("Clash: " + noClashResult + " Cap: " + capResult);
            return(noClashResult && capResult);
        }
        public void createUpdateObjTest()
        {
            // test for create
            string name = "Lecture Theatre 40";
            int capacity = 500;

            Venue e;
            e = VenueModel.create(name, capacity);

            Venue expected = new Venue();
            expected.Name = name;
            expected.Capacity = capacity;

            Assert.AreEqual(expected.Name, e.Name);
            Assert.AreEqual(expected.Capacity, e.Capacity);

            // test for create obj
            Venue actual;
            actual = VenueModel.createObj(e);

            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Capacity, actual.Capacity);

            // test for update obj
            name = "New Lecture Theatre";
            capacity = 600;

            expected.Name = name;
            expected.Capacity = capacity;

            e.Name = name;
            e.Capacity = capacity;
            actual = VenueModel.updateObj(e);

            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Capacity, actual.Capacity);
        }
        public void getByIDTest()
        {
            int id = 1;

            Venue expected = new Venue();
            expected.Id = id;
            expected.Name = "Lecture Theatre 15";
            expected.Capacity = 100;

            Venue actual;
            actual = VenueModel.getByID(id);

            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Capacity, actual.Capacity);
        }