コード例 #1
0
            public void Given_ValidParameters_ExpectValidObject()
            {
                AgoraLog agoraLog = MinhaCdnToAgoraLogConverter.ConvertLog(this.validUrl, this.outputFile);

                agoraLog.Should().NotBeNull();
                agoraLog.Lines.Should().NotBeNull();
                agoraLog.Lines.Count().Should().BeGreaterThan(0);
                agoraLog.ToString().Should().NotBeNull();
                Directory.Exists(Path.GetDirectoryName(this.outputFile)).Should().Be(true);
            }
コード例 #2
0
            public void Given_InvalidParameters_ExpectException()
            {
                Action convertLogMethod = () => MinhaCdnToAgoraLogConverter.ConvertLog(string.Empty, string.Empty);

                convertLogMethod.Should().Throw <ArgumentNullException>();

                convertLogMethod = () => MinhaCdnToAgoraLogConverter.ConvertLog(this.randomGenerator.NextString(20, 20), string.Empty);
                convertLogMethod.Should().Throw <UriFormatException>();

                convertLogMethod = () => MinhaCdnToAgoraLogConverter.ConvertLog(this.validUrl, string.Empty);
                convertLogMethod.Should().Throw <ArgumentNullException>();

                convertLogMethod = () => MinhaCdnToAgoraLogConverter.ConvertLog(this.inexistentFileUrl, this.outputFile);
                convertLogMethod.Should().Throw <Exception>();

                convertLogMethod = () => MinhaCdnToAgoraLogConverter.ConvertLog(this.invalidFileUrl, this.outputFile);
                convertLogMethod.Should().Throw <ArgumentException>();
            }
コード例 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("...::: Agile Content Challenge :::...\r\n");
            Console.WriteLine("* 2 - New CDN iTaas:\r\n");

            if ((args.Count() == 0) || (string.IsNullOrWhiteSpace(args[0])) || (string.IsNullOrWhiteSpace(args[1])) || (!Uri.IsWellFormedUriString(args[0], UriKind.Absolute)))
            {
                Console.WriteLine(">> Usage: convert url outputFile\r\n");
            }
            else
            {
                Console.WriteLine("Downloading and converting log file:\r\n+ {0} +\r\nPlease wait...\r\n", args[0]);
                Console.WriteLine(MinhaCdnToAgoraLogConverter.ConvertLog(args[0], args[1]).ToString());
                Console.WriteLine("+ Log saved: {0}. +\r\n", args[1]);
            }

            Console.WriteLine("Pressione qualquer tecla para sair...");
            Console.ReadKey();
        }
コード例 #4
0
ファイル: MinhaCdnTests.cs プロジェクト: fgNv/fmg-agile-test
        public async Task SampleLogContentConvertionShouldMatchExpectedResult()
        {
            var sourceUrl = "https://s3.amazonaws.com/uux-itaas-static/minha-cdn-logs/input-01.txt";
            //var sourceUrl = "https://s3.amazonaws.com/uux-itaas-static/minha-cdn-logs/input-01.txt";
            var converter   = new MinhaCdnToAgoraLogConverter();
            var application = new LogConverterApplication(converter);
            await application.ConvertMinhaCdnToAgora(sourceUrl, _destinationPath);

            Assert.IsTrue(File.Exists(_destinationPath));

            var resultContent = File.ReadAllText(_destinationPath);

            var expectedResultWithoutHeader = "\"MINHA CDN\" GET 200 /robots.txt 100 312 HIT" + Environment.NewLine;

            expectedResultWithoutHeader += "\"MINHA CDN\" POST 200 /myImages 319 101 MISS" + Environment.NewLine;
            expectedResultWithoutHeader += "\"MINHA CDN\" GET 404 /not-found 143 199 MISS" + Environment.NewLine;
            expectedResultWithoutHeader += "\"MINHA CDN\" GET 200 /robots.txt 245 312 REFRESH_HIT";

            var resultWithoutHeader = String.Join(Environment.NewLine, resultContent.Split(Environment.NewLine).Skip(3).ToArray());

            Assert.AreEqual(expectedResultWithoutHeader, resultWithoutHeader);
        }