public void get_with_concrete_type()
        {
            var serializer = new JsonNetSerializer();
            var camaro     = new Camaro();

            var json = serializer.ToJson(camaro);

            var map = new NulloIdentityMap(serializer);

            map.Get <Car>(camaro.Id, typeof(Camaro), json)
            .ShouldBeOfType <Camaro>()
            .Id.ShouldBe(camaro.Id);
        }
예제 #2
0
        public void get_with_concrete_type()
        {
            var serializer = new JsonNetSerializer();
            var camaro = new Camaro();

            var json = serializer.ToJson(camaro);

            var map = new NulloIdentityMap(serializer);

            map.Get<Car>(camaro.Id, typeof (Camaro), json, null)
                .ShouldBeOfType<Camaro>()
                .Id.ShouldBe(camaro.Id);

            
        }
예제 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("I bought a new Camaro!");
            var myCamaro = new Camaro();  // Instantiate an object from the Camaro class (which is a child of "Car")

            Console.WriteLine("It goes {0}", myCamaro.GoVroom());
            Console.WriteLine("It is the color {0}", myCamaro.color);

            var brothersIrocz = new IROCZ();  // instantiate an object from the IROCZ class (which is a child of Camaro)

            Console.WriteLine("When I was at the dealership, they tried to sell my brother an IROCZ with low miles.");
            Console.WriteLine("It went {0}", brothersIrocz.GoVroom());
            Console.WriteLine("And it was the color {0}", brothersIrocz.color);
            Console.WriteLine("My brother bought it, and he wanted to change the color.");

            var newPaintColor = "yellow";

            Console.WriteLine("So we painted it");
            brothersIrocz.PaintCar(newPaintColor);
            Console.WriteLine("And now it is {0}", brothersIrocz.color);

            Console.WriteLine("I told him it needed to be even faster, so we installed a turbo.");
            brothersIrocz.InstallTurboCharger();
            Console.WriteLine("And now it goes {0}", brothersIrocz.GoVroom());

            Console.WriteLine("But mine is still the color {0}", myCamaro.color);
            Console.WriteLine("And only goes {0}", myCamaro.GoVroom());

            Console.WriteLine("We decided to take my car on a road trip (it got better gas mileage).");
            var ourRoadtrip = new RoadTrip(myCamaro); // create a new RoadTrip and pass in ANY car.  Liskov subsitution example.  A Camaro is a Car.

            ourRoadtrip.AddDestination("Las Vegas");
            ourRoadtrip.AddDestination("Seattle");
            ourRoadtrip.AddDestination("Juno");

            Console.WriteLine("We marked off the cities on the map, bought some snacks, and drove off!");
            ourRoadtrip.Travel();

            Console.WriteLine("When we got home, we took my brother's IROCZ to the dragstrip to do burnouts in the parkinglot!");
            var dragstripTrip = new TripToDragStrip(brothersIrocz);

            Console.WriteLine("We decided to do 7 burnouts.  This is what happened:");
            for (var i = 0; i < 7; i++)
            {
                dragstripTrip.RockAndRoll();
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            #region LSP-exemplo1
            var camaro = new Camaro();
            System.Console.ReadLine();
            var fusca = new Camaro();
            #endregion

            //#region LSP-exemplo1-Solucao
            //var camaroLSP = new CamaroLSP();
            //System.Console.ReadLine();
            //var fuscaLSP = new FuscaLSP();
            //#endregion


            #region LSP-exemplo2
            Agencia.Negocio.LSP.Ex2.Cliente clienteFiel = new Agencia.Negocio.LSP.Ex2.ClienteFiel();
            clienteFiel.TipoCliente  = TipoCliente.Gold;
            clienteFiel.DataCadastro = new DateTime(2008, 12, 1);
            clienteFiel.Nome         = "Diego";
            var valorDesconto = clienteFiel.CalcularDesconto(100, clienteFiel.TipoCliente);

            Console.WriteLine("O cliente {0} pagará o valor de R$ {1} - {2}", clienteFiel.Nome,
                              valorDesconto, clienteFiel.ClienteEspecial() ? "Cliente Especial" : "Cliente Normal");
            Console.ReadKey();


            Agencia.Negocio.LSP.Ex2.Cliente possivelCliente = new Agencia.Negocio.LSP.Ex2.PossivelCliente();
            possivelCliente.TipoCliente  = TipoCliente.Gold;
            possivelCliente.DataCadastro = new DateTime(2008, 12, 1); //PossivelCliente com data de cadastro?
            possivelCliente.Nome         = "Diego";
            var valorDescontoP = possivelCliente.CalcularDesconto(100, possivelCliente.TipoCliente);

            Console.WriteLine("O cliente {0} pagará o valor de R$ {1} - {2}", possivelCliente.Nome,
                              valorDesconto, possivelCliente.ClienteEspecial() ? "Cliente Especial" : "Cliente Normal");

            Console.ReadKey();
            #endregion

            //#region LSP-exemplo2-Solucao
            //Agencia.Negocio.LSP.Ex2.ClienteFielLSP clienteFielLSP = new Agencia.Negocio.LSP.Ex2.ClienteFielLSP();
            //clienteFielLSP.TipoCliente = TipoCliente.Gold;
            //clienteFielLSP.DataCadastro = new DateTime(2008, 12, 1);
            //clienteFielLSP.Nome = "Diego";
            //var valorDesconto = clienteFielLSP.CalcularDesconto(100, clienteFielLSP.TipoCliente);

            //Console.WriteLine("O cliente {0} pagará o valor de R$ {1} - {2}", clienteFielLSP.Nome,
            //    valorDesconto, clienteFielLSP.ClienteEspecial() ? "Cliente Especial" : "Cliente Normal");
            //Console.ReadKey();


            //Agencia.Negocio.LSP.Ex2.PossivelClienteLPS possivelClienteLSP = new Agencia.Negocio.LSP.Ex2.PossivelClienteLPS();
            //possivelClienteLSP.TipoCliente = TipoCliente.Gold;
            ////possivelClienteLSP.DataCadastro = new DateTime(2008, 12, 1);
            //possivelClienteLSP.Nome = "Diego";
            //var valorDescontoP = possivelClienteLSP.CalcularDesconto(100, possivelClienteLSP.TipoCliente);

            //Console.WriteLine("O cliente {0} pagará o valor de R$ {1} - {2}", possivelClienteLSP.Nome,
            //    valorDesconto, "Cliente Normal");

            //Console.ReadKey();
            //#endregion
        }