public void GetAllElements_EmptyOrNonexistentDirectory_ReturnsEmptyCollection()
        {
            WithUniqueTempDirectory(dirInfo =>
            {
                // Arrange
                var repository = new FileSystemXmlRepository(dirInfo);

                // Act
                var allElements = repository.GetAllElements();

                // Assert
                Assert.Equal(0, allElements.Count);
            });
        }
예제 #2
0
        public void GetAllElements_EmptyOrNonexistentDirectory_ReturnsEmptyCollection()
        {
            WithUniqueTempDirectory(dirInfo =>
            {
                // Arrange
                var repository = new FileSystemXmlRepository(dirInfo);

                // Act
                var allElements = repository.GetAllElements();

                // Assert
                Assert.Equal(0, allElements.Count);
            });
        }
예제 #3
0
        public void StoreElements_ThenRetrieve_SeesAllElements()
        {
            WithUniqueTempDirectory(dirInfo =>
            {
                // Arrange
                var repository = new FileSystemXmlRepository(dirInfo);

                // Act
                repository.StoreElement(new XElement("element1"), friendlyName: null);
                repository.StoreElement(new XElement("element2"), friendlyName: null);
                repository.StoreElement(new XElement("element3"), friendlyName: null);
                var allElements = repository.GetAllElements();

                // Assert
                var orderedNames = allElements.Select(el => el.Name.LocalName).OrderBy(name => name);
                Assert.Equal(new[] { "element1", "element2", "element3" }, orderedNames);
            });
        }
        public void StoreElements_ThenRetrieve_SeesAllElements()
        {
            WithUniqueTempDirectory(dirInfo =>
            {
                // Arrange
                var repository = new FileSystemXmlRepository(dirInfo);

                // Act
                repository.StoreElement(new XElement("element1"), friendlyName: null);
                repository.StoreElement(new XElement("element2"), friendlyName: null);
                repository.StoreElement(new XElement("element3"), friendlyName: null);
                var allElements = repository.GetAllElements();

                // Assert
                var orderedNames = allElements.Select(el => el.Name.LocalName).OrderBy(name => name);
                Assert.Equal(new[] { "element1", "element2", "element3" }, orderedNames);
            });
        }