private Track getSuggestedTrack()
        {
            Bpm bpm = new Bpm(null);
            Year year = new Year(null);
            Ending ending = new Ending(Ending.Attribute.None);

            int temp;
            if(!String.IsNullOrEmpty(tbBpm.Text) && int.TryParse(tbBpm.Text, out temp))
                bpm.Value = temp;
            if(!String.IsNullOrEmpty(tbYear.Text) && int.TryParse(tbYear.Text, out temp))
                year.Value = temp;
            if(!String.IsNullOrEmpty(tbEnding.Text))
                if(new List<string>(Enum.GetNames(typeof(Ending.Attribute))).Contains(tbEnding.Text))
                    ending.Value = (Ending.Attribute)Enum.Parse(typeof(Ending.Attribute), tbEnding.Text);

            Track track = new Track(
                new Autor(String.IsNullOrEmpty(tbAutor.Text) ? " " : tbAutor.Text),
                bpm,
                new Code(String.IsNullOrEmpty(tbCode.Text) ? " " : tbCode.Text),
                new Interpret(String.IsNullOrEmpty(tbInterpret.Text) ? " " : tbInterpret.Text),
                new Label(String.IsNullOrEmpty(tbLabel.Text) ? " " : tbLabel.Text),
                new Laenge(String.IsNullOrEmpty(tbLaenge.Text) ? " " : tbLaenge.Text),
                new Titel(String.IsNullOrEmpty(tbTitel.Text) ? " " : tbTitel.Text),
                new Verlag(String.IsNullOrEmpty(tbVerlag.Text) ? " " : tbVerlag.Text),
                year,
                ending);

            return track;
        }
示例#2
0
 public void take_only_year_part_of_ctor_arg()
 {
     sut = new Year((ushort)DateTime.Now.Year);
     Assert.AreEqual(2011, sut.Value);
 }