public void ApplyDesignTimeChanges_WithExistingEvaluationChanges_CanAddItem(string currentFiles, string filesToAdd, string expected)
        {
            string[] expectedFiles = expected.Split(';');

            var handler = CreateInstanceWithEvaluationItems(@"C:\Project\Project.csproj", currentFiles);

            var difference = IProjectChangeDiffFactory.WithAddedItems(filesToAdd);

            ApplyDesignTimeChanges(handler, 1, difference);

            Assert.Equal(handler.Files.OrderBy(f => f), expectedFiles.OrderBy(f => f));
        }
        public void ApplyEvaluationChanges_WithExistingEvaluationChanges_CanRemoveItem(string currentFiles, string filesToRemove, string expected)
        {
            string[] expectedFiles = expected.Length == 0 ? Array.Empty <string>() : expected.Split(';');

            var handler = CreateInstanceWithEvaluationItems(@"C:\Project\Project.csproj", currentFiles);

            var difference = IProjectChangeDiffFactory.WithRemovedItems(filesToRemove);

            ApplyEvaluationChanges(handler, 2, difference);

            Assert.Equal(expectedFiles.OrderBy(f => f), handler.Files.OrderBy(f => f));
        }
        public void ApplyDesignTimeChanges_NullAsLogger_ThrowsArgumentNull()
        {
            var handler = CreateInstance();

            var version    = 1;
            var difference = IProjectChangeDiffFactory.Create();

            Assert.Throws <ArgumentNullException>(() =>
            {
                handler.ApplyDesignTimeChanges(version, difference, true, (IProjectLogger)null);
            });
        }
Exemplo n.º 4
0
        public void ApplyDesignTimeChanges_NullAsVersion_ThrowsArgumentNull()
        {
            var handler = CreateInstance();

            var difference = IProjectChangeDiffFactory.Create();
            var logger     = IProjectLoggerFactory.Create();

            Assert.Throws <ArgumentNullException>(() =>
            {
                handler.ApplyDesignTimeChanges((IComparable)null, difference, true, logger);
            });
        }
        public void ApplyProjectBuild_NullAsVersion_ThrowsArgumentNull()
        {
            var handler = CreateInstance();

            var difference = IProjectChangeDiffFactory.Create();
            var logger     = IProjectLoggerFactory.Create();

            Assert.Throws <ArgumentNullException>(() =>
            {
                handler.ApplyProjectBuild(null !, difference, true, logger);
            });
        }
        public void ApplyProjectEvaluation_WithExistingDesignTimeChanges_CanRenameItem(string currentFiles, string originalNames, string newNames, string expected)
        {
            string[] expectedFiles = expected.Length == 0 ? Array.Empty <string>() : expected.Split(';');

            var handler = CreateInstanceWithDesignTimeItems(@"C:\Project\Project.csproj", currentFiles);

            var difference = IProjectChangeDiffFactory.WithRenamedItems(originalNames, newNames);

            ApplyProjectEvaluation(handler, 2, difference);

            Assert.Equal(expectedFiles.OrderBy(f => f), handler.FileNames.OrderBy(f => f));
        }
        public void ApplyProjectEvaluation_NullAsLogger_ThrowsArgumentNull()
        {
            var handler = CreateInstance();

            var version    = 1;
            var difference = IProjectChangeDiffFactory.Create();
            var metadata   = ImmutableDictionary <string, IImmutableDictionary <string, string> > .Empty;

            Assert.Throws <ArgumentNullException>(() =>
            {
                handler.ApplyProjectEvaluation(version, difference, metadata, true, (IProjectLogger)null);
            });
        }
        public void AddEvaluationChanges_CanAddItemWithMetadata()
        {
            var handler = CreateInstance(@"C:\Project\Project.csproj");

            var difference = IProjectChangeDiffFactory.WithAddedItems("A.cs");
            var metadata   = MetadataFactory.Create("A.cs", ("Name", "Value"));

            ApplyProjectEvaluation(handler, 1, difference, metadata);

            var result = handler.Files[@"C:\Project\A.cs"];

            Assert.Equal("Value", result["Name"]);
        }
Exemplo n.º 9
0
        public void ApplyEvaluationChanges_NullAsMetadata_ThrowsArgumentNull()
        {
            var handler = CreateInstance();

            var version    = 1;
            var difference = IProjectChangeDiffFactory.Create();
            var logger     = IProjectLoggerFactory.Create();

            Assert.Throws <ArgumentNullException>(() =>
            {
                handler.ApplyEvaluationChanges(version, difference, (ImmutableDictionary <string, IImmutableDictionary <string, string> >)null, true, logger);
            });
        }
Exemplo n.º 10
0
        public void ApplyEvaluationChanges_NullAsVersion_ThrowsArgumentNull()
        {
            var handler = CreateInstance();

            var difference = IProjectChangeDiffFactory.Create();
            var metadata   = ImmutableDictionary <string, IImmutableDictionary <string, string> > .Empty;
            var logger     = IProjectLoggerFactory.Create();

            Assert.Throws <ArgumentNullException>(() =>
            {
                handler.ApplyEvaluationChanges((IComparable)null, difference, metadata, true, logger);
            });
        }
        public void ApplyProjectEvaluation_NullAsMetadata_ThrowsArgumentNull()
        {
            var handler = CreateInstance();

            var version    = 1;
            var difference = IProjectChangeDiffFactory.Create();
            var logger     = IProjectLoggerFactory.Create();

            Assert.Throws <ArgumentNullException>(() =>
            {
                handler.ApplyProjectEvaluation(version, difference, null !, true, logger);
            });
        }
Exemplo n.º 12
0
        public void ApplyProjectEvaluation_NullAsVersion_ThrowsArgumentNull()
        {
            var handler = CreateInstance();

            var difference = IProjectChangeDiffFactory.Create();
            var metadata   = ImmutableDictionary <string, IImmutableDictionary <string, string> > .Empty;
            var logger     = IProjectDiagnosticOutputServiceFactory.Create();

            Assert.Throws <ArgumentNullException>(() =>
            {
                handler.ApplyProjectEvaluation(null !, difference, metadata, metadata, true, logger);
            });
        }
        public void ApplyProjectEvaluationChanges_WithExistingEvaluationChanges_CanAddChangeMetadata()
        {
            var file    = "A.cs";
            var handler = CreateInstanceWithEvaluationItems(@"C:\Project\Project.csproj", file);

            var difference = IProjectChangeDiffFactory.WithChangedItems(file);
            var metadata   = MetadataFactory.Create(file, ("Name", "Value"));

            ApplyProjectEvaluation(handler, 2, difference, metadata);

            var result = handler.Files[@"C:\Project\A.cs"];

            Assert.Equal("Value", result["Name"]);
        }
Exemplo n.º 14
0
        public void AddEvaluationChanges_ItemsWithExclusionMetadataAreIgnored()
        {
            var handler = CreateInstance(@"C:\Project\Project.csproj");

            var difference = IProjectChangeDiffFactory.WithAddedItems("A.cs;B.cs;C.cs");
            var metadata   = MetadataFactory.Create("A.cs", ("ExcludeFromCurrentConfiguration", "true"))
                             .Add("B.cs", ("ExcludeFromCurrentConfiguration", "false"));


            ApplyProjectEvaluation(handler, 1, difference, metadata);

            string[] expectedFiles = new[] { @"C:\Project\B.cs", @"C:\Project\C.cs" };
            Assert.Equal(expectedFiles.OrderBy(f => f), handler.FileNames.OrderBy(f => f));
        }
        public void ApplyProjectBuild_WhenOlderEvaluationChangesWithRemovedConflict_DesignTimeWinsOut()
        {
            var handler = CreateInstance(@"C:\Project\Project.csproj");

            int evaluationVersion = 0;

            // Setup the "current state"
            ApplyProjectEvaluation(handler, evaluationVersion, IProjectChangeDiffFactory.WithRemovedItems("Source.cs"));

            int designTimeVersion = 1;

            ApplyProjectBuild(handler, designTimeVersion, IProjectChangeDiffFactory.WithAddedItems("Source.cs"));

            Assert.Single(handler.FileNames, @"C:\Project\Source.cs");
        }
Exemplo n.º 16
0
        public void ApplyDesignTimeChanges_WhenNewerEvaluationChangesWithRemovedConflict_EvaluationWinsOut()
        {
            var handler = CreateInstance(@"C:\Project\Project.cs");

            int evaluationVersion = 1;

            // Setup the "current state"
            ApplyEvaluationChanges(handler, evaluationVersion, IProjectChangeDiffFactory.WithRemovedItems("Source.cs"));

            int designTimeVersion = 0;

            ApplyDesignTimeChanges(handler, designTimeVersion, IProjectChangeDiffFactory.WithAddedItems("Source.cs"));

            Assert.Empty(handler.Files);
        }