public void DefineUpdateEntity() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return; } SqlServerEntityPipeline insertPipeline = new SqlServerEntityPipeline(ConnectString); try { insertPipeline.AddEntity(new EntityDefine <UpdateEntity1>()); throw new SpiderException("TEST FAILED."); } catch (SpiderException e) { Assert.Equal("Columns set as unique are not a property of your entity.", e.Message); } try { insertPipeline.AddEntity(new EntityDefine <UpdateEntity2>()); throw new SpiderException("TEST FAILED."); } catch (SpiderException e) { Assert.Equal("Columns set to update are not a property of your entity.", e.Message); } try { insertPipeline.AddEntity(new EntityDefine <UpdateEntity3>()); throw new SpiderException("TEST FAILED."); } catch (SpiderException e) { Assert.Equal("There is no column need update.", e.Message); } var metadata = new EntityDefine <UpdateEntity4>(); insertPipeline.AddEntity(metadata); Assert.Single(insertPipeline.GetUpdateColumns(metadata.Name)); Assert.Equal("Value", insertPipeline.GetUpdateColumns(metadata.Name).First()); SqlServerEntityPipeline insertPipeline2 = new SqlServerEntityPipeline(ConnectString); var metadata2 = new EntityDefine <UpdateEntity5>(); insertPipeline2.AddEntity(metadata2); var columns = insertPipeline2.GetUpdateColumns(metadata2.Name); Assert.Equal(2, columns.Length); Assert.Equal("Value", columns[0]); Assert.Equal("Key", columns[1]); }
public void DefineUpdateEntity() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return; } SqlServerEntityPipeline insertPipeline = new SqlServerEntityPipeline(ConnectString); try { insertPipeline.AddEntity(EntitySpider.GenerateEntityDefine(typeof(UpdateEntity1).GetTypeInfo())); throw new SpiderException("TEST FAILED."); } catch (SpiderException e) { Assert.Equal("Columns set as primary is not a property of your entity.", e.Message); } try { insertPipeline.AddEntity(EntitySpider.GenerateEntityDefine(typeof(UpdateEntity2).GetTypeInfo())); throw new SpiderException("TEST FAILED."); } catch (SpiderException e) { Assert.Equal("Columns set as update is not a property of your entity.", e.Message); } try { insertPipeline.AddEntity(EntitySpider.GenerateEntityDefine(typeof(UpdateEntity3).GetTypeInfo())); throw new SpiderException("TEST FAILED."); } catch (SpiderException e) { Assert.Equal("There is no column need update.", e.Message); } var metadata = EntitySpider.GenerateEntityDefine(typeof(UpdateEntity4).GetTypeInfo()); insertPipeline.AddEntity(EntitySpider.GenerateEntityDefine(typeof(UpdateEntity4).GetTypeInfo())); Assert.Single(insertPipeline.GetUpdateColumns(metadata.Name)); Assert.Equal("Value", insertPipeline.GetUpdateColumns(metadata.Name).First()); SqlServerEntityPipeline insertPipeline2 = new SqlServerEntityPipeline(ConnectString); var metadata2 = EntitySpider.GenerateEntityDefine(typeof(UpdateEntity5).GetTypeInfo()); insertPipeline2.AddEntity(metadata2); Assert.Single(insertPipeline2.GetUpdateColumns(metadata2.Name)); Assert.Equal("Value", insertPipeline2.GetUpdateColumns(metadata2.Name).First()); }
public void DefineUpdateEntity() { SqlServerEntityPipeline insertPipeline = new SqlServerEntityPipeline(ConnectString); try { insertPipeline.AddEntity(EntitySpider.GenerateEntityMetaData(typeof(UpdateEntity1).GetTypeInfo())); throw new SpiderException("TEST FAILED."); } catch (SpiderException e) { Assert.AreEqual("Columns set as Primary is not a property of your entity.", e.Message); } try { insertPipeline.AddEntity(EntitySpider.GenerateEntityMetaData(typeof(UpdateEntity2).GetTypeInfo())); throw new SpiderException("TEST FAILED."); } catch (SpiderException e) { Assert.AreEqual("Columns set as update is not a property of your entity.", e.Message); } try { insertPipeline.AddEntity(EntitySpider.GenerateEntityMetaData(typeof(UpdateEntity3).GetTypeInfo())); throw new SpiderException("TEST FAILED."); } catch (SpiderException e) { Assert.AreEqual("There is no column need update.", e.Message); } var metadata = EntitySpider.GenerateEntityMetaData(typeof(UpdateEntity4).GetTypeInfo()); insertPipeline.AddEntity(EntitySpider.GenerateEntityMetaData(typeof(UpdateEntity4).GetTypeInfo())); Assert.AreEqual(1, insertPipeline.GetUpdateColumns(metadata.Name).Length); Assert.AreEqual("Value", insertPipeline.GetUpdateColumns(metadata.Name).First()); SqlServerEntityPipeline insertPipeline2 = new SqlServerEntityPipeline(ConnectString); var metadata2 = EntitySpider.GenerateEntityMetaData(typeof(UpdateEntity5).GetTypeInfo()); insertPipeline2.AddEntity(metadata2); Assert.AreEqual(1, insertPipeline2.GetUpdateColumns(metadata2.Name).Length); Assert.AreEqual("Value", insertPipeline2.GetUpdateColumns(metadata2.Name).First()); }