コード例 #1
0
        public void TestNormalize()
        {
            var keep = new ImplementationPreferences {ID = "id1", UserStability = Stability.Testing};
            var superflous = new ImplementationPreferences {ID = "id2"};
            var preferences = new FeedPreferences {Implementations = {keep, superflous}};

            preferences.Normalize();
            preferences.Implementations.Should().BeEquivalentTo(keep);
        }
コード例 #2
0
        public void TestGetImplementationPreferences()
        {
            var preferences = new FeedPreferences();
            var prefs1 = preferences["id1"];
            preferences["id1"].Should().BeSameAs(prefs1, because: "Second call with same ID should return same reference");

            var prefs2 = new ImplementationPreferences {ID = "id2"};
            preferences.Implementations.Add(prefs2);
            preferences["id2"].Should().BeSameAs(prefs2, because: "Call with pre-existing ID should return existing reference");

            preferences.Implementations.Should().BeEquivalentTo(prefs1, prefs2);
        }
コード例 #3
0
        public void TestNormalize()
        {
            var keep = new ImplementationPreferences {
                ID = "id1", UserStability = Stability.Testing
            };
            var superflous = new ImplementationPreferences {
                ID = "id2"
            };
            var preferences = new FeedPreferences {
                Implementations = { keep, superflous }
            };

            preferences.Normalize();
            CollectionAssert.AreEquivalent(new[] { keep }, preferences.Implementations);
        }
コード例 #4
0
        public void TestSaveLoad()
        {
            FeedPreferences preferences1 = CreateTestFeedPreferences(), preferences2;
            Assert.That(preferences1, Is.XmlSerializable);
            using (var tempFile = new TemporaryFile("0install-unit-tests"))
            {
                // Write and read file
                preferences1.SaveXml(tempFile);
                preferences2 = XmlStorage.LoadXml<FeedPreferences>(tempFile);
            }

            // Ensure data stayed the same
            preferences2.Should().Be(preferences1, because: "Serialized objects should be equal.");
            preferences2.GetHashCode().Should().Be(preferences1.GetHashCode(), because: "Serialized objects' hashes should be equal.");
            preferences2.Should().NotBeSameAs(preferences1, because: "Serialized objects should not return the same reference.");
        }
コード例 #5
0
        public void TestGetImplementationPreferences()
        {
            var preferences = new FeedPreferences();
            var prefs1      = preferences["id1"];

            Assert.AreSame(prefs1, preferences["id1"], "Second call with same ID should return same reference");

            var prefs2 = new ImplementationPreferences {
                ID = "id2"
            };

            preferences.Implementations.Add(prefs2);
            Assert.AreSame(prefs2, preferences["id2"], "Call with pre-existing ID should return existing reference");

            CollectionAssert.AreEquivalent(new[] { prefs1, prefs2 }, preferences.Implementations);
        }