public void ProjectPackageDependenciesTest() { string csprojFile = "Microsoft.Azure.Cosmos.csproj"; Dictionary <string, string> projDependencies = DirectContractTests.GetPackageReferencies(csprojFile); Dictionary <string, string> baselineDependencies = JsonConvert.DeserializeObject <Dictionary <string, string> >( "{\"System.Numerics.Vectors\":\"4.5.0\",\"Newtonsoft.Json\":\"10.0.2\",\"System.Configuration.ConfigurationManager\":\"4.5.0\",\"System.Memory\":\"4.5.1\",\"System.Runtime.CompilerServices.Unsafe\":\"4.5.1\",\"System.Threading.Tasks.Extensions\":\"4.5.1\",\"System.ValueTuple\":\"4.5.0\"}"); Assert.AreEqual(projDependencies.Count, baselineDependencies.Count); foreach (KeyValuePair <string, string> projectDependency in projDependencies) { string baselineVersion = baselineDependencies[projectDependency.Key]; Assert.AreEqual(baselineVersion, projectDependency.Value); } }
public void PackageDependenciesTest() { string csprojFile = "Microsoft.Azure.Cosmos.csproj"; Dictionary <string, string> projDependencies = DirectContractTests.GetPackageReferencies(csprojFile); string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.nuspec"); Dictionary <string, string> allDependencies = new Dictionary <string, string>(); foreach (string nuspecFile in files) { Dictionary <string, string> nuspecDependencies = DirectContractTests.GetNuspecDependencies(nuspecFile); foreach (KeyValuePair <string, string> e in nuspecDependencies) { if (!allDependencies.ContainsKey(e.Key)) { allDependencies[e.Key] = e.Value; } else { string existingValue = allDependencies[e.Key]; if (existingValue.CompareTo(e.Value) > 0) { allDependencies[e.Key] = e.Value; } } } } // Dependency version should match foreach (KeyValuePair <string, string> e in allDependencies) { Assert.AreEqual(e.Value, projDependencies[e.Key]); } CollectionAssert.IsSubsetOf(allDependencies.Keys, projDependencies.Keys); }