Example #1
0
 public void GetMetadataValueThrowsArgumentExceptionWhenNameIsEmpty()
 {
     using (var transformation = new FakeTransformation())
         using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment))
         {
             context.GetMetadataValue(" \t\r\n");
         }
 }
Example #2
0
 public void GetMetadataValueReturnsValueSuppliedByProvider()
 {
     using (var transformation = new FakeTransformation())
         using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment))
         {
             const string ExpectedValue = "TestValue";
             transformation.Host.GetMetadataValue = (hierarchy, fileName, metadataName) => ExpectedValue;
             Assert.AreEqual(ExpectedValue, context.GetMetadataValue("TestProperty"));
         }
 }
Example #3
0
        public void GetMetadataValuePassesInputFileToProvider()
        {
            using (var transformation = new FakeTransformation())
                using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment))
                {
                    transformation.Host.TemplateFile = Path.GetRandomFileName();

                    string actualFileName = null;
                    transformation.Host.GetMetadataValue = (hierarchy, fileName, metadataName) =>
                    {
                        actualFileName = fileName;
                        return(string.Empty);
                    };

                    context.GetMetadataValue("Irrelevant");
                    Assert.AreSame(transformation.Host.TemplateFile, actualFileName);
                }
        }
Example #4
0
        public void GetMetadataValuePassesHostHierarchyToProvider()
        {
            using (var transformation = new FakeTransformation())
                using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment))
                {
                    transformation.Host.Hierarchy = new object();

                    object actualHierarchy = null;
                    transformation.Host.GetMetadataValue = (hierarchy, fileName, metadataName) =>
                    {
                        actualHierarchy = hierarchy;
                        return(string.Empty);
                    };

                    context.GetMetadataValue("Irrelevant");
                    Assert.AreSame(transformation.Host.Hierarchy, actualHierarchy);
                }
        }
 public void GetMetadataValueThrowsArgumentNullExceptionWhenNameIsNull()
 {
     using (var transformation = new FakeTransformation())
     using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment))
     {
         context.GetMetadataValue(null);
     }
 }
 public void GetMetadataValueReturnsValueSuppliedByProvider()
 {
     using (var transformation = new FakeTransformation())
     using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment))
     {
         const string ExpectedValue = "TestValue";
         transformation.Host.GetMetadataValue = (hierarchy, fileName, metadataName) => ExpectedValue;
         Assert.AreEqual(ExpectedValue, context.GetMetadataValue("TestProperty"));
     }
 }
        public void GetMetadataValuePassesInputFileToProvider()
        {
            using (var transformation = new FakeTransformation())
            using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment))
            {
                transformation.Host.TemplateFile = Path.GetRandomFileName();

                string actualFileName = null;
                transformation.Host.GetMetadataValue = (hierarchy, fileName, metadataName) =>
                {
                    actualFileName = fileName;
                    return string.Empty;
                };

                context.GetMetadataValue("Irrelevant");
                Assert.AreSame(transformation.Host.TemplateFile, actualFileName);
            }
        }
        public void GetMetadataValuePassesHostHierarchyToProvider()
        {
            using (var transformation = new FakeTransformation())
            using (var context = new TransformationContext(transformation, transformation.GenerationEnvironment))
            {
                transformation.Host.Hierarchy = new object();

                object actualHierarchy = null;
                transformation.Host.GetMetadataValue = (hierarchy, fileName, metadataName) =>
                {
                    actualHierarchy = hierarchy;
                    return string.Empty;
                };

                context.GetMetadataValue("Irrelevant");
                Assert.AreSame(transformation.Host.Hierarchy, actualHierarchy);
            }
        }