这不能正常工作
INT blueInt = Color.Blue.ToArgb();
颜色弗雷德= Color.FromArgb(blueInt);
Assert.AreEqual(Color.Blue,弗雷德);
有什么建议?
我使用NUnit和输出
失败:
预计:颜色[蓝]
不过是:颜色[A = 255,R = 0,G = 0,B = 255]
这个作品!
INT blueInt = Color.Blue.ToArgb();
颜色弗雷德= Color.FromArgb(blueInt);
Assert.AreEqual(Color.Blue.ToArgb(),fred.ToArgb());
解决方案
从的 MSDN上 Color.operator ==文档
:
这个方法比较多 颜色结构ARGB值。 它也做了一些比较 状态标志。如果你想比较 两种颜色只是ARGB值 结构,使用比较它们 ToArgb方法。
我猜的状态标志是不同的。
This does not work
int blueInt = Color.Blue.ToArgb();
Color fred = Color.FromArgb(blueInt);
Assert.AreEqual(Color.Blue,fred);
Any suggestions?
[Edit]
I'm using NUnit and the output is
failed:
Expected: Color [Blue]
But was: Color [A=255, R=0, G=0, B=255]
[Edit]
This works!
int blueInt = Color.Blue.ToArgb();
Color fred = Color.FromArgb(blueInt);
Assert.AreEqual(Color.Blue.ToArgb(),fred.ToArgb());
解决方案
From the MSDN documentation on Color.operator ==
:
This method compares more than the ARGB values of the Color structures. It also does a comparison of some state flags. If you want to compare just the ARGB values of two Color structures, compare them using the ToArgb method.
I'm guessing the state flags are different.