コード例 #1
0
        public void TestLabel()
        {
            var d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", "1572363632", "label");

            d.Label.Should().Be(@"label");
            d.RemoveLabel();
            d.Label.Should().Be(null);
            d.AddLabel("shhd$ghd");
            d.Label.Should().Be("shhd$ghd");
            d.AddLabel("aaa");
            d.Label.Should().Be("aaa");
            d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", "1572363632");
            d.Label.Should().BeNull();
        }
コード例 #2
0
        public void TestVersionFileName()
        {
            var d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", "1572363632", "label");

            d.VersionFileName.Should().Be(@"1572363632$file.txt$label");
            d.RemoveLabel();
            d.VersionFileName.Should().Be(@"1572363632$file.txt");
            d.AddLabel("shhdud");
            d.VersionFileName.Should().Be(@"1572363632$file.txt$shhdud");
            d.AddLabel("shh$dud");
            d.VersionFileName.Should().Be(@"1572363632$file.txt$shh$$dud");
            d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @".fi$le", "1572363632", "lab$$$el");
            d.VersionFileName.Should().Be(@"1572363632$.fi$$le$lab$$$$$$el");
            var date = new DateTime(2019, 11, 15);

            d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @".fi$le", date);
            d.VersionFileName.Should().Be(Utils.ToUnixTime(date).ToString() + "$.fi$$le");
        }
コード例 #3
0
        public void TestAddRemoveLabel()
        {
            var originalPath = new Uri(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)).LocalPath;
            var repository   = Path.Combine(originalPath, ".localhistory");
            var d            = new DocumentNode(repository, originalPath, "file.txt", new DateTime(2019, 11, 15, 14, 26, 33));

            d.Label.Should().BeNull();
            var parentDir = Path.GetDirectoryName(d.VersionFileFullFilePath);

            if (Directory.Exists(parentDir))
            {
                Directory.Delete(parentDir, true);
            }
            Directory.CreateDirectory(parentDir);
            using (var s = File.Create(d.VersionFileFullFilePath))
            {
                s.Write(new byte[] { 00 }, 0, 1);
            }
            d.AddLabel("test");
            d.Label.Should().Be("test");
            d.VersionFileFullFilePath.Should().EndWith("test");
            File.Exists(d.VersionFileFullFilePath).Should().BeTrue();
            d.AddLabel("aaa");
            d.Label.Should().Be("aaa");
            d.VersionFileFullFilePath.Should().EndWith("aaa");
            File.Exists(d.VersionFileFullFilePath).Should().BeTrue();
            d.AddLabel("aa$a");
            d.Label.Should().Be("aa$a");
            d.VersionFileFullFilePath.Should().EndWith("aa$$a");
            File.Exists(d.VersionFileFullFilePath).Should().BeTrue();
            d.RemoveLabel();
            d.Label.Should().BeNull();
            d.VersionFileFullFilePath.Should().NotEndWith("aa$$a");
            File.Exists(d.VersionFileFullFilePath).Should().BeTrue();
            d.AddLabel("bbb");
            d.Label.Should().Be("bbb");
            d.VersionFileFullFilePath.Should().EndWith("bbb");
            File.Exists(d.VersionFileFullFilePath).Should().BeTrue();
            d.RemoveLabel();
            d.Label.Should().BeNull();
            d.VersionFileFullFilePath.Should().NotEndWith("bbb");
            File.Exists(d.VersionFileFullFilePath).Should().BeTrue();
        }
コード例 #4
0
        public void TestTimestampAndLabel()
        {
            var d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", new DateTime(2019, 11, 15, 14, 26, 33));

            d.TimestampAndLabel.Should().Be("2019-11-15 14:26:33");
            d.AddLabel("djdjj");
            d.TimestampAndLabel.Should().Be("2019-11-15 14:26:33 djdjj");
            d.RemoveLabel();
            d.TimestampAndLabel.Should().Be("2019-11-15 14:26:33");
            d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", Utils.ToUnixTime(new DateTime(2019, 11, 15, 14, 26, 33)).ToString(), "label");
            d.TimestampAndLabel.Should().Be("2019-11-15 14:26:33 label");
        }
コード例 #5
0
        public void TestHasLabel()
        {
            var d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", "1572363632", "label");

            d.HasLabel.Should().BeTrue();
            d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", "1572363632", null);
            d.HasLabel.Should().BeFalse();
            d = new DocumentNode(@"C:\dir\solution\.localhistory", @"C:\dir\solution\folder", @"file.txt", DateTime.Now);
            d.HasLabel.Should().BeFalse();
            d.AddLabel("aaa");
            d.HasLabel.Should().BeTrue();
            d.RemoveLabel();
            d.HasLabel.Should().BeFalse();
        }