public void GetBlobNameTest() { // Arrange string iotHub = "foo.azure-devices.net"; string deviceId = "abcd"; string id = "pqr"; string extension = "json.gz"; var regex = new Regex(BlobNameRegexPattern); var azureBlobLogsUploader = new AzureBlobRequestsUploader(iotHub, deviceId, Mock.Of <IAzureBlobUploader>()); // Act string blobName = azureBlobLogsUploader.GetBlobName(id, AzureBlobRequestsUploader.GetLogsExtension(LogsContentEncoding.Gzip, LogsContentType.Json)); // Assert Assert.NotNull(blobName); Match match = regex.Match(blobName); Assert.True(match.Success); string receivedIotHub = match.Groups["iothub"].Value; string receivedDeviceId = match.Groups["deviceid"].Value; string receivedId = match.Groups["id"].Value; string receivedTimestamp = match.Groups["timestamp"].Value; string receivedExtension = match.Groups["extension"].Value; Assert.Equal(id, receivedId); Assert.Equal(iotHub, receivedIotHub); Assert.Equal(deviceId, receivedDeviceId); Assert.Equal(extension, receivedExtension); Assert.True(DateTime.UtcNow - DateTime.ParseExact(receivedTimestamp, "yyyy-MM-dd--HH-mm-ss", CultureInfo.InvariantCulture) < TimeSpan.FromSeconds(10)); }
public void GetExtensionTest(LogsContentEncoding contentEncoding, LogsContentType contentType, string expectedExtension) { Assert.Equal(expectedExtension, AzureBlobRequestsUploader.GetLogsExtension(contentEncoding, contentType)); }