예제 #1
0
        public void CheckThatCarExists()
        {
            CarShop shop = new CarShop();

            shop.BuyCar();
            Assert.AreEqual(shop.hasCar, shop.hasCar);
        }
예제 #2
0
        public async Task GetCarShopTest()
        {
            var objA = new CarShop()
            {
                Id           = "ID-123",
                TenantId     = "SMLLC",
                CreatedOnUtc = DateTime.UtcNow,
            };

            using var srv = new TestServer(TestHostBuilder <Startup, TestStartup>()
                                           .ConfigureTestServices(x =>
            {
                ExecuteOnContext <CarShopContext>(x, db =>
                {
                    db.CarShop.Add(objA);
                });
            })
                                           );
            var client = srv.CreateClient();

            GenerateAuthHeader(client, GenerateTestToken(new[] { new Claim(TenantFilterAttribute.TenantIdsClaimType, "SMLLC") }));

            var resp = await client.GetStringAsync($"odata/v1/CarShop?tid=SMLLC");

            TestContext.WriteLine($"Server Reponse: {resp}");
            Assert.IsFalse(resp.ToLower().Contains("updatedby"));
            var envelope = JsonConvert.DeserializeObject <ODataEnvelope <CarShop, string> >(resp);

            Assert.AreEqual(objA.CreatedOnUtc, envelope.Value.First().CreatedOnUtc.ToUniversalTime());
        }
예제 #3
0
        public void CheckThatCustomerExists()
        {
            CarShop  shop = new CarShop();
            Customer test = new Customer("Ola", shop);

            Assert.AreEqual(test._name, "Ola");
        }
예제 #4
0
        public async Task <IActionResult> PutCarShop(int id, CarShop carShop)
        {
            if (id != carShop.Id)
            {
                return(BadRequest());
            }

            _context.Entry(carShop).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarShopExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #5
0
        public static void Main(string[] args)
        {
            var car        = CarShop.GetCar <Audi>();
            var anotherCar = CarShop.GetCar("FabrykaRefleksja.Vw");

            car.Produce();
            anotherCar.Produce();
        }
예제 #6
0
        public void CheckThatTwoCustomersAreNotTheSameAsTheOtherOneSinceTheyAreTwoDifferentPeople()
        {
            CarShop  shop  = new CarShop();
            Customer test1 = new Customer("Ola", shop);
            Customer test2 = new Customer("NotOla", shop);

            Assert.AreNotEqual(test1._name, test2._name);
        }
예제 #7
0
        static void Main(string[] args)
        {
            CarShop carShop = new CarShop();

            carShop.Input();

            Console.WriteLine($"Total sum: {carShop.TotalSum()} lv.");
            carShop.Output();
        }
예제 #8
0
 /// <summary>
 /// This Command add a car in warehouse
 /// </summary>
 public AddCarFromConsoleCommand(CarShop receiver, SerializableCar newCar)
 {
     this.Shop = receiver;
     if (newCar != null)
     {
         this.NewCar = newCar;
     }
     else
     {
         throw new ArgumentException("Attempt to add a car that is null");
     }
 }
예제 #9
0
    private void Start()
    {
        if (instance == null)
        {
            instance = this;
        }

        urlShop = name;
        count   = itemList.Count;

        //Load data
        loading();

        // setup ui
        if (itemList != null)
        {
            itemList[0].bought = true;
            boughtList.Add(itemList[0]);
        }
        for (int i = 0; i < count; i++)
        {
            GameObject obj = Instantiate(prefItem, container, false);
            obj.transform.GetChild(0).GetComponent <Image>().sprite = imageItemList[i];

            // add into list to manage
            itemObjectList.Add(obj);
            snap.btnn.Add(obj.GetComponent <Button>());


            // xet da mua
            if (itemList[i].bought)
            {
                itemObjectList[i].transform.GetChild(0).GetComponent <Image>().material = null;
                itemObjectList[i].transform.GetChild(0).GetComponent <Image>().color
                    = new Color(1, 1, 1, 1);
                itemObjectList[i].transform.GetChild(0).GetComponent <Image>().sprite = imageItemList[i];
                // snake chua su dung
                if (itemList[i].itemID != currentItemID)
                {
                }
                // snake da mua va su dung
                else
                {
                }
            }
            else
            {
            }
        }
        coinManager.UpdateCoin();
        UpdateUI();
        snap._setupStart(currentItemID);
    }
예제 #10
0
        public void RunShopTest()
        {
            CarShop bmwCarShop = new CarShop(new BmwConcreteFactory());

            bmwCarShop.RunShop();

            Console.WriteLine("--------------");

            CarShop audiCarShop = new CarShop(new AudiConcreteFactory());

            audiCarShop.RunShop();
        }
예제 #11
0
        public async Task <ActionResult <CarShop> > PostCarShop(CarShop carShop)
        {
            try
            {
                if (carShop is null)
                {
                    return(StatusCode(409));
                }
                if (carShop.ProductID == 0)
                {
                    return(NotFound());
                }
                carShop.Type       = TypeShop(carShop.Type);
                carShop.StateOrder = $"{EOrder.InCarShop}";
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetCarShop", new { id = carShop.Id }, carShop));
            }
            catch (Exception)
            {
                return(StatusCode(409));
            }
        }
예제 #12
0
 /// <summary>
 /// This command prints in console the number of all cars in warehouse
 /// </summary>
 public CountAllCommand(CarShop receiver)
 {
     this.Shop = receiver;
 }
예제 #13
0
        static void Main(string[] args)
        {
            #region Creational Pattern

            #region Singleton
            //var cacheManager = CacheManager.Instance;
            //cacheManager["a"] = "a";
            //Console.WriteLine(cacheManager["a"].ToString());
            //cacheManager = CacheManager.Instance;
            //cacheManager["a"] = "b";
            //Console.WriteLine(cacheManager["a"].ToString());
            #endregion

            #region Prototype

            //XSnake xsnake = new XSnake(10, 20, 100, "right", "red");
            //xsnake.ContainerId = "container1Id";
            //xsnake.Status = "snoozed";
            //// we need another snake object with the same configuration but with different container & status.
            //// instread of creating another one and giving it the same configuration we need some method to clone this
            //// object , say welcome to Protoype pattern which comes to the scene
            //XSnake snake2 = (XSnake)xsnake.Clone("container1Id2", "ready");
            //Console.WriteLine(snake2);

            #endregion

            #region Simple Factory Pattern [ Traditional ]

            //// this class is tightly coupled with SnakeFactory
            //// SnakeFactory violates Open/Closed Principle
            //ISnake snake = SnakeFactory.CreateSnake(SnakeType.Normal);
            //snake.Move();

            #endregion

            #region Factory Method
            //// so we need to let current class depend on abstract factory
            //// and let children to extend and decide which class to create
            //ISnakeFactory snakeFactory = new NormalSnakeFcatory();
            //snake = snakeFactory.CreateSnake();
            //snake.Move();


            //snakeFactory = new MediumSnakeFcatory();
            //snake = snakeFactory.CreateSnake();
            //snake.Move();

            //snakeFactory = new HardSnakeFcatory();
            //snake = snakeFactory.CreateSnake();
            //snake.Move();

            // now we resolved OCP principle and loosly coupling current class from concerete factory
            // so you can inject different child factories
            #endregion

            #region Abstract Fcatory

            //// application will choose which factory to use
            //IFurnitureFactory furnitureFactory = new AFurnitureFactory();
            //                  furnitureFactory = new BFurnitureFactory();

            //// but this code won't be affected by which factory is already in use [ no break ]
            //Chair chair = furnitureFactory.CreateChair();
            //Sofa sofa = furnitureFactory.CreateSofa();
            //CoffeeTable coffeeTable = furnitureFactory.CreateCoffeTable();
            #endregion

            #region Builder Pattern
            CarBuilder carBuilder = new XCarBuilder();
            CarShop    carShop    = new CarShop();
            var        car        = carShop.Construct(carBuilder);
            Console.WriteLine(car.Engine);
            #endregion

            #endregion
        }
예제 #14
0
 /// <summary>
 /// This Command prints in console the average price of all cars in warehouse
 /// </summary>
 public AveragePriceCommand(CarShop receiver)
 {
     this.Shop = receiver;
 }
예제 #15
0
 /// <summary>
 /// This command search the car by serial number and then remove it from warehouse
 /// </summary>
 public RemoveCarCommand(CarShop receiver, string serialNumber)
 {
     this.Shop         = receiver;
     this.SerialNumber = serialNumber;
 }
 /// <summary>
 /// This command prints in console the average price of cars of concrete brand which are in warehouse
 /// </summary>
 public AveragePriceTypeCommand(CarShop receiver, string brandName)
 {
     this.Shop      = receiver;
     this.BrandName = brandName;
 }
예제 #17
0
 /// <summary>
 /// This command prints in console the number of brands of cars in warehouse
 /// </summary>
 public CountTypesCommand(CarShop receiver)
 {
     this.Shop = receiver;
 }