Inheritance: InMemorySourceStore
Ejemplo n.º 1
0
        public void ConstructorWithNonExistantFileLoadsEmptyList()
        {
            // Arrange
            var mockFileSystem = new Mock<MockableFileSystem>();

            // Act
            XmlSourceStore store = new XmlSourceStore(mockFileSystem.Object, "sourceList.xml");

            // Assert
            Assert.Empty(store.Sources);
        }
Ejemplo n.º 2
0
        public void ConstructorLoadsFile()
        {
            const string toLoad = @"<?xml version=""1.0""?>
            <sources xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
              <source name=""Foo"">http://foo.bar</source>
              <source name=""Baz"">http://biz.baz</source>
            </sources>";

            // Arrange
            var mockFileSystem = new Mock<MockableFileSystem>();
            SetFileContent(mockFileSystem, "sourceList.xml", toLoad);

            // Act
            XmlSourceStore store = new XmlSourceStore(mockFileSystem.Object, "sourceList.xml");

            // Assert
            Assert.Contains(new PackageSource("http://foo.bar", "Foo"), store.Sources);
            Assert.Contains(new PackageSource("http://biz.baz", "Baz"), store.Sources);
        }
Ejemplo n.º 3
0
        public void SavingAfterAddingSourcesUpdatesFile()
        {
            const string expected = @"<?xml version=""1.0""?>
            <sources xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
              <source name=""Foo"">http://foo.bar</source>
              <source name=""Baz"">http://biz.baz</source>
            </sources>";

            // Arrange
            var mockFileSystem = new Mock<MockableFileSystem>();
            MemoryStream strm = CaptureFileContent(mockFileSystem, "sourceList.xml");
            XmlSourceStore store = new XmlSourceStore(mockFileSystem.Object, "sourceList.xml");
            store.AddSource("http://foo.bar", "Foo");
            store.AddSource("http://biz.baz", "Baz");

            // Act
            store.Save();

            // Assert
            Assert.Equal(expected, GetContent(strm));
        }