protected RazorProjectItem AddProjectItemFromText(string text, string filePath = "_ViewImports.cshtml")
        {
            var projectItem = CreateProjectItemFromText(text, filePath);

            FileSystem.Add(projectItem);
            return(projectItem);
        }
        public IFile CopyTo(string destFileName, bool overwrite)
        {
            EnsureExists();

            if (FileSystem == null)
            {
                throw new InvalidOperationException("FileMock FileSystem property should be set before copying is possible.");
            }

            var file = FileSystem.GetFile(destFileName);

            if (!file.Exists)
            {
                file = new FileMock(Path.GetFileName(destFileName), _data.ToArray())
                {
                    FullName = destFileName
                };
                FileSystem.Add(file);
            }
            else if (overwrite)
            {
                file.WriteAllBytes(this.ReadAllBytes());
            }
            else
            {
                throw new IOException(string.Format("Cannot copy '{1}' to '{0}': file already exists.", destFileName, this.FullName));
            }

            return(file);
        }
 private void AddAResource() =>
 FileSystem.Add(
     "c:\\users\\user\\source\\repos\\project\\aresource.json",
     @"{
             ""type"": ""Microsoft.Web/connections"",
             ""apiVersion"": ""2016-06-01"",
             ""proper"": ""properties were probably here""
         }"
     );
Esempio n. 4
0
 private void AddAResource() =>
 FileSystem.Add(
     "c:\\users\\user\\source\\repos\\project\\aresource.json",
     @"{
             ""definition"": {
                 ""$schema"": ""https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#"",
                 ""contentVersion"": ""1.0.0.0"",
             },
             ""parameters"": {
                 ""we don't want these"": ""at all""
             }
         }"
     );
        public void Add(string filePath, string content)
        {
            if (filePath is null)
            {
                throw new ArgumentNullException(nameof(filePath));
            }

            var item = new TestRazorProjectItem(filePath, fileKind: FileKinds.Component)
            {
                Content = content ?? string.Empty,
            };

            FileSystem.Add(item);
        }
        [TestCase(@"[]")] // ?? Should we swap object/templateLink with array?
        public void Reports_Error_For_Invalid_Contents(string content)
        {
            var relativePath = @"./aresource.json";
            var input        = SimpleTemplateWithRelativeResource(relativePath);

            FileSystem.Add(
                "c:\\users\\user\\source\\repos\\project\\aresource.json",
                content
                );

            GenerateOutput(input);

            Assert.AreEqual(
                @"Content of linked file should be a JSON object. ./aresource.json",
                Reporter.Errors[0].error,
                Reporter.Errors[0].error
                );
        }