Exemplo n.º 1
0
        public IEnumerable <IDanceStep> ParseSteps(string input)
        {
            var rawSteps            = input.Split(",", StringSplitOptions.RemoveEmptyEntries);
            List <IDanceStep> steps = new List <IDanceStep>();

            foreach (var rawStep in rawSteps)
            {
                switch (rawStep.First())
                {
                case 's':
                    steps.Add(Spin.CreateFromString(rawStep));
                    break;

                case 'x':
                    steps.Add(Exchange.CreateFromString(rawStep));
                    break;

                case 'p':
                    steps.Add(Partner.CreateFromString(rawStep));
                    break;

                default:
                    throw new Exception("Unrecognized dance format: " + rawStep);
                }
            }
            return(steps);
        }
        public void CreateFromStrings()
        {
            var spin = Spin.CreateFromString("s1");

            Assert.Equal(1, spin.Amount);

            spin = Spin.CreateFromString("s34233");
            Assert.Equal(34233, spin.Amount);
        }