Ejemplo n.º 1
0
        /// <summary>
        /// Create Test metadata for a service
        /// </summary>
        /// <param name="org">The Organization code for the service owner</param>
        /// <param name="service">The service code for the current service</param>
        /// <param name="test">The test metadata</param>
        /// <returns>A boolean indicating if saving was ok</returns>
        public bool UpdateTest(string org, string service, TestMetadata test)
        {
            string dirName = _settings.GetTestPath(org, service, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext));
            bool   updated = false;

            if (!Directory.Exists(dirName))
            {
                Directory.CreateDirectory(dirName);
            }

            if (string.IsNullOrEmpty(test.FileName))
            {
                // TODO: Use type
                test.FileName = test.Name + ".cs";
            }

            File.WriteAllText(dirName + test.FileName, test.Content ?? "");
            updated = true;

            return(updated);
        }