public void CanUpdateOwnProduct() { var entityPropertyCollection = OwnProductProperties.Get(); var properties = entityPropertyCollection.Properties.ToList(); properties.RemoveAll(p => p.Name == "ImportCode" || p.Name == "Name"); entityPropertyCollection.Properties = properties; entityPropertyCollection.PrimaryEntityColumnName = "OwnSiteID"; entityPropertyCollection.PrimaryEntityTableName = "PNOwnSite"; entityPropertyCollection.PrimaryEntityIds = new int[] { 1, 2 }; entityPropertyCollection.SecondaryEntityColumnName = "GlobalProductID"; entityPropertyCollection.SecondaryEntityIds = new int[] { 1 }; entityPropertyCollection.SecondaryEntityTableName = "PNGlobalProduct"; Test(entityPropertyCollection); var p1 = entityPropertyCollection.Properties.First(); p1.InitialValue = false; //foreach (var property in entityPropertyCollection.Properties) //{ // property.in //} var command = PriceNetSqlGenerator.GenerateUpdateCommand(entityPropertyCollection); ParseSql(command.CommandText); TestCommand(command); }
public void TableNameNull() { var entityPropertyCollection = CreateEntityPropertyCollection(); entityPropertyCollection.TableName = null; var command = PriceNetSqlGenerator.GenerateInsertCommand(entityPropertyCollection); }
public void CanInsertOwnSite() { var entityPropertyCollection = OwnSiteProperties.Get(); var command = PriceNetSqlGenerator.GenerateInsertCommand(entityPropertyCollection); ParseSql(command.CommandText); TestCommand(command); }
public void CanInsertCompetitorProduct() { var propertyCollection = CompetitorProductProperties.Get(); var command = PriceNetSqlGenerator.GenerateInsertCommand(propertyCollection); ParseSql(command.CommandText); TestCommand(command); }
public void CanGeneratePriceNetInsert() { var entityPropertyCollection = CreateEntityPropertyCollection(); entityPropertyCollection.Properties = new[] { CreateNameProperty(), CreateImportCodeProperty() }; var command = PriceNetSqlGenerator.GenerateInsertCommand(entityPropertyCollection); Assert.IsFalse(string.IsNullOrEmpty(command.CommandText)); }
public void ValidSqlUpdateGenerated() { var entityPropertyCollection = CreateEntityPropertyCollection(); entityPropertyCollection.Properties = new[] { CreateNameProperty(), CreateImportCodeProperty() }; //entityPropertyCollection.PrimaryEntityColumnName = "AreaID"; entityPropertyCollection.PrimaryEntityIds = new[] { 1 }; entityPropertyCollection.PrimaryEntityTableName = "Area"; var command = PriceNetSqlGenerator.GenerateUpdateCommand(entityPropertyCollection); ParseSql(command.CommandText); TestCommand(command); }
public void ValidSqlInsertGenerated() { var entityPropertyCollection = CreateEntityPropertyCollection(); entityPropertyCollection.Properties = new[] { CreateNameProperty(), CreateImportCodeProperty() }; entityPropertyCollection.PrimaryEntityColumnName = null; entityPropertyCollection.PrimaryEntityIds = null; entityPropertyCollection.PrimaryEntityTableName = null; var command = PriceNetSqlGenerator.GenerateInsertCommand(entityPropertyCollection); TSql100Parser parser = new TSql100Parser(false); parser.Parse(new StringReader(command.CommandText), out IList <ParseError> errors); Assert.IsFalse(errors.Any()); }
public void CanGeneratePriceNetUpdate() { var entityPropertyCollection = CreateEntityPropertyCollection(); entityPropertyCollection.Properties = new[] { CreateNameProperty(), CreateImportCodeProperty() }; entityPropertyCollection.PrimaryEntityColumnName = "AreaID"; entityPropertyCollection.PrimaryEntityIds = new[] { 1 }; entityPropertyCollection.PrimaryEntityTableName = "PNArea"; Test(entityPropertyCollection); var p = entityPropertyCollection.Properties.First(); p.Value = "Amended"; var command = PriceNetSqlGenerator.GenerateUpdateCommand(entityPropertyCollection); Assert.IsFalse(string.IsNullOrEmpty(command.CommandText)); }
public void CanUpdateArea() { var entityPropertyCollection = AreaProperties.Get(); var properties = entityPropertyCollection.Properties.ToList(); properties.RemoveAll(p => p.Name == "ImportCode" || p.Name == "Name"); entityPropertyCollection.Properties = properties; //entityPropertyCollection.PrimaryEntityColumnName = "AreaID"; entityPropertyCollection.PrimaryEntityTableName = "Area"; entityPropertyCollection.PrimaryEntityIds = new int[] { 1, 2 }; Test(entityPropertyCollection); entityPropertyCollection.Properties.First().Value = "Amended"; var command = PriceNetSqlGenerator.GenerateUpdateCommand(entityPropertyCollection); ParseSql(command.CommandText); TestCommand(command); }