public void Can_Set_AssemblyConfiguration_Attribute_In_Files()
        {
            // Arrange
            const string attributeName = "AssemblyConfiguration";
            const string attributeValue = "Debug";

            var command =
                new SetAssemblyAttributeInFilesCommand
                {
                    AttributeName = attributeName,
                    AttributeValue = attributeValue,
                    CommandLog = new ConsoleCommandLog(),
                    CreateAttributeIfNotExists = true,
                    DirectoryToSearch = _directoryToSearch,
                    FileNamesToSearch = "AssemblyInfo*.cs",
                    Recursive = true,
                    WriteVerboseLogMessages = true
                };

            // Act
            var succeeded = command.Execute();

            // Assert
            succeeded.ShouldBeTrue();

            foreach (var filename in _testFilenames)
            {
                File.Exists(filename).ShouldBeTrue();

                var text = File.ReadAllText(filename);

                text.ShouldContain("[assembly: AssemblyConfiguration(\"Debug\")]");
            }
        }
Пример #2
0
        public void Can_Set_AssemblyConfiguration_Attribute_In_Files()
        {
            // Arrange
            const string attributeName  = "AssemblyConfiguration";
            const string attributeValue = "Debug";

            var command =
                new SetAssemblyAttributeInFilesCommand
            {
                AttributeName              = attributeName,
                AttributeValue             = attributeValue,
                CommandLog                 = new ConsoleCommandLog(),
                CreateAttributeIfNotExists = true,
                DirectoryToSearch          = _directoryToSearch,
                FileNamesToSearch          = "AssemblyInfo*.cs",
                Recursive = true,
                WriteVerboseLogMessages = true
            };

            // Act
            var succeeded = command.Execute();

            // Assert
            succeeded.ShouldBeTrue();

            foreach (var filename in _testFilenames)
            {
                File.Exists(filename).ShouldBeTrue();

                var text = File.ReadAllText(filename);

                text.ShouldContain("[assembly: AssemblyConfiguration(\"Debug\")]");
            }
        }
        /// <summary>
        /// When implemented in a derived class, performs the execution of the activity.
        /// </summary>
        /// <param name="context">The execution context under which the activity executes.</param>
        protected override void Execute(CodeActivityContext context)
        {
            var attributeName = AttributeName.Get(context);
            var attributeValue = AttributeValue.Get(context);
            var createAttributeIfNotExists = CreateAttributeIfNotExists.Get(context);
            var directoryToSearch = DirectoryToSearch.Get(context);
            var fileNamesToSearch = FileNamesToSearch.Get(context);
            var commandLog = new CodeActivityContextCommandLog(context);
            var recursive = Recursive.Get(context);
            var writeVerboseLogMessages = WriteVerboseLogMessages.Get(context);

            var command =
                new SetAssemblyAttributeInFilesCommand
                {
                    AttributeName = attributeName,
                    AttributeValue = attributeValue,
                    CreateAttributeIfNotExists = createAttributeIfNotExists,
                    DirectoryToSearch = directoryToSearch,
                    FileNamesToSearch = fileNamesToSearch,
                    CommandLog = commandLog,
                    Recursive = recursive,
                    WriteVerboseLogMessages = writeVerboseLogMessages
                };

            var successful = command.Execute();

            if (false == successful)
                commandLog.Error("The SetAssemblyAttributeInFiles activity failed.");
        }