public void It_handles_String_identifiers() { var helper = new IdHelperForString(); string defaultValue = default; // ReSharper disable StringLiteralTypo // ReSharper disable ExpressionIsAlwaysNull helper.IsDefaultValue(defaultValue).ShouldBeTrue(); helper.IsDefaultValue("XX").ShouldBeFalse(); helper.AreEqual(defaultValue, defaultValue).ShouldBeTrue(); helper.AreEqual(defaultValue, "X").ShouldBeFalse(); helper.AreEqual("X", defaultValue).ShouldBeFalse(); helper.AreEqual("ABCD", "abcd").ShouldBeTrue(); helper.AreEqual("ABCDE", "ABCDE").ShouldBeTrue(); helper.Compare(defaultValue, "AAA").ShouldBe(-1); helper.Compare("BBB", defaultValue).ShouldBe(1); helper.Compare(defaultValue, defaultValue).ShouldBe(0); helper.Compare("X", "x").ShouldBe(0); helper.GetHashCode(string.Empty).ShouldBe(string.Empty.GetHashCode()); helper.GetHashCode(defaultValue).ShouldBe(0); helper.GetHashCode("XXX").ShouldBe("XXX".GetHashCode()); helper.GetHashCode("XXX").ShouldBe(helper.GetHashCode("xxx")); // ReSharper restore ExpressionIsAlwaysNull // ReSharper restore StringLiteralTypo }
public void Value_type_string() { var helper = new IdHelperForString(); Assert.AreEqual(true, helper.IsNull(null)); Assert.AreEqual(true, helper.IsDefaultValue(null)); Assert.AreEqual(false, helper.IsDefaultValue("XX")); Assert.AreEqual(true, helper.AreEqual(null, null)); Assert.AreEqual(false, helper.AreEqual(null, "X")); Assert.AreEqual(true, helper.AreEqual("ABCD", "abcd")); Assert.AreEqual(true, helper.AreEqual("ABCDE", "ABCDE")); Assert.AreEqual(-1, helper.Compare(null, "AAA")); Assert.AreEqual(+1, helper.Compare("BBB", null)); Assert.That(helper.Compare(null, null), Is.EqualTo(0)); Assert.AreEqual(0, helper.Compare("X", "x")); Assert.AreEqual(string.Empty.GetHashCode(), helper.GetHashCode(string.Empty)); Assert.AreEqual(0, helper.GetHashCode(null)); Assert.AreEqual("XXX".GetHashCode(), helper.GetHashCode("XXX")); Assert.AreEqual(helper.GetHashCode("XXX"), helper.GetHashCode("xxx")); }