internal static void AddContext(MemberInfo memberInfo, string prefix, string extension)
        {
            var value = new TemporaryFileContext(prefix, extension);

            if (!_CreatedTempFilePaths.TryAdd(memberInfo, value))
            {
                value.Dispose();
                throw new InvalidOperationException(Messages.CHECK_ADDED);
            }
        }
示例#2
0
        public static string GetTempFilePath(string extension = null)
        {
            var memberInfo = new StackTrace()
                             .GetFrame(1)
                             .GetMethod();

            return(TemporaryFileContext
                   .GetContext(memberInfo)
                   .GetFilePath(extension));
        }
        public override void Before(MethodInfo methodUnderTest)
        {
            _ = Check.NotNull(nameof(methodUnderTest), methodUnderTest);

            if (string.IsNullOrWhiteSpace(Prefix))
            {
                Prefix = methodUnderTest.Name;
            }

            TemporaryFileContext.AddContext(methodUnderTest, Prefix, Extension);
        }
 public override void After(MethodInfo methodUnderTest) => TemporaryFileContext.GetContext(methodUnderTest)?.Dispose();