Example #1
0
        private int ProcessBatch2(IList <string> batch)
        {
            var form = new CustomsForm(batch);

            batch.Clear();

            return(form.GetValue2());
        }
        public void CustomsCountUnique_WithOneSimplePassenger_ShouldReturn2()
        {
            List <HashSet <char> > data = new List <HashSet <char> > {
                new HashSet <char>()
                {
                    'a', 'b'
                }
            };
            CustomsForm form = new CustomsForm(data);

            Assert.Equal(2, form.GetUniqueAnswersInGroup());
        }
        public void CustomsCountAll_WithTwoSimplePassengers_ShouldReturn4()
        {
            List <HashSet <char> > data = new List <HashSet <char> > {
                new HashSet <char>()
                {
                    'a', 'b', 'c'
                },
                new HashSet <char>()
                {
                    'd'
                }
            };
            CustomsForm form = new CustomsForm(data);

            Assert.Equal(4, form.GetAllAnswersInGroup());
        }
        public void SumCountPart2_WithTestInput_ShouldReturn6()
        {
            string testInput = @"abc

                a
                b
                c

                ab
                ac

                a
                a
                a
                a

                b";

            string[] customsData = new List <string>(
                testInput.Split(Environment.NewLine)
                )
                                   .Select(s => s.Trim())
                                   .ToArray();

            int            uniqueCustomsAnswers = 0;
            CustomsBuilder customsBuilder       = new CustomsBuilder();

            for (int i = 0; i <= customsData.Length; i++)
            {
                if (i == customsData.Length || IsAnEmptyLine(customsData[i]))
                {
                    CustomsForm form = customsBuilder.CreateForm();
                    uniqueCustomsAnswers += form.GetUniqueAnswersInGroup();
                    customsBuilder        = new CustomsBuilder();
                }
                else
                {
                    customsBuilder.AddAnswersToGroup(customsData[i]);
                }
            }

            Assert.Equal(6, uniqueCustomsAnswers);
        }
        public void CustomsCountUnique_WithThreeComplexPassengers_ShouldReturn3()
        {
            List <HashSet <char> > data = new List <HashSet <char> > {
                new HashSet <char>()
                {
                    'a', 'b', 'c'
                },
                new HashSet <char>()
                {
                    'a', 'b', 'c', 'd', 'e', 'f'
                },
                new HashSet <char>()
                {
                    'a', 'b', 'c', 'd', 'e', 'f', 'x', 'y', 'z'
                },
            };
            CustomsForm form = new CustomsForm(data);

            Assert.Equal(3, form.GetUniqueAnswersInGroup());
        }
Example #6
0
 public void CustomsForm_WhenConstructed_InitialisesAsExpected()
 {
     _customsForm = new CustomsForm("abxy");
     Assert.That(_customsForm.answeredYes, Is.EqualTo("abxy"));
 }