Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

测试用例合理性讨论 #16

Closed
LambertW opened this issue Mar 16, 2019 · 11 comments
Closed

测试用例合理性讨论 #16

LambertW opened this issue Mar 16, 2019 · 11 comments

Comments

@LambertW
Copy link
Contributor

SqlServerInsertTest.cs

增加

[Fact]
public void InsertWithExistData()
{
    var items = GenerateItems(10);

    items[0].Id = (int)insert.AppendData(items[0]).ExecuteIdentity();

    Assert.Equal(0, insert.AppendData(items[0]).ExecuteAffrows());
}

预期item.Id > 0的时候,应该是会跳过吧?
或者是可配置?

@LambertW
Copy link
Contributor Author

同理,AppendData(items)的时候,Id有效情况下,是否也应该跳过插入

@LambertW
Copy link
Contributor Author

问题2,

var inarray = new[] { 1, 2, 3 };
var inList = inarray.ToList();
var list = select.Where(a => inList.Contains(a.testFieldInt)).ToList();
var list1 = select.Where(a => !inList.Contains(a.testFieldInt)).ToList();

报错 未实现函数表达式,List.Contains,有考虑支持吗?

@2881099
Copy link
Collaborator

2881099 commented Mar 16, 2019

插入跳过的潜规则,目前只跳过列表中null的对象,是否会增加解释成本啊,因为确实会有id>0仍然执行。

list.Container 应该是没测试到位,我记录一下

@LambertW
Copy link
Contributor Author

插入跳过的潜规则,目前只跳过列表中null的对象,是否会增加解释成本啊,因为确实会有id>0仍然执行。

这种场景感觉会出现异常呀,可能是用户处理不当,例如 Add/Edit 的操作,对应MVC的一个Action,仅按照id判断是进行编辑还是新增~
处理不当可能会产生新数据~

这个是框架设计问题,也不是一定就是错的,说清楚就好

@2881099
Copy link
Collaborator

2881099 commented Mar 16, 2019

image

问题2,已修

@LambertW
Copy link
Contributor Author

👍,是通用的IEnumerable/ IList 接口,还是其他

@2881099
Copy link
Collaborator

2881099 commented Mar 16, 2019

IList,因为它是独立的 Contains
Linq.Enumerable 和这里定义的不一样,之前只作了 linq.Contains 判断

@2881099
Copy link
Collaborator

2881099 commented Mar 16, 2019

插入跳过的潜规则,目前只跳过列表中null的对象,是否会增加解释成本啊,因为确实会有id>0仍然执行。

这种场景感觉会出现异常呀,可能是用户处理不当,例如 Add/Edit 的操作,对应MVC的一个Action,仅按照id判断是进行编辑还是新增~
处理不当可能会产生新数据~

这个是框架设计问题,也不是一定就是错的,说清楚就好

针对这个问题,可不可以在 FreeSql.Repository 的 filter 上实现约束。
因为在最里层加这个,感觉会得罪其中一派人。

@LambertW
Copy link
Contributor Author

可以呀,例如初始化的时候,

new FreeSql.FreeSqlBuilder(options => {
  options.InsertOptions.InsertWithExistPrimaryKey = InsertWithExistPrimaryKey.ThrowException;
});

// ThrowException, Skip, IngoreAndCreateNew , Default: ThrowException

类似吧,放在Repository都可以

@LambertW
Copy link
Contributor Author

参考下别人的做法,这方面还是要看具体框架明确下来,就好了

@2881099
Copy link
Collaborator

2881099 commented Mar 16, 2019

现在配置这块确实有些乱。
想到一个加一个。

FreeSqlBuilder 那里的 一堆 UseXxx,哈哈

2881099 pushed a commit that referenced this issue Mar 16, 2019
@2881099 2881099 closed this as completed May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants