public void Setup()
 {
     _systemClock = MockRepository.GenerateStub<ISystemClock>();
     _logger = new MockLogger();
     _messagingService = new MessagingService(_logger);
     _supportCase = new SupportCase("Looking at the logs", _systemClock);
 }
 public void SetUp()
 {
     _nodeRequestId = 1;
     _host = new MockHost();
     _mockLogger = new MockLogger();
     _host.OnLoggingThreadException += this.LoggingException;
 }
        public void ImportFromExtensionsPathNotFound()
        {
            string extnDir1 = null;
            string mainProjectPath = null;

            try {
                extnDir1 = GetNewExtensionsPathAndCreateFile("extensions1", Path.Combine("foo", "extn.proj"), GetExtensionTargetsFileContent1());
                mainProjectPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("main.proj", GetMainTargetFileContent());

                var projColln = new ProjectCollection();
                projColln.ResetToolsetsForTests(WriteConfigFileAndGetReader("MSBuildExtensionsPath", extnDir1, Path.Combine("tmp", "nonexistant")));
                var logger = new MockLogger();
                projColln.RegisterLogger(logger);

                Assert.Throws<InvalidProjectFileException>(() => projColln.LoadProject(mainProjectPath));

                logger.AssertLogContains("MSB4226");
            } finally {
                if (mainProjectPath != null)
                {
                    FileUtilities.DeleteNoThrow(mainProjectPath);
                }
                if (extnDir1 != null)
                {
                    FileUtilities.DeleteDirectoryNoThrow(extnDir1, recursive: true);
                }
            }
        }
Exemple #4
0
        public void VerifyNewLinesAndTabsEvaluateToEmpty()
        {
            MockLogger mockLogger = new MockLogger();

            string projectFileContent = ObjectModelHelpers.CleanupFileContents(@"
                    <Project xmlns='msbuildnamespace'>
                       <PropertyGroup><NewLine>" + Environment.NewLine + Environment.NewLine + "</NewLine></PropertyGroup>" +
                       "<PropertyGroup><Tab>\t\t\t\t</Tab></PropertyGroup>" +
                       "<PropertyGroup><CarriageReturn>\r\r\r\r</CarriageReturn></PropertyGroup>" +
                        @"<PropertyGroup><Message1 Condition =""'$(NewLine)' == ''"">NewLineEvalAsEmpty</Message1></PropertyGroup>
                        <PropertyGroup><Message2 Condition =""'$(Tab)' == ''"">TabEvalAsEmpty</Message2></PropertyGroup>
                        <PropertyGroup><Message3 Condition =""'$(CarriageReturn)' == ''"">CarriageReturnEvalAsEmpty</Message3></PropertyGroup>

                        <Target Name=""BUild"">
                           <Message Text=""$(Message1)"" Importance=""High""/>
                          <Message Text=""$(Message2)"" Importance=""High""/>
                          <Message Text=""$(Message3)"" Importance=""High""/>
                       </Target>                    
                    </Project>");

            ProjectRootElement xml = ProjectRootElement.Create(XmlReader.Create(new StringReader(projectFileContent)));
            Project project = new Project(xml);
            bool result = project.Build(new ILogger[] { mockLogger });
            Assert.Equal(true, result);
            mockLogger.AssertLogContains("NewLineEvalAsEmpty");
            mockLogger.AssertLogContains("TabEvalAsEmpty");
            mockLogger.AssertLogContains("CarriageReturnEvalAsEmpty");
        }
 /// <summary>
 /// Sets up to run tests.  Creates the host object.
 /// </summary>
 public TargetBuilder_Tests()
 {
     _nodeRequestId = 1;
     _host = new MockHost();
     _mockLogger = new MockLogger();
     _host.OnLoggingThreadException += this.LoggingException;
 }
        public void WhenCallingFatalCallCountShouldIncrease()
        {
            ILogger sut = new MockLogger();
            sut.Fatal(TestString, new Exception());

            MockLogger mockLogger = (MockLogger)sut;
            mockLogger.FatalCallCount.Should().Be(1, "because we only called the fatal method once");
        }
        public void WhenCallingWarnCallCountShouldIncrease()
        {
            ILogger sut = new MockLogger();
            sut.Warn(TestString);

            MockLogger mockLogger = (MockLogger)sut;
            mockLogger.WarnCallCount.Should().Be(1, "because we only called the warn method once");
        }
Exemple #8
0
        public void Setup()
        {
            Logger = new LoggingExtensions.Moq.MockLogger();
            LoggingExtensions.Logging.Log.InitializeWith(Logger);

            Context();
            Because();
        }
Exemple #9
0
        public void InitializeLoggerAndAspect()
        {
            _logger = new MockLogger();
            LogAttribute.Logger = _logger;

            Mock<IConfigurationProvider> mock = new Mock<IConfigurationProvider>();
            mock.Setup(provider => provider.ShouldLog(It.IsAny<LogAttribute>())).Returns(true);
            LogAttribute.ConfigurationProvider = mock.Object;
        }
        public void AddNewErrorWarningMessageElement()
        {
            MockLogger logger = new MockLogger();

            /**
             * <Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
             *   <Target Name=`Build`>
             *   </Target>
             * </Project
             */

            ProjectRootElement projectXml = ProjectRootElement.Create();
            ProjectTargetElement target = projectXml.AddTarget("Build");
            projectXml.DefaultTargets = "Build";
            projectXml.ToolsVersion = ObjectModelHelpers.MSBuildDefaultToolsVersion;

            SolutionProjectGenerator.AddErrorWarningMessageElement(target, XMakeElements.message, true, "SolutionVenusProjectNoClean");
            SolutionProjectGenerator.AddErrorWarningMessageElement(target, XMakeElements.warning, true, "SolutionParseUnknownProjectType", "proj1.csproj");
            SolutionProjectGenerator.AddErrorWarningMessageElement(target, XMakeElements.error, true, "SolutionInvalidSolutionConfiguration");

            Project project = new Project(projectXml);

            project.Build(logger);

            string code = null;
            string keyword = null;
            string text = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionParseUnknownProjectType", "proj1.csproj");

            // check the error event
            Assert.AreEqual(1, logger.Warnings.Count);
            BuildWarningEventArgs warning = logger.Warnings[0];

            Assert.AreEqual(text, warning.Message);
            Assert.AreEqual(code, warning.Code);
            Assert.AreEqual(keyword, warning.HelpKeyword);

            code = null;
            keyword = null;
            text = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionInvalidSolutionConfiguration");

            // check the warning event
            Assert.AreEqual(1, logger.Errors.Count);
            BuildErrorEventArgs error = logger.Errors[0];

            Assert.AreEqual(text, error.Message);
            Assert.AreEqual(code, error.Code);
            Assert.AreEqual(keyword, error.HelpKeyword);

            code = null;
            keyword = null;
            text = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionVenusProjectNoClean");

            // check the message event
            Assert.IsTrue(logger.FullLog.Contains(text), "Log should contain the regular message");
        }
        public void WhenTestingAFullTestcaseClassWithDebugDisplayShouldLogEverythingAndTheObject()
        {
            MockLogger logger = new MockLogger();
            LogAttribute.Logger = logger;

            FullTestClass testClass = CreateTestClass();
            testClass.Value.Should().NotBeNullOrWhiteSpace();

            FullTestClass.EmbeddedMethod();

            logger.DebugCallCount.Should().Be(24, "because we call the Entry, Exit and Success methods for the constructor, property and methods, even private method");
        }
        public void ResolveAllReturnsRegisteredObjectsForBaseClass()
        {
            IUnityContainer container = new UnityContainer();
            ILogger o1 = new MockLogger();
            ILogger o2 = new SpecialLogger();

            container
                .RegisterInstance<ILogger>("o1", o1)
                .RegisterInstance<ILogger>("o2", o2);

            List<ILogger> results = new List<ILogger>(container.ResolveAll<ILogger>());
            CollectionAssert.AreEqual(new ILogger[] {o1, o2}, results);
        }
        public void SetUp()
        {
            // Ensure that any previous tests which may have been using the default BuildManager do not conflict with us.
            BuildManager.DefaultBuildManager.Dispose();

            _logger = new MockLogger();
            _parameters = new BuildParameters();
            _parameters.ShutdownInProcNodeOnBuildFinish = true;
            _parameters.Loggers = new ILogger[] { _logger };
            _parameters.EnableNodeReuse = false;
            _buildManager = new BuildManager();
            _projectCollection = new ProjectCollection();
            Environment.SetEnvironmentVariable("MSBUILDINPROCENVCHECK", "1");
        }
        public void EmptyItemSpecInTargetOutputs()
        {
            MockLogger ml = new MockLogger();
            Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
            @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
      	        <Target Name='Build'
		            Inputs='@(TASKXML)'
		            Outputs=""@(TASKXML->'%(OutputFile)');@(TASKXML->'%(PasFile)');"">
       	           <Message Text='Running Build target' Importance='High'/>
	            </Target>
	            <ItemGroup>
		            <TASKXML Include='bcc32task.xml'>
                        <OutputFile>bcc32task.cs</OutputFile>
		            </TASKXML>
      		        <TASKXML Include='ccc32task.xml'>
                        <PasFile>ccc32task.pas</PasFile>
		            </TASKXML>
	            </ItemGroup>
              </Project>"))));

            bool success = p.Build("Build", new ILogger[] { ml });

            Assert.True(success);

            // It should not have skipped the "Build" target since some output metadata was missing
            ml.AssertLogContains("Running Build target");

            ml = new MockLogger();
            p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
            @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
      	        <Target Name='Build'
		            Inputs='@(TASKXML)'
		            Outputs=""@(TASKXML->'%(OutputFile)');@(TASKXML->'%(PasFile)');"">
       	           <Message Text='Running Build target' Importance='High'/>
	            </Target>
	            <ItemGroup>
		            <TASKXML Include='bcc32task.xml'>
		            </TASKXML>
      		        <TASKXML Include='ccc32task.xml'>
		            </TASKXML>
	            </ItemGroup>
              </Project>"))));

            success = p.Build("Build", new ILogger[] { ml });

            Assert.True(success);

            // It should have actually skipped the "Build" target since some output metadata was missing
            ml.AssertLogDoesntContain("Running Build target");
        }
        public void WhenTestingAFullTestcaseClassShouldLogEverything()
        {
            MockLogger logger = new MockLogger();
            LogAttribute.Logger = logger;

            FullTestClass testClass = new FullTestClass
            {
                Value = Guid.NewGuid().ToString()
            };
            testClass.Value.Should().NotBeNullOrEmpty();

            FullTestClass.EmbeddedMethod();

            logger.DebugCallCount.Should().Be(15, "because we call the Entry, Exit and Success methods for the constructor, property and methods, even private method");
        }
        public void OverrideTaskPathIsRelative()
        {
            //Note Engine's BinPath is distinct from the ToolsVersion's ToolsPath
            ProjectCollection e = new ProjectCollection();
            Toolset t = new Toolset("toolsversionname", "c:\\directory1\\directory2", new PropertyDictionary<ProjectPropertyInstance>(), new ProjectCollection(), new DirectoryGetFiles(this.getFiles), new LoadXmlFromPath(this.loadXmlFromPath), "msbuildoverridetasks", new DirectoryExists(this.directoryExists));

            MockLogger mockLogger = new MockLogger();
            LoggingService service = (LoggingService)LoggingService.CreateLoggingService(LoggerMode.Synchronous, 1);
            service.RegisterLogger(mockLogger);

            TaskRegistry taskoverrideRegistry = (TaskRegistry)t.GetOverrideTaskRegistry(service, new BuildEventContext(1, 2, BuildEventContext.InvalidProjectContextId, 4), e.ProjectRootElementCache);
            Assert.IsNotNull(taskoverrideRegistry);
            Assert.IsTrue(taskoverrideRegistry.TaskRegistrations.Count == 0);
            string rootedPathMessage = ResourceUtilities.FormatResourceString("OverrideTaskNotRootedPath", "msbuildoverridetasks");
            mockLogger.AssertLogContains(ResourceUtilities.FormatResourceString("OverrideTasksFileFailure", rootedPathMessage));
        }
Exemple #17
0
        public void Basic()
        {
            MockLogger l = new MockLogger();
            Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(@"

                <Project DefaultTargets='Build' ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'> 
                   <Target Name='CleanUp'>
                      <Message Text='CleanUp-was-called.'/>
                   </Target>
                   <Target Name='Build'>
                      <Error Text='This is an error.'/>
                      <OnError ExecuteTargets='CleanUp'/>
                   </Target>
                </Project>"))));

            p.Build(new string[] { "Build" }, new ILogger[] { l });

            Assert.Equal(1, l.ErrorCount); // "Expected one error because 'Build' failed."
            Assert.True((l.FullLog.IndexOf("CleanUp-was-called") != -1)); // "The CleanUp target should have been called."
        }
        public void EmptyItemSpecInTargetInputs()
        {
            MockLogger ml = new MockLogger();
            Project p = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
            @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
	                <ItemGroup>
	                    <MyFile Include='a.cs; b.cs; c.cs'/>
	                </ItemGroup>
	                <Target Name='Build'
	                        Inputs=""@(MyFile->'%(NonExistentMetadata)')""
	                        Outputs='foo.exe'>
	                        <Message Text='Running Build target' Importance='High'/>
	                </Target>
	            </Project>"))));

            bool success = p.Build(new string[] { "Build" }, new ILogger[] { ml });

            Assert.True(success);

            // It should have actually skipped the "Build" target since there were no inputs.
            ml.AssertLogDoesntContain("Running Build target");
        }
 public RatingRepository(MockLogger logger, IMapper mapper, DatabaseContext context)
 {
     _logger  = logger;
     _mapper  = mapper;
     _context = context;
 }
 public CurrentUserControllerTests()
 {
     TimeService.UtcNow = new DateTime(2019, 2, 1, 12, 3, 0);
     _controller        = new CurrentUserController(Db, UserEventsService, MockLogger.Get <CurrentUserController>(), TimeService);
 }
        public void IllegalFileCharsInItemsOutOfTask()
        {
            MockLogger logger = new MockLogger();
            string projectFileContents = ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
 <PropertyGroup>
   <p>||illegal||</p>
 </PropertyGroup>
 <CreateItem Include='$(p)'>
   <Output TaskParameter='Include' ItemName='x' />
 </CreateItem>
 <Message Text='[@(x)]'/>
</Target>
</Project>");

            Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
            List<ILogger> loggers = new List<ILogger>();
            loggers.Add(logger);
            bool result = project.Build("t", loggers);

            Assert.AreEqual(true, result);
            logger.AssertLogContains("[||illegal||]");
        }
Exemple #22
0
 public void should_not_list_unpinned_packages()
 {
     MockLogger.Verify(l => l.Info("regular|1.2.0"), Times.Never);
 }
        public void ItShouldLogInformationWithCode(HttpStatusCode code)
        {
            var actual = Unit.Handle(_httpClient, code);

            MockLogger.Verify(x => x.Info(It.IsAny <string>()), Times.Once());
        }
 public void DiscoverTests_CrashingExecutable_CrashIsLogged()
 {
     RunExecutableAndCheckLogging(TestResources.AlwaysCrashingExe,
                                  () => MockLogger.Verify(l => l.LogError(It.Is <string>(s => s.Contains("Could not list test cases for executable"))),
                                                          Times.Once));
 }
 public void VerifyLoggerWithObjectWasCalled(Int32 timesCalled)
 {
     MockLogger.Verify(x => x.LogDebug(It.IsAny <string>(), It.IsAny <PreInstallValidationJob>()), Times.Exactly(timesCalled));
 }
 public override void BeforeEachSpec()
 {
     MockLogger.reset();
 }
 public void should_log_why_it_skips_auto_uninstaller()
 {
     MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - AutoUninstaller feature is not enabled."), Times.Once);
 }
 public override void BeforeEachSpec()
 {
     MockLogger.reset();
     files.Clear();
     directoryCreated.Clear();
 }
Exemple #29
0
        public void FailingTaskStillPublishesOutputs()
        {
            MockLogger l = new MockLogger();

            string resx = Path.Combine(Path.GetTempPath(), "FailingTaskStillPublishesOutputs.resx");

            try
            {
                File.WriteAllText(resx, @"
                    <root>
                      <resheader name=""resmimetype"">
                        <value>text/microsoft-resx</value>
                      </resheader>
                      <resheader name=""version"">
                        <value>2.0</value>
                      </resheader>
                      <resheader name=""reader"">
                        <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
                      </resheader>
                      <resheader name=""writer"">
                        <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
                      </resheader>
                      <data name=""a"">
                        <value>aa</value>
                      </data>
                      <data name=""b"">
                        <value>bb</value>
                      </data>
                    </root>");

                Project project = new Project(XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(@"
                    <Project DefaultTargets='Build' ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'> 
                        <Target Name='Build'>
                            
                            <GenerateResource
                                ExecuteAsTool='false'
                                Sources='" + resx + @"'
                                StronglyTypedLanguage='!@:|'>
                                    <Output TaskParameter='FilesWritten' ItemName='FilesWrittenItem'/>
                                    <Output TaskParameter='FilesWritten' PropertyName='FilesWrittenProperty'/>
                            </GenerateResource>
                                               
                            <OnError ExecuteTargets='ErrorTarget'/>
                        </Target>

                        <Target Name='ErrorTarget'>    
                            <Message Text='[@(fileswrittenitem)]'/>
                            <Message Text='[$(fileswrittenproperty)]'/>
                        </Target>
                    </Project>"))));

                ProjectInstance p = project.CreateProjectInstance();
                p.Build(new string[] { "Build" }, new ILogger[] { l });

                string resource = Path.ChangeExtension(resx, ".resources");

                Assert.Equal(1, l.ErrorCount); // "Expected one error because 'Build' failed."
                l.AssertLogContains("[" + resource + "]", "[" + resource + "]");

                // And outputs are visible at the project level
                Assert.Equal(resource, Helpers.MakeList(p.GetItems("FilesWrittenItem"))[0].EvaluatedInclude);
                Assert.Equal(resource, p.GetPropertyValue("FilesWrittenProperty"));

                p = project.CreateProjectInstance();

                // But are gone after resetting of course
                Assert.Empty(Helpers.MakeList(p.GetItems("FilesWrittenItem")));
                Assert.Equal(String.Empty, p.GetPropertyValue("FilesWrittenProperty"));
            }
            finally
            {
                File.Delete(resx);
            }
        }
 public void DiscoverTests_FailingExecutable_ExitCodeIsLogged()
 {
     RunExecutableAndCheckLogging(TestResources.AlwaysFailingExe,
                                  () => MockLogger.Verify(l => l.LogError(It.Is <string>(s => s.Contains("process execution failed with exit code 4711"))),
                                                          Times.Once));
 }
 public void should_log_why_it_skips_auto_uninstaller()
 {
     MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - The application appears to have been uninstalled already by other means."), Times.Once);
 }
Exemple #32
0
 public void InitializeTest()
 {
     _mockLogger = new MockLogger();
 }
Exemple #33
0
 public void should_log_a_message()
 {
     MockLogger.Verify(l => l.Info(It.IsAny <string>()), Times.Once);
 }
 internal void AssertHandler()
 {
     MockLogger.VerifyLogging(LogLevel.Information);
     MockpprenticeshipCompletedEventHandler.Verify(s => s.Handle(It.Is <ApprenticeshipCompletionDateUpdatedEvent>(c => c.ApprenticeshipId.Equals(ApprenticeshipCompletionDateUpdatedEvent.ApprenticeshipId))), Times.Once);
 }
 /// <summary>
 /// Executed after all tests are run.
 /// </summary>
 public void Dispose()
 {
     File.Delete("testProject.proj");
     _mockLogger = null;
     _host = null;
 }
Exemple #36
0
        public void TestDefiningProjectMetadata()
        {
            string projectA = Path.Combine(ObjectModelHelpers.TempProjectDir, "a.proj");
            string projectB = Path.Combine(ObjectModelHelpers.TempProjectDir, "b.proj");

            string includeFileA = Path.Combine(ObjectModelHelpers.TempProjectDir, "aaa4.cs");
            string includeFileB = Path.Combine(ObjectModelHelpers.TempProjectDir, "bbb4.cs");

            string contentsA =
                @"<?xml version=`1.0` encoding=`utf-8`?>
<Project ToolsVersion=`msbuilddefaulttoolsversion` DefaultTargets=`Validate` xmlns=`msbuildnamespace`>
  <ItemGroup>
    <A Include=`aaaa.cs` />
    <A2 Include=`aaa2.cs` />
    <A2 Include=`aaa3.cs`>
      <Foo>Bar</Foo>
    </A2>
  </ItemGroup>

  <Import Project=`b.proj` />

  <ItemGroup>
    <E Include=`@(C)` />
    <F Include=`@(C);@(C2)` />
    <G Include=`@(C->'%(Filename)')` />
    <H Include=`@(C2->WithMetadataValue('Foo', 'Bar'))` />
    <U Include=`*4.cs` />
  </ItemGroup>

  <Target Name=`AddFromMainProject`>
    <ItemGroup>
      <B Include=`bbbb.cs` />
      <I Include=`@(C)` />
      <J Include=`@(C);@(C2)` />
      <K Include=`@(C->'%(Filename)')` />
      <L Include=`@(C2->WithMetadataValue('Foo', 'Bar'))` />
      <V Include=`*4.cs` />
    </ItemGroup>
  </Target>

  <Target Name=`Validate` DependsOnTargets=`AddFromMainProject;AddFromImport`>
    <Warning Text=`A is wrong: EXPECTED: [a] ACTUAL: [%(A.DefiningProjectName)]` Condition=`'%(A.DefiningProjectName)' != 'a'` />
    <Warning Text=`B is wrong: EXPECTED: [a] ACTUAL: [%(B.DefiningProjectName)]` Condition=`'%(B.DefiningProjectName)' != 'a'` />
    <Warning Text=`C is wrong: EXPECTED: [b] ACTUAL: [%(C.DefiningProjectName)]` Condition=`'%(C.DefiningProjectName)' != 'b'` />
    <Warning Text=`D is wrong: EXPECTED: [b] ACTUAL: [%(D.DefiningProjectName)]` Condition=`'%(D.DefiningProjectName)' != 'b'` />
    <Warning Text=`E is wrong: EXPECTED: [a] ACTUAL: [%(E.DefiningProjectName)]` Condition=`'%(E.DefiningProjectName)' != 'a'` />
    <Warning Text=`F is wrong: EXPECTED: [a] ACTUAL: [%(F.DefiningProjectName)]` Condition=`'%(F.DefiningProjectName)' != 'a'` />
    <Warning Text=`G is wrong: EXPECTED: [a] ACTUAL: [%(G.DefiningProjectName)]` Condition=`'%(G.DefiningProjectName)' != 'a'` />
    <Warning Text=`H is wrong: EXPECTED: [a] ACTUAL: [%(H.DefiningProjectName)]` Condition=`'%(H.DefiningProjectName)' != 'a'` />
    <Warning Text=`I is wrong: EXPECTED: [a] ACTUAL: [%(I.DefiningProjectName)]` Condition=`'%(I.DefiningProjectName)' != 'a'` />
    <Warning Text=`J is wrong: EXPECTED: [a] ACTUAL: [%(J.DefiningProjectName)]` Condition=`'%(J.DefiningProjectName)' != 'a'` />
    <Warning Text=`K is wrong: EXPECTED: [a] ACTUAL: [%(K.DefiningProjectName)]` Condition=`'%(K.DefiningProjectName)' != 'a'` />
    <Warning Text=`L is wrong: EXPECTED: [a] ACTUAL: [%(L.DefiningProjectName)]` Condition=`'%(L.DefiningProjectName)' != 'a'` />
    <Warning Text=`M is wrong: EXPECTED: [b] ACTUAL: [%(M.DefiningProjectName)]` Condition=`'%(M.DefiningProjectName)' != 'b'` />
    <Warning Text=`N is wrong: EXPECTED: [b] ACTUAL: [%(N.DefiningProjectName)]` Condition=`'%(N.DefiningProjectName)' != 'b'` />
    <Warning Text=`O is wrong: EXPECTED: [b] ACTUAL: [%(O.DefiningProjectName)]` Condition=`'%(O.DefiningProjectName)' != 'b'` />
    <Warning Text=`P is wrong: EXPECTED: [b] ACTUAL: [%(P.DefiningProjectName)]` Condition=`'%(P.DefiningProjectName)' != 'b'` />
    <Warning Text=`Q is wrong: EXPECTED: [b] ACTUAL: [%(Q.DefiningProjectName)]` Condition=`'%(Q.DefiningProjectName)' != 'b'` />
    <Warning Text=`R is wrong: EXPECTED: [b] ACTUAL: [%(R.DefiningProjectName)]` Condition=`'%(R.DefiningProjectName)' != 'b'` />
    <Warning Text=`S is wrong: EXPECTED: [b] ACTUAL: [%(S.DefiningProjectName)]` Condition=`'%(S.DefiningProjectName)' != 'b'` />
    <Warning Text=`T is wrong: EXPECTED: [b] ACTUAL: [%(T.DefiningProjectName)]` Condition=`'%(T.DefiningProjectName)' != 'b'` />
    <Warning Text=`U is wrong: EXPECTED: [a] ACTUAL: [%(U.DefiningProjectName)]` Condition=`'%(U.DefiningProjectName)' != 'a'` />
    <Warning Text=`V is wrong: EXPECTED: [a] ACTUAL: [%(V.DefiningProjectName)]` Condition=`'%(V.DefiningProjectName)' != 'a'` />
    <Warning Text=`W is wrong: EXPECTED: [b] ACTUAL: [%(W.DefiningProjectName)]` Condition=`'%(W.DefiningProjectName)' != 'b'` />
    <Warning Text=`X is wrong: EXPECTED: [b] ACTUAL: [%(X.DefiningProjectName)]` Condition=`'%(X.DefiningProjectName)' != 'b'` />
  </Target>

</Project>";

            string contentsB =
                @"<?xml version=`1.0` encoding=`utf-8`?>
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
  <ItemGroup>
    <C Include=`cccc.cs` />
    <C2 Include=`ccc2.cs` />
    <C2 Include=`ccc3.cs`>
      <Foo>Bar</Foo>
    </C2>
    <M Include=`@(A)` />
    <N Include=`@(A);@(A2)` />
    <O Include=`@(A->'%(Filename)')` />
    <P Include=`@(A2->WithMetadataValue('Foo', 'Bar'))` />
    <W Include=`*4.cs` />
  </ItemGroup>


  <Target Name=`AddFromImport`>
    <ItemGroup>
      <D Include=`dddd.cs` />
      <Q Include=`@(A)` />
      <R Include=`@(A);@(A2)` />
      <S Include=`@(A->'%(Filename)')` />
      <T Include=`@(A2->WithMetadataValue('Foo', 'Bar'))` />
      <X Include=`*4.cs` />
    </ItemGroup>
  </Target>
</Project>";

            try
            {
                File.WriteAllText(projectA, ObjectModelHelpers.CleanupFileContents(contentsA));
                File.WriteAllText(projectB, ObjectModelHelpers.CleanupFileContents(contentsB));

                File.WriteAllText(includeFileA, "aaaaaaa");
                File.WriteAllText(includeFileB, "bbbbbbb");

                MockLogger logger = new MockLogger(_testOutput);
                ObjectModelHelpers.BuildTempProjectFileExpectSuccess("a.proj", logger);
                logger.AssertNoWarnings();
            }
            finally
            {
                if (File.Exists(projectA))
                {
                    File.Delete(projectA);
                }

                if (File.Exists(projectB))
                {
                    File.Delete(projectB);
                }

                if (File.Exists(includeFileA))
                {
                    File.Delete(includeFileA);
                }

                if (File.Exists(includeFileB))
                {
                    File.Delete(includeFileB);
                }
            }
        }
Exemple #37
0
 public void should_log_why_it_skips_auto_uninstaller()
 {
     MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - Installer type was not detected and no silent uninstall key exists."), Times.Once);
 }
 internal void VerifyCommitmentsApiModelExceptionExceptionLogged()
 {
     MockLogger.Verify(
         x => x.Log(LogLevel.Error, It.IsAny <EventId>(), It.IsAny <It.IsAnyType>(), It.IsAny <CommitmentsApiModelException>(),
                    It.IsAny <Func <object, Exception, string> >()), Times.AtLeastOnce());
 }
 public void VerifyLoggerWithoutObjectWasCalled(Int32 timesCalled)
 {
     MockLogger.Verify(x => x.LogDebug(It.IsAny <string>()), Times.Exactly(timesCalled));
 }
        public void DoNotCrashOnInvalidFormatExpression()
        {
            string content = @"
 <Project DefaultTargets=`t` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
   <UsingTask
     TaskName=`Crash`
     TaskFactory=`CodeTaskFactory`
     AssemblyFile=`$(MSBuildToolsPath)" + Path.DirectorySeparatorChar + @"Microsoft.Build.Tasks.Core.dll` >
     <Task>
       <Code Type=`Fragment` Language=`cs`>
         this.Log.LogError(`Correct: {0}`, `[goodone]`);
         this.Log.LogError(`This is a message logged from a task {1} blah blah [crashing].`, `[crasher]`);

            try
            {
                this.Log.LogError(`Correct: {0}`, 4224);
                this.Log.LogError(`Malformed: {1}`, 42); // Line 13
                throw new InvalidOperationException();
            }
            catch (Exception e)
            {
                this.Log.LogError(`Catching: {0}`, e.GetType().Name);
            }
            finally
            {
                this.Log.LogError(`Finally`);
            }

            try
            {
                this.Log.LogError(`Correct: {0}`, 4224);
                throw new InvalidOperationException();
            }
            catch (Exception e)
            {
                this.Log.LogError(`Catching: {0}`, e.GetType().Name);
                this.Log.LogError(`Malformed: {1}`, 42); // Line 19
            }
            finally
            {
                this.Log.LogError(`Finally`);
            }

            try
            {
                this.Log.LogError(`Correct: {0}`, 4224);
                throw new InvalidOperationException();
            }
            catch (Exception e)
            {
                this.Log.LogError(`Catching: {0}`, e.GetType().Name);
            }
            finally
            {
                this.Log.LogError(`Finally`);
                this.Log.LogError(`Malformed: {1}`, 42); // Line 24
            }

       </Code>
     </Task>
   </UsingTask>

        <Target Name=`t`>
             <Crash />
        </Target>
</Project>
                ";

            MockLogger log = Helpers.BuildProjectWithNewOMExpectSuccess(content);

            log.AssertLogContains("[goodone]");
            log.AssertLogContains("[crashing]");
        }
Exemple #41
0
 internal void AssertHandler()
 {
     MockLogger.VerifyLogging(LogLevel.Information);
     MockapprenticeshipUpdatedApprovedEventHandler.Verify(s => s.Handle(It.Is <ApprenticeshipStopDateChangedEvent>(c => c.ApprenticeshipId.Equals(ApprenticeshipStopDateChangedEvent.ApprenticeshipId))), Times.Once);
 }
        public void TasksCanAddRecursiveDirBuiltInMetadata()
        {
            MockLogger logger = new MockLogger();

            string projectFileContents = ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
 <CreateItem Include='$(programfiles)\reference assemblies\**\*.dll;'>
   <Output TaskParameter='Include' ItemName='x' />
 </CreateItem>
<Message Text='@(x)'/>
 <Message Text='[%(x.RecursiveDir)]'/>                    
</Target>
</Project>");

            Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
            List<ILogger> loggers = new List<ILogger>();
            loggers.Add(logger);
            bool result = project.Build("t", loggers);

            Assert.AreEqual(true, result);
            logger.AssertLogDoesntContain("[]");
            logger.AssertLogDoesntContain("MSB4118");
            logger.AssertLogDoesntContain("MSB3031");
        }
Exemple #43
0
        /// <summary>
        /// Set up
        /// </summary>
        public Scheduler_Tests()
        {
            // Since we're creating our own BuildManager, we need to make sure that the default 
            // one has properly relinquished the inproc node
            NodeProviderInProc nodeProviderInProc = ((IBuildComponentHost)BuildManager.DefaultBuildManager).GetComponent(BuildComponentType.InProcNodeProvider) as NodeProviderInProc;
            if (nodeProviderInProc != null)
            {
                nodeProviderInProc.Dispose();
            }

            _host = new MockHost();
            _scheduler = new Scheduler();
            _scheduler.InitializeComponent(_host);
            CreateConfiguration(99, "parent.proj");
            _defaultParentRequest = CreateBuildRequest(99, 99, new string[] { }, null);

            // Set up the scheduler with one node to start with.
            _scheduler.ReportNodesCreated(new NodeInfo[] { new NodeInfo(1, NodeProviderType.InProc) });
            _scheduler.ReportRequestBlocked(1, new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { _defaultParentRequest }));

            _logger = new MockLogger();
            _parameters = new BuildParameters();
            _parameters.Loggers = new ILogger[] { _logger };
            _parameters.ShutdownInProcNodeOnBuildFinish = true;
            _buildManager = new BuildManager();
        }
Exemple #44
0
 public void should_list_pinned_packages()
 {
     MockLogger.Verify(l => l.Info("pinned|1.1.0"), Times.Once);
 }
        public void OverridePropertiesInCreateProperty()
        {
            MockLogger logger = new MockLogger();
            string projectFileContents = ObjectModelHelpers.CleanupFileContents(
                @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                      <ItemGroup>
                         <EmbeddedResource Include='a.resx'>
                            <LogicalName>foo</LogicalName>
                         </EmbeddedResource>
                         <EmbeddedResource Include='b.resx'>
                            <LogicalName>bar</LogicalName>
                         </EmbeddedResource>
                         <EmbeddedResource Include='c.resx'>
                            <LogicalName>barz</LogicalName>
                         </EmbeddedResource>
                      </ItemGroup>
                      <Target Name='t'>
                         <CreateProperty Value=""@(EmbeddedResource->'/assemblyresource:%(Identity),%(LogicalName)', ' ')""
                                         Condition=""'%(LogicalName)' != '' "">
                             <Output TaskParameter=""Value"" PropertyName=""LinkSwitches""/>
                         </CreateProperty>
                         <Message Text='final:[$(LinkSwitches)]'/>                    
                      </Target>
                      </Project>");

            Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
            List<ILogger> loggers = new List<ILogger>();
            loggers.Add(logger);
            project.Build("t", loggers);

            logger.AssertLogContains(new string[] { "final:[/assemblyresource:c.resx,barz]" });
            logger.AssertLogContains(new string[] { ResourceUtilities.FormatResourceString("TaskStarted", "CreateProperty") });
            logger.AssertLogContains(new string[] { ResourceUtilities.FormatResourceString("PropertyOutputOverridden", "LinkSwitches", "/assemblyresource:a.resx,foo", "/assemblyresource:b.resx,bar") });
            logger.AssertLogContains(new string[] { ResourceUtilities.FormatResourceString("PropertyOutputOverridden", "LinkSwitches", "/assemblyresource:b.resx,bar", "/assemblyresource:c.resx,barz") });
        }
        public void TaskOutputBatching()
        {
            MockLogger logger = new MockLogger();
            string projectFileContents = ObjectModelHelpers.CleanupFileContents(@"
                <Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                    <ItemGroup>
                        <TaskParameterItem Include=""foo"">
                            <ParameterName>Value</ParameterName>
                            <ParameterName2>Include</ParameterName2>
                            <PropertyName>MetadataProperty</PropertyName>
                            <ItemType>MetadataItem</ItemType>
                        </TaskParameterItem>
                    </ItemGroup>
                    <Target Name='Build'>
                        <CreateProperty Value=""@(TaskParameterItem)"">
                            <Output TaskParameter=""Value"" PropertyName=""Property1""/>
                        </CreateProperty> 
                        <Message Text='Property1=[$(Property1)]' />

                        <CreateProperty Value=""@(TaskParameterItem)"">
                            <Output TaskParameter=""%(TaskParameterItem.ParameterName)"" PropertyName=""Property2""/>
                        </CreateProperty> 
                        <Message Text='Property2=[$(Property2)]' />

                        <CreateProperty Value=""@(TaskParameterItem)"">
                            <Output TaskParameter=""Value"" PropertyName=""%(TaskParameterItem.PropertyName)""/>
                        </CreateProperty> 
                        <Message Text='MetadataProperty=[$(MetadataProperty)]' />

                        <CreateItem Include=""@(TaskParameterItem)"">
                            <Output TaskParameter=""Include"" ItemName=""TestItem1""/>
                        </CreateItem>
                        <Message Text='TestItem1=[@(TestItem1)]' />

                        <CreateItem Include=""@(TaskParameterItem)"">
                            <Output TaskParameter=""%(TaskParameterItem.ParameterName2)"" ItemName=""TestItem2""/>
                        </CreateItem>
                        <Message Text='TestItem2=[@(TestItem2)]' />

                        <CreateItem Include=""@(TaskParameterItem)"">
                            <Output TaskParameter=""Include"" ItemName=""%(TaskParameterItem.ItemType)""/>
                        </CreateItem>
                        <Message Text='MetadataItem=[@(MetadataItem)]' />
                    </Target>
                </Project>");

            Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
            List<ILogger> loggers = new List<ILogger>();
            loggers.Add(logger);
            project.Build(loggers);

            logger.AssertLogContains("Property1=[foo]");
            logger.AssertLogContains("Property2=[foo]");
            logger.AssertLogContains("MetadataProperty=[foo]");
            logger.AssertLogContains("TestItem1=[foo]");
            logger.AssertLogContains("TestItem2=[foo]");
            logger.AssertLogContains("MetadataItem=[foo]");
        }
 public void should_log_why_it_skips_auto_uninstaller()
 {
     MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - Package contains a skip file ('" + skipFileName + "')."), Times.Once);
 }
 public void should_not_log_an_error()
 {
     MockLogger.Verify(l => l.Error(It.IsAny <string>()), Times.Never);
 }
Exemple #49
0
        public void VerifyRequestOrderingDoesNotAffectNodeCreationCountWithInProcAndAnyRequests()
        {
            // Since we're creating our own BuildManager, we need to make sure that the default 
            // one has properly relinquished the inproc node
            NodeProviderInProc nodeProviderInProc = ((IBuildComponentHost)BuildManager.DefaultBuildManager).GetComponent(BuildComponentType.InProcNodeProvider) as NodeProviderInProc;
            if (nodeProviderInProc != null)
            {
                nodeProviderInProc.Dispose();
            }

            _host = new MockHost();
            _host.BuildParameters.MaxNodeCount = 3;

            _scheduler = new Scheduler();
            _scheduler.InitializeComponent(_host);

            _logger = new MockLogger();
            _parameters = new BuildParameters();
            _parameters.Loggers = new ILogger[] { _logger };
            _parameters.ShutdownInProcNodeOnBuildFinish = true;
            _buildManager = new BuildManager();

            CreateConfiguration(99, "parent.proj");
            _defaultParentRequest = CreateBuildRequest(99, 99, new string[] { }, null);

            CreateConfiguration(1, "foo.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, NodeAffinity.Any, _defaultParentRequest);
            BuildRequest request2 = CreateBuildRequest(2, 1, new string[] { "bar" }, NodeAffinity.InProc, _defaultParentRequest);
            BuildRequest request3 = CreateBuildRequest(3, 1, new string[] { "bar" }, NodeAffinity.InProc, _defaultParentRequest);

            List<ScheduleResponse> response = new List<ScheduleResponse>(_scheduler.ReportRequestBlocked(1, new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { _defaultParentRequest, request1, request2, request3 })));
            Assert.Equal(1, response.Count);
            Assert.Equal(ScheduleActionType.CreateNode, response[0].Action);
            Assert.Equal(NodeAffinity.InProc, response[0].RequiredNodeType);
            Assert.Equal(1, response[0].NumberOfNodesToCreate);

            List<NodeInfo> nodeInfos = new List<NodeInfo>(new NodeInfo[] { new NodeInfo(1, NodeProviderType.InProc) });
            List<ScheduleResponse> moreResponses = new List<ScheduleResponse>(_scheduler.ReportNodesCreated(nodeInfos));

            Assert.Equal(2, moreResponses.Count);
            Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, moreResponses[0].Action);
            Assert.Equal(ScheduleActionType.CreateNode, moreResponses[1].Action);
            Assert.Equal(NodeAffinity.OutOfProc, moreResponses[1].RequiredNodeType);
            Assert.Equal(1, moreResponses[1].NumberOfNodesToCreate);
        }
 public void should_log_why_it_skips_auto_uninstaller()
 {
     MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - No package in package information."), Times.Once);
 }
        public void TasksNotDiscoveredWhenTaskConditionFalse()
        {
            MockLogger logger = new MockLogger();
            string projectFileContents = ObjectModelHelpers.CleanupFileContents(
                @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                      <Target Name='t'>
                         <NonExistantTask Condition=""'1'=='2'""/>
                         <Message Text='Made it'/>                    
                      </Target>
                      </Project>");

            Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
            List<ILogger> loggers = new List<ILogger>();
            loggers.Add(logger);
            project.Build("t", loggers);

            logger.AssertLogContains("Made it");
        }
 public void should_log_why_it_skips_auto_uninstaller()
 {
     MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - No registry keys in snapshot."), Times.Once);
 }
        public void OverridePropertiesInInferredCreateProperty()
        {
            string[] files = null;
            try
            {
                files = ObjectModelHelpers.GetTempFiles(2, new DateTime(2005, 1, 1));

                MockLogger logger = new MockLogger();
                string projectFileContents = ObjectModelHelpers.CleanupFileContents(
                    @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                      <ItemGroup>
                        <i Include='" + files[0] + "'><output>" + files[1] + @"</output></i>
                      </ItemGroup> 
                      <ItemGroup>
                         <EmbeddedResource Include='a.resx'>
                        <LogicalName>foo</LogicalName>
                          </EmbeddedResource>
                            <EmbeddedResource Include='b.resx'>
                            <LogicalName>bar</LogicalName>
                        </EmbeddedResource>
                            <EmbeddedResource Include='c.resx'>
                            <LogicalName>barz</LogicalName>
                        </EmbeddedResource>
                        </ItemGroup>
                      <Target Name='t2' DependsOnTargets='t'>
                        <Message Text='final:[$(LinkSwitches)]'/>   
                      </Target>
                      <Target Name='t' Inputs='%(i.Identity)' Outputs='%(i.Output)'>
                        <Message Text='start:[Hello]'/>
                        <CreateProperty Value=""@(EmbeddedResource->'/assemblyresource:%(Identity),%(LogicalName)', ' ')""
                                         Condition=""'%(LogicalName)' != '' "">
                             <Output TaskParameter=""Value"" PropertyName=""LinkSwitches""/>
                        </CreateProperty>
                        <Message Text='end:[hello]'/>                    
                    </Target>
                    </Project>");

                Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
                List<ILogger> loggers = new List<ILogger>();
                loggers.Add(logger);
                project.Build("t2", loggers);

                // We should only see messages from the second target, as the first is only inferred
                logger.AssertLogDoesntContain("start:");
                logger.AssertLogDoesntContain("end:");

                logger.AssertLogContains(new string[] { "final:[/assemblyresource:c.resx,barz]" });
                logger.AssertLogDoesntContain(ResourceUtilities.FormatResourceString("TaskStarted", "CreateProperty"));
                logger.AssertLogContains(new string[] { ResourceUtilities.FormatResourceString("PropertyOutputOverridden", "LinkSwitches", "/assemblyresource:a.resx,foo", "/assemblyresource:b.resx,bar") });
                logger.AssertLogContains(new string[] { ResourceUtilities.FormatResourceString("PropertyOutputOverridden", "LinkSwitches", "/assemblyresource:b.resx,bar", "/assemblyresource:c.resx,barz") });
            }
            finally
            {
                ObjectModelHelpers.DeleteTempFiles(files);
            }
        }
 public void should_log_why_it_skips_auto_uninstaller()
 {
     MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - '{0}' does not have an uninstall string.".format_with(expectedDisplayName)), Times.Once);
 }
        public void MSBuildLastTaskResult()
        {
            string projectFileContents = ObjectModelHelpers.CleanupFileContents(@"
<Project DefaultTargets='t2' ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
    <Target Name='t'>
        <Message Text='[start:$(MSBuildLastTaskResult)]'/> <!-- Should be blank -->
        <Warning Text='warning'/>
        <Message Text='[0:$(MSBuildLastTaskResult)]'/> <!-- Should be true, only a warning-->
        <!-- task's Execute returns false -->
        <Copy SourceFiles='|' DestinationFolder='c:\' ContinueOnError='true' />
        <PropertyGroup>
           <p>$(MSBuildLastTaskResult)</p>
        </PropertyGroup>                 
        <Message Text='[1:$(MSBuildLastTaskResult)]'/> <!-- Should be false: propertygroup did not reset it -->   
        <Message Text='[p:$(p)]'/> <!-- Should be false as stored earlier -->   
        <Message Text='[2:$(MSBuildLastTaskResult)]'/> <!-- Message succeeded, should now be true -->
    </Target>
    <Target Name='t2' DependsOnTargets='t'>
        <Message Text='[3:$(MSBuildLastTaskResult)]'/> <!-- Should still have true -->
        <!-- check Error task as well -->
        <Error Text='error' ContinueOnError='true' />
        <Message Text='[4:$(MSBuildLastTaskResult)]'/> <!-- Should be false -->
        <!-- trigger OnError target, ContinueOnError is false -->
        <Error Text='error2'/>
        <OnError ExecuteTargets='t3'/>
    </Target>
    <Target Name='t3' >
        <Message Text='[5:$(MSBuildLastTaskResult)]'/> <!-- Should be false -->
    </Target>
</Project>");

            Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
            List<ILogger> loggers = new List<ILogger>();
            MockLogger logger = new MockLogger();
            loggers.Add(logger);
            project.Build("t2", loggers);

            logger.AssertLogContains("[start:]");
            logger.AssertLogContains("[0:true]");
            logger.AssertLogContains("[1:false]");
            logger.AssertLogContains("[p:false]");
            logger.AssertLogContains("[2:true]");
            logger.AssertLogContains("[3:true]");
            logger.AssertLogContains("[4:false]");
            logger.AssertLogContains("[4:false]");
        }
 public void should_log_why_it_skips_auto_uninstaller()
 {
     MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - '{0}' appears to have been uninstalled already by other means.".format_with(expectedDisplayName)), Times.Once);
 }
        public void OtherBuiltInMetadataErrors2()
        {
            MockLogger logger = new MockLogger();
            string projectFileContents = ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
<Target Name='t'>
 <CreateItem Include='Foo' AdditionalMetadata='Extension=1'/>
</Target>
</Project>");

            Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
            List<ILogger> loggers = new List<ILogger>();
            loggers.Add(logger);
            bool result = project.Build("t", loggers);

            Assert.AreEqual(false, result);
            logger.AssertLogContains("MSB3031");
        }
 public void should_log_why_it_skips_auto_uninstaller()
 {
     MockLogger.Verify(l => l.Info(" Skipping auto uninstaller - The uninstaller file no longer exists. \"" + expectedUninstallString + "\""), Times.Once);
 }
        /// <summary>
        /// Executes an STA task test.
        /// </summary>
        private void TestSTATask(bool requireSTA, bool failTask, bool throwException)
        {
            MockLogger logger = new MockLogger();
            logger.AllowTaskCrashes = throwException;

            string taskAssemblyName = null;
            Project project = CreateSTATestProject(requireSTA, failTask, throwException, out taskAssemblyName);

            List<ILogger> loggers = new List<ILogger>();
            loggers.Add(logger);

            BuildParameters parameters = new BuildParameters();
            parameters.Loggers = new ILogger[] { logger };
            BuildResult result = BuildManager.DefaultBuildManager.Build(parameters, new BuildRequestData(project.CreateProjectInstance(), new string[] { "Foo" }));
            if (requireSTA)
            {
                logger.AssertLogContains("STA");
            }
            else
            {
                logger.AssertLogContains("MTA");
            }

            if (throwException)
            {
                logger.AssertLogContains("EXCEPTION");
                Assert.AreEqual(BuildResultCode.Failure, result.OverallResult);
                return;
            }
            else
            {
                logger.AssertLogDoesntContain("EXCEPTION");
            }

            if (failTask)
            {
                logger.AssertLogContains("FAIL");
                Assert.AreEqual(BuildResultCode.Failure, result.OverallResult);
            }
            else
            {
                logger.AssertLogDoesntContain("FAIL");
            }

            if (!throwException && !failTask)
            {
                Assert.AreEqual(BuildResultCode.Success, result.OverallResult);
            }
        }
Exemple #60
0
 internal MockCosmosState(MockLogger logger)
 {
     this.Databases = new Databases();
     this.Logger    = logger;
 }