public void LocalFileTest() {
			var desc = new FileDescriptorEx {FullName = file};
			Assert.AreEqual(File.GetLastWriteTimeUtc(file),desc.Version);
			var hash = Convert.ToBase64String(MD5.Create().ComputeHash(File.ReadAllBytes(file)));
			Assert.AreEqual(hash,desc.Hash);
			Assert.False(desc.IsGitBased);
			Assert.Null(desc.CommitInfo);
		}
		public void CanReadAssemblyVersionAndAttributes() {
			var assembly = Assembly.GetExecutingAssembly();
			var path = assembly.GetName().CodeBase.Replace("file:///", "");
			var desc = new FileDescriptorEx {FullName = path};
			Assert.True(desc.IsAssembly);
			Console.WriteLine(desc.Hash);
			Console.WriteLine(desc.Version);
			Console.WriteLine(desc.Header);
		}
 /// <summary>
 /// 
 /// </summary>
 /// <param name="updateCode"></param>
 public ScriptTextDbUpdateTask(string name, string text, string explicithash = null) {
     Script = text;
     Name = name;
     var hash = explicithash;
     if (string.IsNullOrWhiteSpace(hash)) {
         hash = Script.GetMd5();
     }
     Source = new FileDescriptorEx {Name = name, Hash = hash, Version = DateTime.Now,Overrides = ResolvePathOverrides};
 }
 /// <summary>
 /// </summary>
 /// <param name="filename"></param>
 public AssemblyDbUpdateTask(string filename, string prefix = null) {
     if (!string.IsNullOrWhiteSpace(filename)) {
         Source = new FileDescriptorEx {FullName = filename,Overrides = ResolvePathOverrides};
         Source.Name = Path.GetFileNameWithoutExtension(filename);
         if (!string.IsNullOrWhiteSpace(prefix)) {
             Source.Name = prefix + "." + Source.Name;
         }
     }
 }
		public void GitFileTest()
		{
			var desc = new FileDescriptorEx { FullName = file };
			GitHelper.Init(dir);
			GitHelper.CommitAll(dir);
			var commit = GitHelper.GetCommit(dir);
			Assert.AreEqual(commit.GlobalRevisionTime, desc.Version);
		   Assert.AreEqual(commit.Hash, desc.Hash);
			Assert.True(desc.IsGitBased);
			Assert.NotNull(desc.CommitInfo);
		}
	    public void FileLevelGitHash() {
            var desc = new FileDescriptorEx { FullName = file};
            GitHelper.Init(dir);
            GitHelper.CommitAll(dir);
            desc.Refresh();
            Assert.AreEqual(desc.Hash, GitHelper.GetCommit(dir).Hash);
            File.WriteAllText(file2, "sample");
            GitHelper.CommitAll(dir);
            Assert.AreNotEqual(desc.Hash, GitHelper.GetCommit(dir).Hash);
            desc.Refresh();
            Assert.AreNotEqual(desc.Hash, GitHelper.GetCommit(dir).Hash);
	    }
Esempio n. 7
0
 public TestUpdater(TextWriter sw, string fileFrom, string fileTo) {
     o = sw ?? new StringWriter();
     Source = new FileDescriptorEx {FullName = fileFrom, AllowNotExisted = true};
     Target = new FileDescriptorEx {FullName = fileTo, AllowNotExisted = true};
 }
	    public void CanUseExplicitHash() {
	        File.WriteAllText(file,"--!options hash=XXX\r\ndata");
	        var desc = new FileDescriptorEx {FullName = file};
            Assert.AreEqual("XXX",desc.Hash);
	    }
		public void ReadHeader() {
			var desc = new FileDescriptorEx { FullName = file };
			var header = desc.Header.ToString().Replace("\"", "'");
			Console.WriteLine(header);
			Assert.AreEqual(@"<opts _file='code.bxl' _line='2' x='1' y='2' />", header);
		}
Esempio n. 10
0
        public void HeaderRepositoryLevelHash()
        {
            File.WriteAllText(file, @"/*!
opts userepositorycommit=true
*/
data");
            var desc = new FileDescriptorEx { FullName = file};
            GitHelper.Init(dir);
            GitHelper.CommitAll(dir);
            desc.Refresh();
            Assert.AreEqual(desc.Hash, GitHelper.GetCommit(dir).Hash);
            File.WriteAllText(file2, "sample");
            GitHelper.CommitAll(dir);
            Assert.AreNotEqual(desc.Hash, GitHelper.GetCommit(dir).Hash);
            desc.Refresh();
            Assert.AreEqual(desc.Hash, GitHelper.GetCommit(dir).Hash);
        }
Esempio n. 11
0
        public void HeaderMultiRepositoryDependency()
        {
            File.WriteAllText(file, @"/*!
opts 
    repodependency ../FileDescriptorExTest2
    repodependency @repos@/qorpent.sys
*/
data");
            File.WriteAllText(file2_1, "test");
            GitHelper.Init(dir);
            GitHelper.CommitAll(dir);
            GitHelper.Init(dir2);
            GitHelper.CommitAll(dir2);
            var h1 = GitHelper.GetCommit(dir).Hash;
            var h2 = GitHelper.GetCommit(dir2).Hash;
            var h3 = GitHelper.GetCommit(EnvironmentInfo.ResolvePath("@repos@/qorpent.sys")).Hash;
            Assert.NotNull(h1);
            Assert.NotNull(h2);
            Assert.NotNull(h3);
            var h = (h1 + h2 + h3).GetMd5();
            var desc = new FileDescriptorEx { FullName = file };
            Assert.AreEqual(h, desc.Hash);
        }