Ejemplo n.º 1
0
        public void ReturnTwo_WhenGivenAContainedBag()
        {
            var bags = new Bags(@"bright white bags contain 1 shiny gold bag.
muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.");

            Assert.Equal(2, bags.ThatContainBagOf("shiny gold"));
        }
Ejemplo n.º 2
0
        private List <Bags> GenerateBagList(string[] input = null)
        {
            if (input == null && _bagList != null)
            {
                return(_bagList);
            }
            var bagRules      = new List <Bags>();
            var bagRuleParser = new Regex("(?:(.*) bags(?: contain ))?( ?(\\d) ?([a-z ]*)(?: bags| bag))", RegexOptions.Compiled);

            // All bags in array with their name and a list of what they can contain
            foreach (var bag in input)
            {
                var bags = bagRuleParser.Matches(bag);
                if (bags.Count > 0)
                {
                    var container = bags[0].Groups[1].Value;
                    foreach (Match bagParsed in bags)
                    {
                        var bagInRule = new Bags()
                        {
                            Container    = container,
                            Bag          = bagParsed.Groups[4].Value,
                            NumberOfBags = StringsAndInts.ConvertStringToInt(bagParsed.Groups[3].Value)
                        };
                        bagRules.Add(bagInRule);
                    }
                }
            }

            _bagList = bagRules;
            return(bagRules);
        }
Ejemplo n.º 3
0
        public void Return126_WhenFindingBagsThatCanBeContainedInShinyGoldOne()
        {
            const string rules = @"shiny gold bags contain 2 dark red bags.
dark red bags contain 2 dark orange bags.
dark orange bags contain 2 dark yellow bags.
dark yellow bags contain 2 dark green bags.
dark green bags contain 2 dark blue bags.
dark blue bags contain 2 dark violet bags.
dark violet bags contain no other bags.";

            var bags = new Bags(rules);

            Assert.Equal(126, bags.ContainedBy("shiny gold"));
        }
Ejemplo n.º 4
0
        public void Return32_WhenFindingBagsThatCanBeContainedInShinyGoldOne()
        {
            const string rules = @"light red bags contain 1 bright white bag, 2 muted yellow bags.
dark orange bags contain 3 bright white bags, 4 muted yellow bags.
bright white bags contain 1 shiny gold bag.
muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.
shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags.
dark olive bags contain 3 faded blue bags, 4 dotted black bags.
vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.
faded blue bags contain no other bags.
dotted black bags contain no other bags.";

            var bags = new Bags(rules);

            Assert.Equal(32, bags.ContainedBy("shiny gold"));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bags = await _context.Bags.FindAsync(id);

            if (Bags != null)
            {
                _context.Bags.Remove(Bags);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 6
0
 protected override void classInit()
 {
     this.bags = Bags.none;
 }                
Ejemplo n.º 7
0
        /// <summary>
        /// PostRequest - Use 'PostRequestParams' to pass parameters into this method.
        /// </summary>
        public void PostRequest(Smoking smoking, Bags bags)
        {
            #region Variable Declarations
            HtmlEdit uIPostInputEdit = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIPostInputEdit;
            HtmlSpan uIBeershebaPane1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIBeershebaPane1;
            HtmlEdit uIPostInputEdit1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIPostInputEdit1;
            HtmlSpan uIIsraelPane1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIIsraelPane1;
            HtmlRadioButton uINORadioButton1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UINORadioButton1;
            HtmlRadioButton uIYesRadioButton1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIYesRadioButton1;
            HtmlRadioButton uIDontcareRadioButton1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIDontcareRadioButton1;
            HtmlRadioButton uIBigbagRadioButton1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIBigbagRadioButton1;
            HtmlRadioButton uINoneSmallbagRadioButton1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UINoneSmallbagRadioButton1;
            HtmlEdit uIDateEdit1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIDateEdit1;
            HtmlEdit uIPostFromTimeInputEdit1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIPostFromTimeInputEdit1;
            HtmlEdit uIPostToTimeInputEdit1 = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIPostToTimeInputEdit1;
            HtmlInputButton uIPostButton = this.UIRideShareWindowsInteWindow.UIRideShareDocument.UIPostContentPane2.UIPostButton;
            #endregion

            // Type 'beersheba' in 'postInput' text box
            uIPostInputEdit.Text = this.PostRequestParams.UIPostInputEditText;
            Thread.Sleep(2000);
            Keyboard.SendKeys("{Down}");
            Keyboard.SendKeys("{Enter}");
            //try
            //{
            //    // Click 'Beersheba' pane
            //    Mouse.Click(uIBeershebaPane1, new Point(641, 348));
            //}
            //catch { }

            // Type 'haifa' in 'postInput' text box
            uIPostInputEdit1.Text = this.PostRequestParams.UIPostInputEdit1Text;
            Thread.Sleep(2000);
            Keyboard.SendKeys("{Down}");
            Keyboard.SendKeys("{Enter}");
            //try
            //{
            //    // Click 'Israel' pane
            //    Mouse.Click(uIIsraelPane1, new Point(20, 4));
            //}
            //catch { }

            // Select 'No' radio button
            if (smoking == Smoking.no)
                uINORadioButton1.Selected = this.PostRequestParams.UINORadioButton1Selected;

            // Select 'Yes' radio button
            if (smoking == Smoking.yes)
                uIYesRadioButton1.Selected = this.PostRequestParams.UIYesRadioButton1Selected;

            // Select 'Dont care' radio button
            if (smoking == Smoking.dontCare)
                uIDontcareRadioButton1.Selected = this.PostRequestParams.UIDontcareRadioButton1Selected;

            // Select 'Big bag' radio button
            if (bags == Bags.big_bag)
                uIBigbagRadioButton1.Selected = this.PostRequestParams.UIBigbagRadioButton1Selected;

            // Select 'None/Small bag' radio button
            if (bags == Bags.none)
                uINoneSmallbagRadioButton1.Selected = this.PostRequestParams.UINoneSmallbagRadioButton1Selected;

            // Type '2015-07-28' in 'Date' text box
            uIDateEdit1.Text = this.PostRequestParams.UIDateEdit1Text;

            // Type '02:36' in 'postFromTimeInput' text box
            uIPostFromTimeInputEdit1.Text = this.PostRequestParams.UIPostFromTimeInputEdit1Text;

            // Type '02:37' in 'postToTimeInput' text box
            uIPostToTimeInputEdit1.Text = this.PostRequestParams.UIPostToTimeInputEdit1Text;

            // Click 'Post' button
            Mouse.Click(uIPostButton, new Point(68, 12));
        }