Esempio n. 1
0
        public Migration001() : base(1)
        {
            Migration[MigrationStep.Migrate] = (database, dbProvider) =>
            {
                var studentTable = database.AddTable("Authors");
                studentTable.AddColumn("Id", typeof(Guid)).PrimaryKey().Clustered().NotNullable();
                studentTable.AddColumn("FirstName", typeof(string), 100);
                studentTable.AddColumn("LastName", typeof(string), 100);
                studentTable.AddColumn("Email", typeof(string), 100).NotNullable().Unique();
                studentTable.AddColumn("CreatedDate", typeof(DateTime)).NotNullable();
                studentTable.AddColumn("UpdatedDate", typeof(DateTime)).NotNullable();
                studentTable.AddColumn("IsDeleted", typeof(bool)).NotNullable(false);

                var courseTable = database.AddTable("Publishers");
                courseTable.AddColumn("Id", typeof(Guid)).PrimaryKey().NotNullable();
                courseTable.AddColumn("Name", typeof(string), 100).NotNullable();
                courseTable.AddColumn("Description", typeof(string), 100).NotNullable();
                courseTable.AddColumn("CreatedDate", typeof(DateTime)).NotNullable();
                courseTable.AddColumn("UpdatedDate", typeof(DateTime)).NotNullable();
                courseTable.AddColumn("IsDeleted", typeof(bool)).NotNullable(false);

                // OneToMany Relationship to Student
                var bookTable = database.AddTable("Books");
                bookTable.AddColumn("Id", typeof(Guid)).PrimaryKey().NotNullable();
                bookTable.AddColumn("PublisherId", typeof(Guid)).Nullable().ForeignKey("Publishers", "Id");
                bookTable.AddColumn("Name", typeof(string), 100).NotNullable();
                bookTable.AddColumn("ISBN", typeof(int)).Nullable();
                bookTable.AddColumn("PublishDate", typeof(DateTime)).NotNullable();
                bookTable.AddColumn("CreatedDate", typeof(DateTime)).NotNullable();
                bookTable.AddColumn("UpdatedDate", typeof(DateTime)).NotNullable();
                bookTable.AddColumn("IsDeleted", typeof(bool)).NotNullable(false);

                // ManyToMany Join Tables are currently handled under the covers (without an associated model)
                // Naming convention used by ORM is to joing the 2 table names together in alphabetical order
                var courseStudentTable = database.AddTable("Authors_Books").CompositeKey("AuthorId", "BookId", ClusterType.Clustered);
                courseStudentTable.AddColumn("BookId", typeof(Guid)).ForeignKey("Books", "Id").NotNullable();
                courseStudentTable.AddColumn("AuthorId", typeof(Guid)).ForeignKey("Authors", "Id").NotNullable();

                // Example of the inflection library at work
                var gooseTable = database.AddTable("Geese");
                gooseTable.AddColumn("Id", typeof(Guid)).PrimaryKey().NotNullable();
                gooseTable.AddColumn("Name", typeof(string), 100).Nullable();
            };

            Migration[MigrationStep.ServerAfterMigrate] = (database, dbProvider) =>
            {
                // Create some base data
                var bobsPublishing = new PublisherModel
                {
                    Id          = BobsPublishingId,
                    Name        = "Bob's publishing",
                    Description = "This is bobs publishing company.",
                };

                var randomHouse = new PublisherModel
                {
                    Id          = RandomHouseId,
                    Name        = "Random House",
                    Description = "This is a Canadian book publisher.",
                };

                dbProvider.Create(FixtureBase.UpdateBaseFields(randomHouse));
                dbProvider.Create(FixtureBase.UpdateBaseFields(bobsPublishing));

                var theHobbit = new BookModel
                {
                    Id        = TheHobbitId,
                    ISBN      = 4444,
                    Publisher = randomHouse,
                    Name      = "The Hobbit"
                };

                var screwTapeLetters = new BookModel
                {
                    Id        = TheScrewTapeLettersId,
                    ISBN      = 1234,
                    Publisher = randomHouse,
                    Name      = "The Screwtape Letters"
                };

                var theLionWitchWardrobe = new BookModel
                {
                    Id        = TheLionWitchWardrobeId,
                    ISBN      = 1234,
                    Publisher = randomHouse,
                    Name      = "The Lion the Witch and the Wardrobe"
                };

                dbProvider.Create(FixtureBase.UpdateBaseFields(theHobbit));
                dbProvider.Create(FixtureBase.UpdateBaseFields(screwTapeLetters));
                dbProvider.Create(FixtureBase.UpdateBaseFields(theLionWitchWardrobe));

                var jrTolkien = new AuthorModel
                {
                    Id        = AuthorJRTolkienId,
                    FirstName = "JR",
                    LastName  = "Tolkien",
                    Email     = JRTolkien,
                };

                jrTolkien.AddBooks(theHobbit);

                var csLewis = new AuthorModel
                {
                    Id        = AuthorCSLewisId,
                    FirstName = "CS",
                    LastName  = "Lewis",
                    Email     = CSLewisEmail,
                };
                csLewis.AddBooks(screwTapeLetters, theLionWitchWardrobe);

                dbProvider.Create(FixtureBase.UpdateBaseFields(jrTolkien));
                dbProvider.Create(FixtureBase.UpdateBaseFields(csLewis));
            };
        }
 protected TestsBase(FixtureBase fixture, string path)
 {
     Browser = fixture.Browser;
     Browser.Navigate().GoToUrl(new Uri($"{fixture.ServerUrl}{path}"));
 }
Esempio n. 3
0
        public override void ServerAfterMigrate()
        {
            // Create some base data
            var bobsPublishing = new PublisherModel
            {
                Id          = BobsPublishingId,
                Name        = "Bob's publishing",
                Description = "This is bobs publishing company.",
            };

            var randomHouse = new PublisherModel
            {
                Id          = RandomHouseId,
                Name        = "Random House",
                Description = "This is a Canadian book publisher.",
            };

            DbProvider.Create(FixtureBase.UpdateBaseFields(randomHouse));
            DbProvider.Create(FixtureBase.UpdateBaseFields(bobsPublishing));

            var theHobbit = new BookModel
            {
                Id        = TheHobbitId,
                ISBN      = 4444,
                Publisher = randomHouse,
                Name      = "The Hobbit"
            };

            var screwTapeLetters = new BookModel
            {
                Id        = TheScrewTapeLettersId,
                ISBN      = 1234,
                Publisher = randomHouse,
                Name      = "The Screwtape Letters"
            };

            var theLionWitchWardrobe = new BookModel
            {
                Id        = TheLionWitchWardrobeId,
                ISBN      = 1234,
                Publisher = randomHouse,
                Name      = "The Lion the Witch and the Wardrobe"
            };

            DbProvider.Create(FixtureBase.UpdateBaseFields(theHobbit));
            DbProvider.Create(FixtureBase.UpdateBaseFields(screwTapeLetters));
            DbProvider.Create(FixtureBase.UpdateBaseFields(theLionWitchWardrobe));

            var jrTolkien = new AuthorModel
            {
                Id        = AuthorJRTolkienId,
                FirstName = "JR",
                LastName  = "Tolkien",
                Email     = JRTolkien,
            };

            jrTolkien.AddBooks(theHobbit);

            var csLewis = new AuthorModel
            {
                Id        = AuthorCSLewisId,
                FirstName = "CS",
                LastName  = "Lewis",
                Email     = CSLewisEmail,
            };

            csLewis.AddBooks(screwTapeLetters, theLionWitchWardrobe);

            DbProvider.Create(FixtureBase.UpdateBaseFields(jrTolkien));
            DbProvider.Create(FixtureBase.UpdateBaseFields(csLewis));
        }
Esempio n. 4
0
 public AppPersonTest(FixtureBase context) : base(context)
 {
 }
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            string          name      = (sender as MenuItem).Header.ToString();
            WindowOperation operation = WindowOperation.Add;

            if (name.Contains("车型"))
            {
                CarProject car = (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Car;

                switch (name.Substring(0, 2))
                {
                case "新建":
                    cmbCType.SelectedIndex = -1;
                    (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Car = new CarProject();
                    operation = WindowOperation.Add;
                    break;

                case "修改":
                    if (car == null)
                    {
                        MessageBox.Show("请选择一个车型!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    operation = WindowOperation.Update;
                    break;

                case "删除":
                    if (car == null)
                    {
                        MessageBox.Show("请选择一个车型!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    operation = WindowOperation.Delete;
                    break;

                default:
                    break;
                }

                CarTypeWindow carTypeWindow = new CarTypeWindow(operation);
                carTypeWindow.ShowDialog();
            }
            else if (name.Contains("线束"))
            {
                WireType wire = (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Wire;
                switch (name.Substring(0, 2))
                {
                case "新建":
                    partcmb.SelectedIndex = -1;
                    (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Wire = new WireType();
                    operation = WindowOperation.Add;
                    break;

                case "修改":
                    if (wire == null)
                    {
                        MessageBox.Show("请选择一个线束!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    operation = WindowOperation.Update;
                    break;

                case "删除":
                    if (wire == null)
                    {
                        MessageBox.Show("请选择一个线束!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    operation = WindowOperation.Delete;
                    break;

                default:
                    break;
                }
                WireWindow wireWindow = new WireWindow(operation);
                wireWindow.ShowDialog();
            }
            else if (name.Contains("工程"))
            {
                ExcelProject project = (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Project;
                switch (name.Substring(0, 2))
                {
                case "新建":
                    projectcmb.SelectedIndex = -1;
                    (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Project = new ExcelProject();
                    operation = WindowOperation.Add;
                    break;

                case "修改":
                    if (project == null)
                    {
                        MessageBox.Show("请选择一个工程!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    operation = WindowOperation.Update;
                    break;

                case "删除":
                    if (project == null)
                    {
                        MessageBox.Show("请选择一个工程!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    operation = WindowOperation.Delete;
                    break;

                default:
                    break;
                }
                ExcelProjectWindow excelProjectWindow = new ExcelProjectWindow(operation);
                excelProjectWindow.ShowDialog();
            }
            else if (name.Contains("治具"))
            {
                FixtureBase fixture = (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Fixture;
                switch (name.Substring(0, 2))
                {
                case "新建":
                    cmbFixture.SelectedIndex = -1;
                    (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Project = new ExcelProject();
                    operation = WindowOperation.Add;
                    break;

                case "修改":
                    if (fixture == null)
                    {
                        MessageBox.Show("请选择一个治具!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    operation = WindowOperation.Update;
                    break;

                case "删除":
                    if (fixture == null)
                    {
                        MessageBox.Show("请选择一个治具!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    operation = WindowOperation.Delete;
                    break;

                default:
                    break;
                }
                ExFixtureWindow fixtureWindow = new ExFixtureWindow(operation);
                fixtureWindow.ShowDialog();
            }
        }
Esempio n. 6
0
 protected TwoDatabasesTestBase(FixtureBase fixture)
 {
     Fixture = fixture;
 }
Esempio n. 7
0
        public async Task GetScanImage()
        {
            var actual = await NetverifyClient.GetScanImageAsync(_scanReference, Classifier.Front, Maskhint.Masked);

            Assert.Equal(actual, FixtureBase.GetBase64Image("passport.usa.jpg"));
        }
 protected SelectorTests(FixtureBase fixture, string path, Func <string, TSelector> selectorAccessor)
     : base(fixture, path) => _selectorAccessor = selectorAccessor;
Esempio n. 9
0
 public abstract FixtureBuilder Init(FixtureBase fixtureBase);
        private void Add()
        {
            FixtureBase fixture = (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Fixture;

            switch (Operation)
            {
            case WindowOperation.Add:
                if (QualityCheck())
                {
                    try
                    {
                        Bitmap bitmap = new Bitmap(filepath);
                        if (folderExist(System.Environment.CurrentDirectory + "\\Image\\" + "ExcelProject"))
                        {
                            filepath = System.Environment.CurrentDirectory + "\\Image\\" + "ExcelProject" + "\\" + System.IO.Path.GetFileName(filepath);
                        }
                        else
                        {
                            folderCreate(System.Environment.CurrentDirectory + "\\Image\\" + "ExcelProject");
                            filepath = System.Environment.CurrentDirectory + "\\Image\\" + "ExcelProject" + "\\" + System.IO.Path.GetFileName(filepath);
                        }
                        bitmap.Save(filepath);
                        bitmap.Dispose();
                    }
                    catch (Exception ex)
                    {
                        System.Windows.MessageBox.Show("工程中已经存在同名的图片,请将图片重命名后再导入", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                    int row = SQliteDbContext.AddFixtureBaseInfo(fixture);
                    if (row > 0)
                    {
                        System.Windows.MessageBox.Show("添加成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                        this.Close();
                    }
                }

                break;

            case WindowOperation.Update:
                if (QualityCheck())
                {
                    int rs = SQliteDbContext.UpdateFixtureBaseInfo(fixture);
                    if (rs > 0)
                    {
                        System.Windows.MessageBox.Show("更新成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                        this.Close();
                    }
                }
                break;

            case WindowOperation.Delete:
                int rd = SQliteDbContext.DeleteFixtureBaseInfo(fixture);
                if (rd > 0)
                {
                    System.Windows.MessageBox.Show("删除成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    this.Close();
                }
                break;

            default:
                break;
            }
            (App.Current.Resources["Locator"] as ViewModelLocator).ExcelPaper.Fixtures = new System.Collections.ObjectModel.ObservableCollection <FixtureBase>(SQliteDbContext.GetAllFixtureBaseInfos());
        }