Exemple #1
0
    public void GetAllElements_EmptyOrNonexistentDirectory_ReturnsEmptyCollection()
    {
        WithUniqueTempDirectory(dirInfo =>
        {
            // Arrange
            var repository = new FileSystemXmlRepository(dirInfo, NullLoggerFactory.Instance);

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

            // Assert
            Assert.Equal(0, allElements.Count);
        });
    }
Exemple #2
0
    public void StoreElements_ThenRetrieve_SeesAllElements()
    {
        WithUniqueTempDirectory(dirInfo =>
        {
            // Arrange
            var repository = new FileSystemXmlRepository(dirInfo, NullLoggerFactory.Instance);

            // 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);
        });
    }