コード例 #1
0
        public IHttpActionResult Get()
        {
            var pizzas = new PizzaList(this._repository);
            IEnumerable <PizzaItemDto> pizzasList;
            string userName = User.Identity.Name;

            pizzasList = pizzas.GetPizzasListByUserFullName(userName);

            return(Ok <IEnumerable <PizzaItemDto> >(pizzasList));
        }
コード例 #2
0
        public void GetPizzasListByUserFullName_ExistingUserName_ReturnsListOfPizzas()
        {
            var              mock       = new Mock <IPizzaRepository>();
            string           name       = "John";
            List <PizzaItem> pizzaItems = new List <PizzaItem>()
            {
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 1, new Contact(), new User("John", "John`s email"))
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 2, new Contact(), new User("John", "John`s email"))
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 3, new Contact(), new User("John", "John`s email"))
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 4, new Contact(), new User("Sam", "John`s email"))
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 5, new Contact(), new User("Sam", "John`s email"))
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 6, new Contact(), new User("Sam", "John`s email"))
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 7, new Contact(), new User("John", "John`s email"))
                }
            };

            mock.Setup(moq => moq.GetList(It.IsAny <Expression <Func <PizzaItem, bool> > >())).Returns(pizzaItems.Where(p => p.Order.User.Name == name));

            PizzaList pizzaList = new PizzaList(mock.Object);
            int       expected  = 4;

            int actual = pizzaList.GetPizzasListByUserFullName(name).Count;

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void SetOptions()
        {
            MenuOptions.Add("1. Cancel");
            MenuOptions.Add("2. Preview Order");
            MenuOptions.Add("3. Build Your Own");
            var i         = 3;
            var pizzaList = DataAccessor.GetPresetPizzas();

            foreach (var pizzaID in pizzaList)
            {
                i++;
                APizza newPizza = Factory.CreateAPizza();
                newPizza.BuildPizzaFromData(DataAccessor.CreatePresetPizza(pizzaID));
                PizzaList.Add(newPizza);
                MenuOptions.Add($"{i}. {newPizza.Name}");
            }
        }
コード例 #4
0
        public void GetPizzaList_NoParams_ReturnsListOfPizzas()
        {
            var mock = new Mock <IPizzaRepository>();
            List <PizzaItem> pizzaItems = new List <PizzaItem>()
            {
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 0, new Contact())
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 0, new Contact())
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 0, new Contact())
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 0, new Contact())
                },
                new PizzaItem()
                {
                    Order = new Order(new Guid(), 0, new Contact())
                }
            };

            mock.Setup(moq => moq.GetList(null)).Returns(pizzaItems);
            PizzaList pizzaList = new PizzaList(mock.Object);
            int       expected  = pizzaItems.Count;

            int actual = pizzaList.GetPizzasList().Count;

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
ファイル: PizzaSolver.cs プロジェクト: DudePascalou/HashCode
        public PizzaSolver(StreamReader inputStream)
        {
            int[] config = inputStream.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            NbRows        = config[0];
            NbColumns     = config[1];
            MinIngredient = config[2];
            MaxSliceCells = config[3];

            Pizza = new int[NbRows, NbColumns];
            for (int y = 0; y < NbRows; ++y)
            {
                string line = inputStream.ReadLine();
                for (int x = 0; x < NbColumns; ++x)
                {
                    Pizza[y, x] = line[x] == 'T' ? 1 : 2;
                }
            }

            NbTomatoes                   = PizzaList.Count(c => c == 1);
            NbMushrooms                  = PizzaList.Count(c => c == 2);
            NbCells                      = NbRows * NbColumns;
            TheoreticalBestNbSlices      = (int)Math.Ceiling((double)NbCells / MaxSliceCells);
            TheoreticalMaxPossibleSlices = Math.Min(NbTomatoes, NbMushrooms) / MinIngredient;
        }
コード例 #6
0
 public void RemovePizza(Pizza pizza)
 {
     PizzaList.Remove(pizza);
 }
コード例 #7
0
 public void AddPizza(Pizza pizza)
 {
     PizzaList.Add(pizza);
 }