public void LoadComponentTarget_NonExistingCompTargetsFile_Test()
        {
            // Prepare environment
            string tempPath          = Path.GetTempPath();
            string guid              = System.Guid.NewGuid().ToString();
            string repositoryRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(repositoryRootDir);
            string compName = "existCompWithVersion";
            string compDir  = repositoryRootDir + Path.DirectorySeparatorChar + compName;

            Directory.CreateDirectory(compDir);
            string compVersion = "1.0.0.35";

            Directory.CreateDirectory(compDir + Path.DirectorySeparatorChar + compVersion);

            ISettings <ResolverValidSettings> sett = new Settings <ResolverValidSettings>();

            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.FileShareUrl, repositoryRootDir));
            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.DependencyDefinitionFileNameList, "component.targets"));

            IDependencyResolver rfs = new ResolverFileShare(sett);
            var xdoc = rfs.LoadComponentTarget(new ComponentName(compName), new ComponentVersion(compVersion));

            Assert.IsNull(xdoc);
        }
        public void ComponentExists_CompVersion_Test()
        {
            // Prepare environment
            string tempPath          = Path.GetTempPath();
            string guid              = System.Guid.NewGuid().ToString();
            string repositoryRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(repositoryRootDir);
            string compName = "comp";
            string compDir  = repositoryRootDir + Path.DirectorySeparatorChar + compName;

            Directory.CreateDirectory(compDir);
            string existingVersion    = "1.0";
            string nonexistingVersion = "1.2";

            Directory.CreateDirectory(compDir + Path.DirectorySeparatorChar + existingVersion);
            File.Create(Path.Combine(compDir, existingVersion, "component.targets"));

            ISettings <ResolverValidSettings> sett = new Settings <ResolverValidSettings>();

            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.FileShareUrl, repositoryRootDir));
            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.DependencyDefinitionFileNameList, "component.targets"));
            IDependencyResolver rfs = new ResolverFileShare(sett);

            Assert.IsTrue(rfs.ComponentExists(new ComponentName(compName), new ComponentVersion(existingVersion)));
            Assert.IsFalse(rfs.ComponentExists(new ComponentName(compName), new ComponentVersion(nonexistingVersion)));
        }
        public void GetAvailableVersions_ExistingComponentNoVersions_Test()
        {
            // Prepare environment
            string tempPath          = Path.GetTempPath();
            string guid              = System.Guid.NewGuid().ToString();
            string repositoryRootDir = Path.Combine(tempPath, guid);

            Directory.CreateDirectory(repositoryRootDir);
            string compName = "comp";
            string compDir  = Path.Combine(repositoryRootDir, compName);

            Directory.CreateDirectory(compDir);

            ISettings <ResolverValidSettings> sett = new Settings <ResolverValidSettings>();

            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.FileShareUrl, repositoryRootDir));
            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.DependencyDefinitionFileNameList, "component.targets"));

            IDependencyResolver rfs = new ResolverFileShare(sett);

            List <IComponentVersion> noVersionList = new List <IComponentVersion>();

            IEnumerable <IComponentVersion> actual = rfs.GetAvailableVersions(new ComponentName(compName));

            Assert.AreEqual(actual.Count(), noVersionList.Count());
            IEnumerator <IComponentVersion> eA = actual.GetEnumerator();
            IEnumerator <IComponentVersion> eN = noVersionList.GetEnumerator();

            while (eA.MoveNext() && eN.MoveNext())
            {
                Assert.AreEqual(eA.Current.Version, eN.Current.Version);
            }
        }
        public void GetAvailableComponentNames_EmptyFileShareTest_Test()
        {
            // Prepare environment
            string tempPath     = Path.GetTempPath();
            string guid         = System.Guid.NewGuid().ToString();
            string emptyRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(emptyRootDir);

            ISettings <ResolverValidSettings> sett = new Settings <ResolverValidSettings>();

            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.FileShareUrl, emptyRootDir));
            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.DependencyDefinitionFileNameList, "component.targets"));

            var rfs = new ResolverFileShare(sett);

            List <IComponentName>        expectedList = new List <IComponentName>();
            IEnumerable <IComponentName> actual;

            actual = rfs.GetAvailableComponentNames();

            Assert.AreEqual(actual.Count(), expectedList.Count());
            IEnumerator <IComponentName> eA = actual.GetEnumerator();
            IEnumerator <IComponentName> eE = expectedList.GetEnumerator();

            while (eA.MoveNext() && eA.MoveNext())
            {
                Assert.AreEqual(eA.Current.Path, eE.Current.Path);
            }
        }
        public void Resolver_FileShare_InvalidUrl_Test()
        {
            ISettings <ResolverValidSettings> sett = new Settings <ResolverValidSettings>();

            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.FileShareUrl, @"\\\server\folder"));
            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.DependencyDefinitionFileNameList, "component.targets"));

            var rfs = new ResolverFileShare(sett);
        }
        public void GetAvailableVersions_NonExistingComponent_Test()
        {
            // Prepare environment
            string tempPath          = Path.GetTempPath();
            string guid              = System.Guid.NewGuid().ToString();
            string repositoryRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(repositoryRootDir);
            string nonexistingComp = "nonExistingComp";

            ISettings <ResolverValidSettings> sett = new Settings <ResolverValidSettings>();

            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.FileShareUrl, repositoryRootDir));
            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.DependencyDefinitionFileNameList, "component.targets"));

            IDependencyResolver rfs = new ResolverFileShare(sett);

            rfs.GetAvailableVersions(new ComponentName(nonexistingComp));
        }
        public void GetAvailableComponentNames_NonExistingFileShareTest_Test()
        {
            // Prepare environment
            string tempPath           = Path.GetTempPath();
            string guid               = System.Guid.NewGuid().ToString();
            string nonexistingRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            ISettings <ResolverValidSettings> sett = new Settings <ResolverValidSettings>();

            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.FileShareUrl, nonexistingRootDir));
            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.DependencyDefinitionFileNameList, "component.targets"));

            IDependencyResolver rfs = new ResolverFileShare(sett);

            List <IComponentName>        expectedList = new List <IComponentName>();
            IEnumerable <IComponentName> actual;

            actual = rfs.GetAvailableComponentNames();
        }
        public void LoadComponentTarget_ExistingCompTargetsFile_Test()
        {
            // Prepare environment
            string tempPath          = Path.GetTempPath();
            string guid              = System.Guid.NewGuid().ToString();
            string repositoryRootDir = tempPath + Path.DirectorySeparatorChar + guid;

            Directory.CreateDirectory(repositoryRootDir);
            string compName = "comp";
            string compDir  = repositoryRootDir + Path.DirectorySeparatorChar + compName;

            Directory.CreateDirectory(compDir);
            string compVersion = "1.0.0.35";

            Directory.CreateDirectory(compDir + Path.DirectorySeparatorChar + compVersion);
            string       compTargetsFilename = "component.targets";
            StreamWriter sw = new StreamWriter(File.Create(compDir + Path.DirectorySeparatorChar + compVersion + Path.DirectorySeparatorChar + compTargetsFilename));

            sw.WriteLine("<Component>");
            sw.WriteLine("<Dependencies>");
            sw.WriteLine("</Dependencies>");
            sw.WriteLine("</Component>");
            sw.Close();

            ISettings <ResolverValidSettings> sett = new Settings <ResolverValidSettings>();

            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.FileShareUrl, repositoryRootDir));
            sett.AddSetting(new KeyValuePair <ResolverValidSettings, string>(ResolverValidSettings.DependencyDefinitionFileNameList, "component.targets"));

            IDependencyResolver rfs      = new ResolverFileShare(sett);
            XDocument           compXdoc = rfs.LoadComponentTarget(new ComponentName(compName), new ComponentVersion(compVersion));

            Assert.AreEqual(1, compXdoc.Descendants("Component").Count());
            Assert.AreEqual(1, compXdoc.Descendants("Dependencies").Count());

            // Cleanup the temp folder, to test the Cleanup on Build Server
            File.Delete(compDir + Path.DirectorySeparatorChar + compVersion + Path.DirectorySeparatorChar + compTargetsFilename);
            Directory.Delete(Path.Combine(compDir, compVersion));
        }