Пример #1
0
        public void HandleMinutesDuringV8Migration()
        {
            // Arrange
            var bufferFiles = new TimeRolledBufferFiles(directoryService, "SomeBuffer");

            var want = new[]
            {
                // "json" extension was used < v8
                "SomeBuffer-200112312358.json",
                "SomeBuffer-200112312359.json",
                "SomeBuffer-200201010000.json",
                // "txt" is used from >= v8
                "SomeBuffer-200201010000.txt",
                "SomeBuffer-200201010001.txt",
                "SomeBuffer-200201010002.txt"
            };

            directoryService.Files = Randomize.Values(want);

            // Act
            var got = bufferFiles.Get();

            // Assert
            got.ShouldBe(want);
        }
Пример #2
0
        public void HandleDates()
        {
            // Arrange
            var want = new[]
            {
                "Buffer-20001020.json",
                "Buffer-20001021.json",
                "Buffer-20001022.json"
            };

            directoryService
            .Setup(mock => mock.GetFiles(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(want.Reverse().ToArray);      // Reverse expected elements

            // Act
            var got = bufferFiles.Get();

            // Assert
            got.ShouldBe(want);
        }
Пример #3
0
        public void HandleYears()
        {
            // Arrange
            var want = new[]
            {
                "Buffer-2008.json",
                "Buffer-2009.json",
                "Buffer-2010.json",
                "Buffer-2011.json"
            };

            directoryService
            .Setup(mock => mock.GetFiles(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Randomize.Values(want));

            // Act
            var got = bufferFiles.Get();

            // Assert
            got.ShouldBe(want);
        }
Пример #4
0
        public void GetOnlyBufferFiles()
        {
            // Arrange
            var bufferFiles = new TimeRolledBufferFiles(directoryService, "SomeBuffer");

            var want = new[]
            {
                "SomeBuffer-2000.txt",
                "SomeBuffer-200001.txt",
                "SomeBuffer-20000102.txt",
                "SomeBuffer-2000010203.txt",
                "SomeBuffer-200001020304.txt",
            };

            directoryService.Files = Randomize.Values(
                want.Concat(new[]
            {
                // Wrong extension
                "SomeBuffer-2000.config",
                "SomeBuffer-2000.dll",
                "SomeBuffer-2000.exe",
                "SomeBuffer-2000.xml",
                // Wrong file name format
                "SomeBuffer.txt",
                "SomeBuffer.json",
                "XSomeBuffer-2000.txt",
                "XSomeBuffer-2000.json",
                "SomeBufferX-2000.txt",
                "SomeBufferX-2000.json",
                "SomeBuffer-X2000.txt",
                "SomeBuffer-X2000.json",
                "SomeBuffer-2000X.txt",
                "SomeBuffer-2000X.json",
                "SomeBuffer-2000.Xtxt",
                "SomeBuffer-2000.Xjson"
            }));

            // Act
            var got = bufferFiles.Get();

            // Assert
            got.ShouldBe(want);
        }
Пример #5
0
        public void HandleYears()
        {
            // Arrange
            var bufferFiles = new TimeRolledBufferFiles(directoryService, "SomeBuffer");

            var want = new[]
            {
                "SomeBuffer-2008.txt",
                "SomeBuffer-2009.txt",
                "SomeBuffer-2010.txt",
                "SomeBuffer-2011.txt"
            };

            directoryService.Files = Randomize.Values(want);

            // Act
            var got = bufferFiles.Get();

            // Assert
            got.ShouldBe(want);
        }