< Summary

Class:Microsoft.Azure.Batch.FileStaging.FileStagingNamingHelpers
Assembly:Microsoft.Azure.Batch.FileStaging
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch.FileStaging\src\FileStagingNamingHelpers.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:51
Line coverage:100% (11 of 11)
Covered branches:3
Total branches:4
Branch coverage:75% (3 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
MakeDefaultNamePlusNamingFragment(...)-100%100%
ConstructDefaultName(...)-100%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch.FileStaging\src\FileStagingNamingHelpers.cs

#LineLine coverage
 1// Copyright (c) Microsoft and contributors.  All rights reserved.
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6// http://www.apache.org/licenses/LICENSE-2.0
 7//
 8// Unless required by applicable law or agreed to in writing, software
 9// distributed under the License is distributed on an "AS IS" BASIS,
 10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11//
 12// See the License for the specific language governing permissions and
 13// limitations under the License.
 14
 15using System;
 16using System.Text;
 17
 18namespace Microsoft.Azure.Batch.FileStaging
 19{
 20    internal static class FileStagingNamingHelpers
 21    {
 22        public const int MaxContainerNameLength = 63;
 23
 24        private static string MakeDefaultNamePlusNamingFragment(string namingFragment)
 25        {
 126            StringBuilder newNameBuilder = new StringBuilder();
 27
 128            newNameBuilder.Append(Batch.Constants.DefaultConveniencePrefix);
 29
 130            if (!string.IsNullOrWhiteSpace(namingFragment))
 31            {
 132                newNameBuilder.Append(namingFragment);
 133                newNameBuilder.Append("-");
 34            }
 35
 136            string newName = newNameBuilder.ToString();
 37
 138            return newName;
 39        }
 40
 41        internal static string ConstructDefaultName(string namingFragment)
 42        {
 143            string timeString = DateTime.UtcNow.ToString("yyyy-MM-dd-HH-mm-ss");
 144            string containerName = MakeDefaultNamePlusNamingFragment(namingFragment) + timeString + Guid.NewGuid().ToStr
 45
 146            containerName = containerName.Length > MaxContainerNameLength ? containerName.Substring(0, MaxContainerNameL
 47
 148            return containerName;
 49        }
 50    }
 51}