public void PropertyChanged_IsSelected_ColumnsSelection([Values(true, false)] bool isSelected)
        {
            // Arrange
            var vm = new TableInformationViewModel
            {
                Name          = "dbo.album",
                ObjectType    = ObjectType.Table,
                HasPrimaryKey = true,
                IsSelected    = isSelected,
            };

            vm.Columns.Add(new ColumnInformationViewModel {
                Name = "column1"
            });
            vm.Columns.Add(new ColumnInformationViewModel {
                Name = "column2"
            });
            vm.Columns.Add(new ColumnInformationViewModel {
                Name = "column3"
            });


            // Act
            vm.IsSelected = !isSelected;

            // Assert
            Assert.IsTrue(vm.Columns.All(c => c.IsSelected == !isSelected));
        }
        private TableInformationViewModel CreateTable(string name)
        {
            var messenger = new Mock <IMessenger>();

            messenger.SetupAllProperties();
            var result = new TableInformationViewModel(messenger.Object);

            result.Name = name;
            return(result);
        }
Beispiel #3
0
        public void PropertyChanged_IsSelected_SaveValue()
        {
            // Arrange
            var propertyChangedInvoked = false;
            var tim = new TableInformationModel("dbo.Album", true);
            var vm  = new TableInformationViewModel
            {
                Model      = tim,
                IsSelected = true
            };

            vm.PropertyChanged += (sender, args) => propertyChangedInvoked = true;

            // Act
            vm.IsSelected = true;

            // Assert
            Assert.IsFalse(propertyChangedInvoked);
        }
        public void PropertyChanged_HasPrimaryKey_SameValue()
        {
            // Arrange
            var propertyChangedInvoked = false;
            var vm = new TableInformationViewModel
            {
                Name          = "dbo.album",
                ObjectType    = ObjectType.Table,
                HasPrimaryKey = true,
                IsSelected    = true
            };

            vm.PropertyChanged += (sender, args) => propertyChangedInvoked = true;

            // Act
            vm.HasPrimaryKey = true;

            // Assert
            Assert.IsFalse(propertyChangedInvoked);
        }
Beispiel #5
0
        public void PropertyChanged_IsSelected_DifferentValue()
        {
            // Arrange
            var changedProperties = new List <string>();
            var tim = new TableInformationModel("dbo.Album", true);
            var vm  = new TableInformationViewModel
            {
                Model      = tim,
                IsSelected = true
            };

            vm.PropertyChanged += (sender, args) => changedProperties.Add(args.PropertyName);

            // Act
            vm.IsSelected = false;

            // Assert
            Assert.AreEqual(1, changedProperties.Count);
            Assert.AreEqual(nameof(TableInformationViewModel.IsSelected), changedProperties[0]);
        }
        private static ITableInformationViewModel[] GetTestViewModels()
        {
            var r = new ITableInformationViewModel[6];

            r[0] = new TableInformationViewModel
            {
                IsSelected = false,
                Model      = new TableInformationModel("[dbo].[Atlas]", true)
            };
            r[1] = new TableInformationViewModel
            {
                IsSelected = true,
                Model      = new TableInformationModel("[__].[RefactorLog]", false)
            };
            r[2] = new TableInformationViewModel
            {
                IsSelected = true,
                Model      = new TableInformationModel("[dbo].[__RefactorLog]", true)
            };
            r[3] = new TableInformationViewModel
            {
                IsSelected = true,
                Model      = new TableInformationModel("[dbo].[sysdiagrams]", true)
            };
            r[4] = new TableInformationViewModel
            {
                IsSelected = true,
                Model      = new TableInformationModel("unit.test", true)
            };
            r[5] = new TableInformationViewModel
            {
                IsSelected = true,
                Model      = new TableInformationModel("unit.foo", false)
            };

            return(r);
        }
Beispiel #7
0
        private static ITableInformationViewModel[] GetTestViewModels()
        {
            var r = new ITableInformationViewModel[6];

            r[0] = new TableInformationViewModel
            {
                IsSelected    = false,
                HasPrimaryKey = true,
                Name          = "[dbo].[Atlas]",
            };
            r[0].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "Id"
            });
            r[0].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column1"
            });
            r[0].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column2"
            });

            r[1] = new TableInformationViewModel
            {
                IsSelected    = true,
                HasPrimaryKey = true,
                Name          = "[__].[RefactorLog]",
            };
            r[1].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "Id"
            });
            r[1].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column1"
            });
            r[1].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column2"
            });

            r[2] = new TableInformationViewModel
            {
                IsSelected    = true,
                HasPrimaryKey = true,
                Name          = "[dbo].[__RefactorLog]",
            };
            r[2].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "Id"
            });
            r[2].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column1"
            });
            r[2].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column2"
            });

            r[3] = new TableInformationViewModel
            {
                IsSelected    = true,
                HasPrimaryKey = true,
                Name          = "[dbo].[sysdiagrams]",
            };
            r[3].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "Id"
            });
            r[3].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column1"
            });
            r[3].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column2"
            });

            r[4] = new TableInformationViewModel
            {
                IsSelected    = true,
                HasPrimaryKey = true,
                Name          = "unit.test",
            };
            r[4].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "Id"
            });
            r[4].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column1"
            });
            r[4].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column2"
            });

            r[5] = new TableInformationViewModel
            {
                IsSelected    = true,
                HasPrimaryKey = true,
                Name          = "unit.foo",
            };
            r[5].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "Id"
            });
            r[5].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column1"
            });
            r[5].Columns.Add(new ColumnInformationViewModel
            {
                IsSelected = true,
                Name       = "column2"
            });

            return(r);
        }
        private static ISchemaInformationViewModel[] GetDatabaseObjects()
        {
            TableInformationViewModel CreateTable(string tableSchema, string name, bool selected)
            {
                var messenger = new Mock <IMessenger>();

                messenger.SetupAllProperties();
                var result = new TableInformationViewModel(messenger.Object);

                result.Name   = name;
                result.Schema = tableSchema;
                if (selected)
                {
                    result.SetSelectedCommand.Execute(true);
                }
                return(result);
            }

            ColumnInformationViewModel CreateColumn(string name, bool isPrimaryKey, bool selected)
            {
                var messenger = new Mock <IMessenger>();

                messenger.SetupAllProperties();
                var result = new ColumnInformationViewModel(messenger.Object);

                result.Name         = name;
                result.IsPrimaryKey = isPrimaryKey;
                if (selected)
                {
                    result.SetSelectedCommand.Execute(true);
                }
                return(result);
            }

            var schema0 = new SchemaInformationViewModel {
                Name = "dbo"
            };

            schema0.Objects.Add(CreateTable("dbo", "Atlas", false));
            schema0.Objects[0].Columns.Add(CreateColumn("id", true, false));
            schema0.Objects[0].Columns.Add(CreateColumn("column1", false, false));
            schema0.Objects[0].Columns.Add(CreateColumn("column2", false, false));

            schema0.Objects.Add(CreateTable("dbo", "__RefactorLog", true));
            schema0.Objects[1].Columns.Add(CreateColumn("id", true, false));
            schema0.Objects[1].Columns.Add(CreateColumn("column1", false, false));
            schema0.Objects[1].Columns.Add(CreateColumn("column2", false, false));

            schema0.Objects.Add(CreateTable("dbo", "sysdiagrams", false));
            schema0.Objects[2].Columns.Add(CreateColumn("id", true, false));
            schema0.Objects[2].Columns.Add(CreateColumn("column1", false, false));
            schema0.Objects[2].Columns.Add(CreateColumn("column2", false, false));

            schema0.Objects.Add(CreateTable("dbo", "sysdiagrams", false));
            schema0.Objects[2].Columns.Add(CreateColumn("id", true, false));
            schema0.Objects[2].Columns.Add(CreateColumn("column1", false, false));
            schema0.Objects[2].Columns.Add(CreateColumn("column2", false, false));

            var schema1 = new SchemaInformationViewModel {
                Name = "unit"
            };

            schema1.Objects.Add(CreateTable("unit", "test", false));
            schema1.Objects[0].Columns.Add(CreateColumn("id", true, false));
            schema1.Objects[0].Columns.Add(CreateColumn("column1", false, false));
            schema1.Objects[0].Columns.Add(CreateColumn("column2", false, false));

            schema1.Objects.Add(CreateTable("unit", "foo", true));
            schema1.Objects[1].Columns.Add(CreateColumn("id", true, false));
            schema1.Objects[1].Columns.Add(CreateColumn("column1", false, false));
            schema1.Objects[1].Columns.Add(CreateColumn("column2", false, false));

            return(new[] { schema0, schema1 });
        }