site/xunit.analyzers/rules/xUnit2005.md
A violation of this rule occurs when two value type objects are compared using Assert.Same or Assert.NotSame.
Assert.Same and Assert.NotSame both use Object.ReferenceEquals to compare objects. This always fails for value types since the values will be boxed before they are passed to the method, creating two different references (even if the values are the equal).
To fix a violation of this rule, use Assert.Equal or Assert.NotEqual instead.
using System;
using Xunit;
public class xUnit2005
{
[Fact]
public void TestMethod()
{
var result = DateTime.Now;
Assert.Same(new DateTime(2017, 1, 1), result);
}
}
using System;
using Xunit;
public class xUnit2005
{
[Fact]
public void TestMethod()
{
var result = DateTime.Now;
Assert.Equal(new DateTime(2017, 1, 1), result);
}
}