コード例 #1
0
        public void TestEquality()
        {
            var a = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", new DateTime(2019, 11, 15, 14, 26, 33));
            var b = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", new DateTime(2019, 11, 15, 14, 26, 33));

            (a == b).Should().BeTrue();
            (a != b).Should().BeFalse();
            a.Should().Equals(b);
            a.GetHashCode().Should().Be(b.GetHashCode());
            a = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", "1572363632", "aaa");
            b = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", "1572363632", "bbb");
            (a == b).Should().BeTrue();
            (a != b).Should().BeFalse();
            a.Should().Equals(b);
            a.GetHashCode().Should().Be(b.GetHashCode());
            a = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"aaa.txt", "1572363632");
            b = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"bbv.txt", "1572363632");
            (a == b).Should().BeFalse();
            (a != b).Should().BeTrue();
            a.Should().NotBeEquivalentTo(b);
            a.GetHashCode().Should().NotBe(b.GetHashCode());
            a = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\aaa", @"file.txt", "1572363632");
            b = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\bbb", @"file.txt", "1572363632");
            (a == b).Should().BeFalse();
            (a != b).Should().BeTrue();
            a.Should().NotBeEquivalentTo(b);
            a.GetHashCode().Should().NotBe(b.GetHashCode());
            a = new DocumentNode(@"C:\dir\aaa\.localhistory", @"C:\dir\solution\folder", @"file.txt", "1572363632");
            b = new DocumentNode(@"C:\dir\bbb\.localhistory", @"C:\dir\solution\folder", @"file.txt", "1572363632");
            (a == b).Should().BeTrue();
            (a != b).Should().BeFalse();
            a.Should().Equals(b);
            a.GetHashCode().Should().Be(b.GetHashCode());
            a = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"FILE.txt", new DateTime(2019, 11, 15, 14, 26, 33));
            b = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", new DateTime(2019, 11, 15, 14, 26, 33));
            (a == b).Should().BeTrue();
            (a != b).Should().BeFalse();
            a.Should().Equals(b);
            a.GetHashCode().Should().Be(b.GetHashCode());
            a = null;
            b = null;
            (a == b).Should().BeTrue();
            (a != b).Should().BeFalse();
        }
コード例 #2
0
        public static string GetDataSourceName(DocumentNode dataSourceNode)
        {
            string str = (string)null;

            if (dataSourceNode != null)
            {
                DocumentCompositeNode parent = dataSourceNode.Parent;
                if (parent != null && PlatformTypes.DictionaryEntry.IsAssignableFrom((ITypeId)parent.Type))
                {
                    DocumentNode resourceEntryKey = DocumentNodeHelper.GetResourceEntryKey(parent);
                    if (resourceEntryKey != null)
                    {
                        str = DocumentPrimitiveNode.GetValueAsString(resourceEntryKey);
                    }
                }
                if (string.IsNullOrEmpty(str))
                {
                    str = dataSourceNode.Type.Name + (object)" " + (string)(object)dataSourceNode.GetHashCode();
                }
            }
            return(str ?? string.Empty);
        }