Ejemplo n.º 1
0
        public void TestVenueFactoryGetInstanceReturnsSameInstance()
        {
            VenueFactory venueFactory1 = VenueFactory.GetInstance;
            VenueFactory venueFactory2 = VenueFactory.GetInstance;

            Assert.AreEqual <VenueFactory>(venueFactory1, venueFactory2);
        }
Ejemplo n.º 2
0
        public void TestVenueFactoryAddFeaturesRaisesExceptionOnUnregisteredVenue()
        {
            VenueFactory  venueFactory    = VenueFactory.GetInstance;
            PrivateObject privateAccessor = new PrivateObject(venueFactory);

            privateAccessor.SetField("venueFeatures", new Hashtable()); // Reset venueFeatures

            Venue venue = new Venue();
            List <VenueDecorator> venueAddOnList = new List <VenueDecorator>();

            VenueAfternoonRefreshments decorator1 = new VenueAfternoonRefreshments();
            VenueMorningRefreshments   decorator2 = new VenueMorningRefreshments();

            //set up venue and decorator values
            venue.venueName = "Venue";
            venue.cost      = 25.0M;

            decorator1.ID   = "0";
            decorator1.name = "decorator1";
            decorator1.cost = 10.0M;
            decorator2.ID   = "1";
            decorator2.name = "decorator2";
            decorator2.cost = 15.0M;

            venueAddOnList.Add(decorator1);
            venueAddOnList.Add(decorator2);

            venueFactory.AddFeatures(venue, venueAddOnList);
        }
Ejemplo n.º 3
0
        public void TestVenueFactoryAddFeaturesRaisesExceptionFailingToParseID()
        {
            VenueFactory          venueFactory   = VenueFactory.GetInstance;
            Venue                 venue          = new Venue();
            List <VenueDecorator> venueAddOnList = new List <VenueDecorator>();

            VenueAfternoonRefreshments decorator1 = new VenueAfternoonRefreshments();
            VenueMorningRefreshments   decorator2 = new VenueMorningRefreshments();

            //set up venue and decorator values
            venue.venueName = "Venue";
            venue.cost      = 25.0M;

            decorator1.ID   = "brokenID";
            decorator1.name = "decorator1";
            decorator1.cost = 10.0M;
            decorator2.ID   = "1";
            decorator2.name = "decorator2";
            decorator2.cost = 15.0M;

            venueAddOnList.Add(decorator1);
            venueAddOnList.Add(decorator2);

            venueFactory.AddFeatures(venue, venueAddOnList);
        }
Ejemplo n.º 4
0
        public IView Add(string name, string address, string description)
        {
            var newVenue = VenueFactory.CreateVenue(name, address, description, this.CurrentUser);

            this.Data.RepositoryWithVenues.Add(newVenue);
            return(this.GetView(newVenue));
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            VenueFactory venueFactory = VenueFactory.GetInstance;

            venueFactory.Register(VenueAddOns.AFTERNOON_REFRESHMENTS, new VenueAfternoonRefreshments());
            venueFactory.Register(VenueAddOns.BUS_TRANSPORTS, new VenueBusTransport());
            venueFactory.Register(VenueAddOns.EVENING_MEAL, new VenueEveningMeal());
            venueFactory.Register(VenueAddOns.MIDDAY_LUNCH, new VenueMiddayLunch());
            venueFactory.Register(VenueAddOns.MORNING_REFRESHMENTS, new VenueMorningRefreshments());


            ActivityFactory activityFactory = ActivityFactory.GetInstance;

            activityFactory.Register(ActivityTypes.GO_KART, new GoKartActivity());
            activityFactory.Register(ActivityTypes.WALL_CLIMBING, new WallClimbingActivity());
            activityFactory.Register(ActivityTypes.CHOCOLATE_PRODUCING_AND_MARKETING, new ChoclateProducingAndMarketingActivity());
            activityFactory.Register(ActivityTypes.MEDITATION_AND_MINDFULLNESS, new MeditationAndMindfullnessActivity());
            activityFactory.Register(ActivityTypes.TEAM_BUILDING_AND_PROBLEM_SOLVING, new TeamBuildingAndProblemSolvingActivity());


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            BookingGUI gui = new BookingGUI();

            new BookingPresenter(gui);
            Application.Run(gui);
        }
Ejemplo n.º 6
0
        public void TestVenueFactoryGetInstance()
        {
            VenueFactory  venueFactory    = VenueFactory.GetInstance;
            PrivateObject privateAccessor = new PrivateObject(venueFactory);

            privateAccessor.SetField("venueFeatures", new Hashtable()); // Reset venueFeatures

            Assert.IsInstanceOfType(VenueFactory.GetInstance, typeof(VenueFactory));
            Hashtable refVenueFeatures = (Hashtable)privateAccessor.GetField("venueFeatures");

            Assert.AreEqual <int>(0, refVenueFeatures.Count);
        }
Ejemplo n.º 7
0
        public static Venue GetVenue(string bookingID)
        {
            if (String.IsNullOrEmpty(bookingID))
            {
                throw new ArgumentNullException("ID cant be null");
            }

            Venue                  venueResult     = null;
            VenueFactory           venueFactory    = VenueFactory.GetInstance;
            List <VenueDecorator>  venueDecorators = new List <VenueDecorator>();
            List <VenueExtrasLink> extrasLinks     = new List <VenueExtrasLink>();

            try
            {
                using (DatabaseEntities context = new DatabaseEntities())
                {
                    venueResult = (from venue in context.Venue where (venue.ID == bookingID) select venue).SingleOrDefault();

                    IQueryable <VenueExtrasLink> data = from extras in context.VenueExtrasLink
                                                        where extras.bookingID == bookingID
                                                        select extras;

                    foreach (VenueExtrasLink extra in data)
                    {
                        extrasLinks.Add(extra);
                    }


                    foreach (VenueExtrasLink extra in extrasLinks)
                    {
                        IQueryable <VenueDecorator> decorators = from decorator in context.VenueDecorator
                                                                 where decorator.ID == extra.extraID
                                                                 select decorator;

                        foreach (VenueDecorator decorator in decorators)
                        {
                            venueDecorators.Add(decorator);
                        }
                    }

                    if (venueDecorators.Count > 0)
                    {
                        venueFactory.AddFeatures(venueResult, venueDecorators);
                    }
                }
            }
            catch (Exception exception)
            {
                ShowErrorMessage(exception);
            }

            return(venueResult);
        }
Ejemplo n.º 8
0
        public void TestVenueFactoryRegisterDoesNotOverwriteExisitingKeys()
        {
            VenueFactory  venueFactory    = VenueFactory.GetInstance;
            PrivateObject privateAccessor = new PrivateObject(venueFactory);

            privateAccessor.SetField("venueFeatures", new Hashtable()); // Reset venueFeatures
            Hashtable refVenueFeatures = (Hashtable)privateAccessor.GetField("venueFeatures");

            VenueAfternoonRefreshments mockVAfterRef = Substitute.For <VenueAfternoonRefreshments>();
            VenueBusTransport          mockVBusTrans = Substitute.For <VenueBusTransport>();

            venueFactory.Register(VenueAddOns.AFTERNOON_REFRESHMENTS, mockVAfterRef);
            venueFactory.Register(VenueAddOns.AFTERNOON_REFRESHMENTS, mockVBusTrans);

            Assert.IsTrue(refVenueFeatures.ContainsKey(VenueAddOns.AFTERNOON_REFRESHMENTS));
            Assert.IsTrue(refVenueFeatures.ContainsValue(mockVAfterRef));
            Assert.AreEqual <int>(1, refVenueFeatures.Count);
        }
Ejemplo n.º 9
0
        public void TestVenueFactoryRegisterSuccess()
        {
            VenueFactory  venueFactory    = VenueFactory.GetInstance;
            PrivateObject privateAccessor = new PrivateObject(venueFactory);

            privateAccessor.SetField("venueFeatures", new Hashtable()); // Reset venueFeatures
            Hashtable refVenueFeatures = (Hashtable)privateAccessor.GetField("venueFeatures");


            VenueAfternoonRefreshments mockVAfterRef = Substitute.For <VenueAfternoonRefreshments>();
            VenueMorningRefreshments   mockVMornRef  = Substitute.For <VenueMorningRefreshments>();
            VenueEveningMeal           mockVEveMeal  = Substitute.For <VenueEveningMeal>();
            VenueBusTransport          mockVBusTrans = Substitute.For <VenueBusTransport>();
            VenueMiddayLunch           mockVMidLunch = Substitute.For <VenueMiddayLunch>();

            venueFactory.Register(VenueAddOns.MORNING_REFRESHMENTS, mockVMornRef);
            Assert.IsTrue(refVenueFeatures.ContainsKey(VenueAddOns.MORNING_REFRESHMENTS));
            Assert.IsTrue(refVenueFeatures.ContainsValue(mockVMornRef));
            Assert.AreEqual <int>(1, refVenueFeatures.Count);

            venueFactory.Register(VenueAddOns.AFTERNOON_REFRESHMENTS, mockVAfterRef);
            Assert.IsTrue(refVenueFeatures.ContainsKey(VenueAddOns.AFTERNOON_REFRESHMENTS));
            Assert.IsTrue(refVenueFeatures.ContainsValue(mockVAfterRef));
            Assert.AreEqual <int>(2, refVenueFeatures.Count);

            venueFactory.Register(VenueAddOns.EVENING_MEAL, mockVEveMeal);
            Assert.IsTrue(refVenueFeatures.ContainsKey(VenueAddOns.EVENING_MEAL));
            Assert.IsTrue(refVenueFeatures.ContainsValue(mockVEveMeal));
            Assert.AreEqual <int>(3, refVenueFeatures.Count);

            venueFactory.Register(VenueAddOns.BUS_TRANSPORTS, mockVBusTrans);
            Assert.IsTrue(refVenueFeatures.ContainsKey(VenueAddOns.BUS_TRANSPORTS));
            Assert.IsTrue(refVenueFeatures.ContainsValue(mockVBusTrans));
            Assert.AreEqual <int>(4, refVenueFeatures.Count);

            venueFactory.Register(VenueAddOns.MIDDAY_LUNCH, mockVMidLunch);
            Assert.IsTrue(refVenueFeatures.ContainsKey(VenueAddOns.MIDDAY_LUNCH));
            Assert.IsTrue(refVenueFeatures.ContainsValue(mockVMidLunch));
            Assert.AreEqual <int>(5, refVenueFeatures.Count);
        }
Ejemplo n.º 10
0
        public void TestVenueFactoryAddFeaturesSuccess()
        {
            VenueFactory  venueFactory    = VenueFactory.GetInstance;
            PrivateObject privateAccessor = new PrivateObject(venueFactory);

            privateAccessor.SetField("venueFeatures", new Hashtable()); // Reset venueFeatures
            Venue venue = new Venue();
            List <VenueDecorator> venueAddOnList = new List <VenueDecorator>();

            VenueAfternoonRefreshments decorator1  = new VenueAfternoonRefreshments();
            PrivateObject            refDecorator1 = new PrivateObject(decorator1, new PrivateType(typeof(VenueDecorator)));
            VenueMorningRefreshments decorator2    = new VenueMorningRefreshments();
            PrivateObject            refDecorator2 = new PrivateObject(decorator2, new PrivateType(typeof(VenueDecorator)));

            //set up venue and decorator values
            venue.venueName = "Venue";

            decorator1.ID   = "0";
            decorator1.name = "decorator1";
            decorator1.cost = 10.0M;
            decorator2.ID   = "3";
            decorator2.name = "decorator2";
            decorator2.cost = 15.0M;

            venueFactory.Register(VenueAddOns.AFTERNOON_REFRESHMENTS, decorator1);
            venueFactory.Register(VenueAddOns.MORNING_REFRESHMENTS, decorator2);

            venueAddOnList.Add(decorator1);
            venueAddOnList.Add(decorator2);

            venueFactory.AddFeatures(venue, venueAddOnList);

            Assert.AreEqual <VenueComponent>(venue, (VenueComponent)refDecorator1.GetField("venueComponent"));
            Assert.AreEqual <VenueComponent>(decorator1, (VenueComponent)refDecorator2.GetField("venueComponent"));
            Assert.AreEqual <decimal>(25.0M, venue.GetCost());
            Assert.AreEqual <string>("Venue", venue.GetName());
            Assert.AreEqual <string>("decorator1\nVenue", decorator1.GetName());
            Assert.AreEqual <string>("decorator2\ndecorator1\nVenue", decorator2.GetName());
        }
Ejemplo n.º 11
0
        public void TestVenueFactoryRegisterRaisesExceptionOnNullDecorator()
        {
            VenueFactory venueFactory = VenueFactory.GetInstance;

            venueFactory.Register(VenueAddOns.AFTERNOON_REFRESHMENTS, null);
        }