Beispiel #1
0
        public void SameObjectReturnsZero()
        {
            var nowInfo = A.Fake <FileInfoHandler>();
            var first   = new FileEntry(1, "first", null);

            Assert.Equal(0, first.CompareTo(first));
        }
Beispiel #2
0
        public void ReturnZeroIfEqualContent()
        {
            var nowInfo = A.Fake <FileInfoHandler>();

            A.CallTo(() => nowInfo.CreationTime).Returns(now);
            A.CallTo(() => nowInfo.LastWriteTime).Returns(now);
            var first  = new FileEntry(1, "same", nowInfo);
            var second = new FileEntry(1, "same", nowInfo);

            Assert.Equal(0, first.CompareTo(second));
            Assert.Equal(0, second.CompareTo(first));
        }
Beispiel #3
0
        public void SecondIsChosenIfEarlierCreateDate()
        {
            var nowInfo     = A.Fake <FileInfoHandler>();
            var earlierInfo = A.Fake <FileInfoHandler>();

            A.CallTo(() => nowInfo.CreationTime).Returns(now);
            A.CallTo(() => earlierInfo.CreationTime).Returns(earlier);
            var first  = new FileEntry(1, "first", nowInfo);
            var second = new FileEntry(1, "second", earlierInfo);

            Assert.Equal(1, first.CompareTo(second));
            Assert.Equal(-1, second.CompareTo(first));
        }
Beispiel #4
0
        public void FirstChosenIfSameCreationAndLastWriteButLowerName()
        {
            var nowInfo     = A.Fake <FileInfoHandler>();
            var earlierInfo = A.Fake <FileInfoHandler>();

            A.CallTo(() => nowInfo.CreationTime).Returns(now);
            A.CallTo(() => earlierInfo.CreationTime).Returns(now);
            A.CallTo(() => nowInfo.LastWriteTime).Returns(now);
            A.CallTo(() => earlierInfo.LastWriteTime).Returns(now);
            var first  = new FileEntry(1, "A", nowInfo);
            var second = new FileEntry(1, "B", earlierInfo);

            Assert.Equal(-1, first.CompareTo(second));
            Assert.Equal(1, second.CompareTo(first));
        }
Beispiel #5
0
        public void FollowsNull()
        {
            var only = new FileEntry(1, "followsNull", null);

            Assert.Equal(1, only.CompareTo(null));
        }
Beispiel #6
0
        public void MustBeFileEntry()
        {
            var fail = new FileEntry(1, "fails", null);

            Assert.Throws <ArgumentException>(() => fail.CompareTo(new object()));
        }