我需要用 c# 编写单元测试来为我们的应用程序生成假的加拿大 SIN 号。在互联网上搜索后,这是我发现的。我什至不知道如何开始。特别将每个顶部数字与下面的数字相乘让我感到困惑,因为它不是直接乘法。提前感谢帮助。谢谢。
这是我从谷歌搜索得到的算法。
Algorithm _
Social Insurance Numbers are validated via a simple checksum process.
Let's use this fictitious SIN to demonstrate:
046 454 286 < Try substituting your SIN
046 454 286 \ Multiply each top number
121 212 121 / by the number below it..
-----------
086 858 276 < and get this.
^
Notice here that 8*2=16, add 1 and
6 together and get 7. If you get a
2 digit # add the digits together.
Add all of these digits together.
0+8+6+8+5+8+2+7+6=50
/\
If the SIN is valid this # will
be evenly divisible by 10. This
is a 'valid' SIN.