示例#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);
        }
示例#2
0
        public void CreateFromStrings()
        {
            var partner = Partner.CreateFromString("pA/B");

            Assert.Equal('A', partner.First);
            Assert.Equal('B', partner.Second);
        }