Ejemplo n.º 1
0
        public void TryParse_IfMalformedStartTime_ReturnsNull()
        {
            string[] fields = CreateArray("<INVALID>", "PutBlob", "blob", @"/storagesample/sample-container/""0x8D199A96CB71468""/sample-blob.txt");

            StorageAnalyticsLogEntry entry = StorageAnalyticsLogEntry.TryParse(fields);

            Assert.Null(entry);
        }
Ejemplo n.º 2
0
        public void TryParse_IfUnrecognizedOperation_IgnoresIt()
        {
            string[] fields = CreateArray("2014-09-08T18:44:18.9681025Z", "INVALID", "blob", @"/storagesample/sample-container/""0x8D199A96CB71468""/sample-blob.txt");

            StorageAnalyticsLogEntry entry = StorageAnalyticsLogEntry.TryParse(fields);

            Assert.NotNull(entry);
            Assert.False(entry.OperationType.HasValue);
        }
        /// <summary>
        /// Attempts to parse a single line of Storage Analytics Log file using Regex matches.
        /// </summary>
        /// <param name="line">A line as extracted from a Storage Analytics Log file. Must not be null or empty.</param>
        /// <returns>Parsed instance of <see cref="StorageAnalyticsLogEntry"/> if the given line matches expected format
        /// of the Storage Analytics Log v1.0, or null otherwise.</returns>
        public StorageAnalyticsLogEntry TryParseLogEntry(string line)
        {
            Debug.Assert(line != null);

            var capturedFields =
                from Match m in _compiledRegex.Matches(line)
                select WebUtility.HtmlDecode(m.Groups[1].Value);

            string[] fieldsArray = capturedFields.ToArray();

            if (fieldsArray.Length != ColumnCount)
            {
                return(null);
            }

            return(StorageAnalyticsLogEntry.TryParse(fieldsArray));
        }
Ejemplo n.º 4
0
        public void TryParse_IfValidFieldValues_ReturnsLogEntryInstance()
        {
            string requestStartTime   = "2014-09-08T18:44:18.9681025Z";
            string operationType      = "PutBlob";
            string serviceType        = "blob";
            string requestedObjectKey = @"/storagesample/sample-container/""0x8D199A96CB71468""/sample-blob.txt";

            string[] fields = CreateArray(requestStartTime, operationType, serviceType, requestedObjectKey);

            StorageAnalyticsLogEntry entry = StorageAnalyticsLogEntry.TryParse(fields);

            Assert.NotNull(entry);
            DateTime expectedRequestStartTime = new DateTime(635457986589681025L, DateTimeKind.Utc);

            Assert.AreEqual(expectedRequestStartTime, entry.RequestStartTime);
            Assert.AreEqual(DateTimeKind.Utc, entry.RequestStartTime.Kind);
            Assert.AreEqual(StorageServiceOperationType.PutBlob, entry.OperationType);
            Assert.AreEqual(StorageServiceType.Blob, entry.ServiceType);
            Assert.AreEqual(requestedObjectKey, entry.RequestedObjectKey);
        }