Beispiel #1
0
        static void Main(string[] args)
        {
            //! If we first create just a plan variable of the IPhone type, we can use it for ANY
            //! class that has implemented the IPhone type. The reason for this, is that interfaces
            //! are like contracts.  There may be a lot of difference between all the classes that
            //! implement the IPhone interface, but the "contract" says that all of the classes
            //! will do certain things.
            IPhone phone;

            //! Since they are all of the IPhone type, you can put different types into the same
            //! variable and not worry about things breaking. Also, you can save memory if you're
            //! good about using the same variable for different classes that implement
            //! the interface. Below we are creating many phones for the same variable and doing
            //! the same things with them with the "DoPhoneStuff(phone);" method call.
            phone = new GalaxyA30();
            DoPhoneStuff(phone);
            phone = new IPhone7();
            DoPhoneStuff(phone);
            phone = new IPhone6();
            DoPhoneStuff(phone);
            phone = new IPhone8();
            DoPhoneStuff(phone);
            phone = new GalaxyS8();
            DoPhoneStuff(phone);

            //? I have left most of the classes doing the same thing, but change a couple for examples.
            //?     This is why we use interfaces and we call it "programming to interfaces", because
            //?     the "consumer" of the class should not have to worry about WHAT it has, or HOW
            //?     the object does what it does. Just that it IS something, and can DO something.
        }
Beispiel #2
0
        public void CartTest()
        {
            ChromeOptions options = new ChromeOptions();

            options.PageLoadStrategy = PageLoadStrategy.None;
            using (ChromeDriver dr = new ChromeDriver(Directory.GetCurrentDirectory(), options))
            {
                dr.Manage().Window.FullScreen();
                var mydriver = new Main(dr);
                mydriver.NavigateToAli();
                ResultIPhone resultIPhone6  = mydriver.ChooseIPhone();
                IPhone6      iphone6        = resultIPhone6.GoIPhone6();
                ResultIPhone resultIPhone6s = iphone6.ChooseIPhone6s();
                IPhone6S     iphone6S       = resultIPhone6s.GoIPhone6s();
                ResultIPhone resultIPhone7  = iphone6S.ChooseIPhone7();
                IPhone7      iphone7        = resultIPhone7.GoIPhone7();
                Cart         cart           = iphone7.GoToCart();
                cart.Finish();
            }
        }