public void ToString_IdAndVersionSpecified_ContainsIdAndVersion ()
		{
			var recentPackageInfo = new RecentPackageInfo ("id", new SemanticVersion ("1.0"));

			string actual = recentPackageInfo.ToString ();

			string expected = "[RecentPackageInfo Id=id, Version=1.0]";
			Assert.AreEqual (expected, actual);
		}
		List<RecentPackageInfo> GetRecentPackagesInfo()
		{
			List<RecentPackageInfo> allRecentPackages = new List<RecentPackageInfo>();
			foreach (IPackage package in packages) {
				var recentPackageInfo = new RecentPackageInfo(package);
				allRecentPackages.Add(recentPackageInfo);
			}
			return allRecentPackages;
		}
        List <RecentPackageInfo> GetRecentPackagesInfo()
        {
            List <RecentPackageInfo> allRecentPackages = new List <RecentPackageInfo>();

            foreach (IPackage package in packages)
            {
                var recentPackageInfo = new RecentPackageInfo(package);
                allRecentPackages.Add(recentPackageInfo);
            }
            return(allRecentPackages);
        }
        public void AddPackage_RepositoryIsEmptyAndOnePackageAdded_RecentPackageAddedToOptions()
        {
            CreateRepository();
            var package = AddOnePackageToRepository("Test");

            var expectedPackages = new RecentPackageInfo[] {
                new RecentPackageInfo(package)
            };

            RecentPackageInfoCollectionAssert.AreEqual(expectedPackages, recentPackages);
        }
		public void IsMatch_PackageWithDifferentIdButSameVersionPassed_ReturnsFalse ()
		{
			var version = new SemanticVersion (1, 0, 0, 0);
			var recentPackageInfo = new RecentPackageInfo ("id", version);
			var package = new FakePackage ("different-id");
			package.Version = version;

			bool result = recentPackageInfo.IsMatch (package);

			Assert.IsFalse (result);
		}
		public void IsMatch_PackageWithSameIdButDifferentVersionPassed_ReturnsFalse ()
		{
			string id = "id";
			var version = new SemanticVersion (1, 0, 0, 0);
			var recentPackageInfo = new RecentPackageInfo (id, version);
			var package = new FakePackage (id);
			package.Version = new SemanticVersion (2, 0, 0, 0);

			bool result = recentPackageInfo.IsMatch (package);

			Assert.IsFalse (result);
		}
		public void IsMatch_PackageWithSameIdAndVersionPassed_ReturnsTrue()
		{
			string id = "id";
			var version = new Version(1, 0);
			var recentPackageInfo = new RecentPackageInfo(id, version);
			var package = new FakePackage(id);
			package.Version = version;
			
			bool result = recentPackageInfo.IsMatch(package);
			
			Assert.IsTrue(result);
		}
        public void AddPackage_RepositoryIsEmptyAndTwoPackagesAddedFromDifferentSources_BothRecentPackagesAddedToOptions()
        {
            CreateRepository();
            var package1 = AddOnePackageToRepository("Test1");
            var package2 = AddOnePackageToRepository("Test2");

            var expectedPackages = new RecentPackageInfo[] {
                new RecentPackageInfo(package2),
                new RecentPackageInfo(package1)
            };

            RecentPackageInfoCollectionAssert.AreEqual(expectedPackages, recentPackages);
        }
		public void Version_SerializeThenDeserializeRecentPackageInfoInPropertiesObject_ReturnsSameValueAfterDeserialization()
		{
			var version = new Version(1, 0);
			var recentPackageInfo = new RecentPackageInfo("id", version);
			var properties = new Properties();
			properties.Set<RecentPackageInfo>("RecentPackageInfo", recentPackageInfo);
			
			var xml = new StringBuilder();
			var stringWriter = new StringWriter(xml);
			var writer = new XmlTextWriter(stringWriter);
			properties.Save(writer);
			
			var stringReader = new StringReader(xml.ToString());
			var reader = new XmlTextReader(stringReader);
			properties = Properties.Load(reader);
			
			var deserializedRecentPackageInfo = properties.Get<RecentPackageInfo>("RecentPackageInfo", null);
			
			Assert.AreEqual(recentPackageInfo.Version, deserializedRecentPackageInfo.Version);
		}
		public void RecentPackages_SaveRecentPackages_DoesNotThrowInvalidOperationException()
		{
			CreateOptions();
			var recentPackage = new RecentPackageInfo("id", new Version(1, 0));
			options.RecentPackages.Add(recentPackage);
			
			Assert.DoesNotThrow(() => SaveOptions());
		}
		public void RecentPackages_OneRecentPackageAddedAndOptionsReloadedFromSavedProperties_ContainsOneRecentPackageThatWasSavedPreviously()
		{
			CreateOptions();
			var package = new FakePackage("Test");
			var recentPackage = new RecentPackageInfo(package);
			options.RecentPackages.Add(recentPackage);
			CreateOptions(properties);
			
			var recentPackages = options.RecentPackages;
			
			var expectedRecentPackages = new RecentPackageInfo[] {
				new RecentPackageInfo(package)
			};
			
			RecentPackageInfoCollectionAssert.AreEqual(expectedRecentPackages, recentPackages);
		}
		RecentPackageInfo AddOneRecentPackage ()
		{
			var recentPackage = new RecentPackageInfo ("Id", new SemanticVersion ("1.0"));
			packageSourcesHelper.Options.RecentPackages.Add (recentPackage);
			return recentPackage;
		}
		public void RecentPackageRepository_OneRecentPackage_RecentPackageUsedToCreateRecentPackageRepository ()
		{
			CreateCache ();
			RecentPackageInfo recentPackage = AddOneRecentPackage ();

			IRecentPackageRepository repository = cache.RecentPackageRepository;

			IList<RecentPackageInfo> actualRecentPackages = fakePackageRepositoryFactory.RecentPackagesPassedToCreateRecentPackageRepository;

			var expectedRecentPackages = new RecentPackageInfo[] {
				recentPackage
			};

			Assert.AreEqual (expectedRecentPackages, actualRecentPackages);
		}
		RecentPackageInfo AddRecentPackageToOptions (string id, string version)
		{
			var recentPackage = new RecentPackageInfo (id, new SemanticVersion (version));
			options.RecentPackages.Add (recentPackage);
			return recentPackage;
		}
        public void Version_SerializeThenDeserializeRecentPackageInfoInPropertiesObject_ReturnsSameValueAfterDeserialization()
        {
            var version = new SemanticVersion(1, 0, 0, 0);
            var recentPackageInfo = new RecentPackageInfo("id", version);
            var properties = new Properties();
            properties.Set<RecentPackageInfo>("RecentPackageInfo", recentPackageInfo);

            XElement savedXml = properties.Save();
            properties = Properties.Load(savedXml);
            var deserializedRecentPackageInfo = properties.Get<RecentPackageInfo>("RecentPackageInfo", (RecentPackageInfo)null);

            Assert.AreEqual(recentPackageInfo.Version, deserializedRecentPackageInfo.Version);
        }