我们如何使用 C# 编程语言编写 MIP(微软信息保护)的单元测试?
要求:如果任何文件具有保护(敏感度标签),那么我们将抛出错误消息。
在我们进行实际实施之前,我想使用 TDD 方法来实现这一目标。
请让我澄清一下,我们是否可以使用 C# 进行单元测试来实现以下步骤?
- 是否可以在此 MIP 上编写单元测试?如果是,
- 通过程序,我想在使用 MIP 代码之前读取文件(.pdf 或 Office 应用程序文件)并应用敏感度标签。
- 一旦到达 MIP 代码片段,就应该检测到该文件并且它受到保护。
- 如果它受到保护,则应抛出错误消息或跳过执行。
Requirement: If any file has protection(Sensitivity label) then we are throwing an error message.
Before we go and do our actual implementation, I want to achieve this using TDD approach.
Please let me clarify whether the below steps can we achieve using unit test with C#?
- Is it possible to write unit test on this MIP? If yes,
- Through program , I want to read the file(.pdf or office app files) and apply sensitivity label before using MIP Code.
- Once it reaches MIP code snippet ,this should detect this file and it has protection.
- If it is protected then should throw an error message or else skip the execution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从来没有使用过MIP SDK,但是如果你想使用MIP来测试文件信息,你就走错了路。
1.使用双重测试
首先,您必须使用双重测试(存根或假)以确保您的业务规则在算法中正确应用(如果存在则抛出异常例如,敏感度级别很差)
存根或假货将允许您控制敏感度级别返回,这也意味着您必须将“MIP 库” 包装在类或使用 IOC
2。使用集成测试
当您通过单元测试获得第一个工作场景时,您将能够使用集成测试进行相同的操作。您将向您的项目添加材料,以拥有“生产环境”,将具有不同敏感度的文件添加到您的测试项目
结论
当然,我知道我的答案不是工作解决方案,但您的需求并不简单,无法在 stackoverflow 帖子中设置。
您需要调查双重测试和双重测试。如果您想进行可靠的单元测试,请在进行任何开发之前进行集成测试。
I never used the MIP SDK, but you are in the wrong path if you want to test the file information using MIP.
1. Use double testing
First you will have to use Double Testing (a stub or a fake) to be sure that you business rules are applied correctly in your algorithme (throwing the exception if the sensitivity level is bad for example)
The stub or the fake will allow you to control the sensitivity level return, It's also means that you will have to wrap the "MIP Library" inside a class or using IOC
2. Use integration testing
When you will have a first working scenario with you unit test, you will be able to make the same with Integration Testing. You will add to your project the material to have a "production environnement" adding files with differents sentivities to your test project
Conclusion
Of course, I know that my answer is not a working solution but your needs is not simple and cannot be set in a stackoverflow post.
You will need to investigate about double testing & integration testing before making any development if you want to have reliable unit tests.