public DbDipViewModel()
        {
            Corpuses = new ObservableCollection <DipCorpus>();
            foreach (var corpus in CorpusesStorage.AllCorpuses())
            {
                Corpuses.Add(corpus);
            }
            AddCommand = new ActionCommand(() =>
            {
                StartProgress();

                var editor = GenericEdit.Create(new DipCorpus
                {
                    Name          = "Новий корпус",
                    PinCount      = 8,
                    CorpusWidthMm = 6
                }, corpus =>
                {
                    Corpuses.Add(corpus);
                    SaveCorpuses();
                });

                editor.ShowDialog();

                CompleteProgress();
            });

            EditCommand = new ActionCommand <DipCorpus>(item =>
            {
                StartProgress();
                // TODO Should copy instead of modification
                var editor = GenericEdit.Create(item, corpus =>
                {
                    SaveCorpuses();
                });

                editor.ShowDialog();

                CompleteProgress();
            });

            RemoveCommand = new ActionCommand <DipCorpus>(item =>
            {
                StartProgress();

                Corpuses.Remove(item);
                SaveCorpuses();

                CompleteProgress();
            });

            GenerateCommand = new ActionCommand <DipCorpus>(item =>
            {
                StartProgress();

                new DipBuilder(new SwContext()).Build(item);

                CompleteProgress();
            });
        }
        public void Should_save_query_components()
        {
            Db.Reset();
            CorpusesStorage.Save(new[]
            {
                new DipCorpus
                {
                    Name          = "DIP8",
                    PinCount      = 8,
                    CorpusWidthMm = 6.0
                },
                new DipCorpus
                {
                    Name          = "DIP24",
                    PinCount      = 24,
                    CorpusWidthMm = 10.0
                }
            });

            var corpuses = CorpusesStorage.AllCorpuses();

            corpuses.Should().HaveCount(2);
            var dip8 = corpuses.First(x => x.Name == "DIP8");

            dip8.PinCount.Should().Be(8);
            dip8.CorpusWidthMm.Should().Be(6.0);
        }
 private void SaveCorpuses()
 {
     CorpusesStorage.Save(Corpuses);
 }