Exemplo n.º 1
0
        public async Task Process_AddSharedDesignTimeInput_DirtiesAllPEsWithoutCompiling()
        {
            // Initial state is two design time inputs
            using (var mgr = new TestTempPEBuildManager())
            {
                await mgr.SetInputs(new[] {
                    "Resources1.Designer.cs",
                    "Resources2.Designer.cs"
                }, null);

                // Apply our update
                var update = IProjectSubscriptionUpdateFactory.FromJson(@"{
    ""ProjectChanges"": {
        ""Compile"": {
            ""Difference"": { 
                ""AddedItems"": [
                                    ""Settings.Designer.cs""
                                 ]
            },
            ""After"": {
                ""Items"": {
                    ""Settings.Designer.cs"": {
                        ""DesignTimeSharedInput"": true
                    }
                }
            }
        }
    }
}");
                var result = await mgr.TestProcessAsync(update);

                Assert.Equal(2, result.Inputs.Count);
                Assert.Contains("Resources1.Designer.cs", result.Inputs);
                Assert.Contains("Resources2.Designer.cs", result.Inputs);
                Assert.Single(result.SharedInputs);
                Assert.Equal("Settings.Designer.cs", result.SharedInputs.First());
                Assert.Equal(2, mgr.DirtyItems.Count);
                Assert.Contains("Resources1.Designer.cs", mgr.DirtyItems);
                Assert.Contains("Resources2.Designer.cs", mgr.DirtyItems);
                Assert.Empty(mgr.DeletedItems);
                Assert.Empty(mgr.CompiledItems);
            }
        }
Exemplo n.º 2
0
        public void CompilationNeeded_OldOutput_NeedsRecompile()
        {
            var fileSystem = new IFileSystemMock();

            fileSystem.AddFile("Resource1.Designer.cs", new DateTime(2018, 6, 1));
            fileSystem.AddFile("Resource1.Designer.cs.dll", new DateTime(2018, 1, 1));

            using (var mgr = new TestTempPEBuildManager(fileSystem))
            {
                var files = new HashSet <string>
                {
                    "Resource1.Designer.cs"
                };

                bool result = mgr.CompilationNeeded(files, "Resource1.Designer.cs.dll");

                Assert.True(result);
            }
        }
        public async Task Process_OneDesignTimeInputAndOneShared_ReturnsOneInputEach()
        {
            // Initial state is an empty object
            using var mgr = new TestTempPEBuildManager();
            // Apply our update
            var update = IProjectSubscriptionUpdateFactory.FromJson(@"{
    ""ProjectChanges"": {
        ""Compile"": {
            ""Difference"": { 
                ""AddedItems"": [
                    ""Form1.cs"",
                    ""Resources1.Designer.cs"",
                    ""Settings.Designer.cs""
                ]
            },
            ""After"": {
                ""Items"": {
                    ""Form1.cs"": {
                    },
                    ""Resources1.Designer.cs"": {
                        ""DesignTime"": true
                    },
                    ""Settings.Designer.cs"": {
                        ""DesignTimeSharedInput"": true
                    }
                }
            }
        }
    }
}");
            var result = await mgr.TestProcessAsync(update);

            // One file should have been added
            Assert.Single(result.Inputs);
            Assert.Equal("Resources1.Designer.cs", result.Inputs.First());
            Assert.Single(result.SharedInputs);
            Assert.Equal("Settings.Designer.cs", result.SharedInputs.First());
            Assert.Single(mgr.DirtyItems);
            Assert.Equal("Resources1.Designer.cs", mgr.DirtyItems.First());
            Assert.Empty(mgr.DeletedItems);
            Assert.Single(mgr.CompiledItems);
            Assert.Contains("TempPE\\Resources1.Designer.cs.dll", mgr.CompiledItems);
        }
        public async Task Process_NonInputPropertyChangedOnSharedItem_ReturnsOneInput()
        {
            // Initial state is a single design time input
            using var mgr = new TestTempPEBuildManager();
            await mgr.SetInputs(new[] { "Resources1.Designer.cs" }, new[] { "Settings.Designer.cs" });

            // Apply our update
            var update = IProjectSubscriptionUpdateFactory.FromJson(@"{
    ""ProjectChanges"": {
        ""Compile"": {
            ""Difference"": { 
                ""ChangedItems"": [
                    ""Settings.Designer.cs""
                ]
            },
            ""Before"": {
                ""Items"": {
                    ""Settings.Designer.cs"": {
                        ""DesignTimeSharedInput"": true
                    }
                }
            },
            ""After"": {
                ""Items"": {
                    ""Settings.Designer.cs"": {
                        ""DesignTimeSharedInput"": true
                    }
                }
            }
        }
    }
}");
            var result = await mgr.TestProcessAsync(update);

            // One file should have been added
            Assert.Single(result.Inputs);
            Assert.Equal("Resources1.Designer.cs", result.Inputs.First());
            Assert.Single(result.SharedInputs);
            Assert.Equal("Settings.Designer.cs", result.SharedInputs.First());
            Assert.Empty(mgr.DirtyItems);
            Assert.Empty(mgr.DeletedItems);
            Assert.Empty(mgr.CompiledItems);
        }
        public async Task Process_InitialProjectLoad_ShouldntCompile()
        {
            using var mgr = new TestTempPEBuildManager();
            // Apply our update
            var update = IProjectSubscriptionUpdateFactory.FromJson(@"{
    ""ProjectChanges"": {
        ""Compile"": {
            ""Difference"": { 
                ""AddedItems"": [
                                    ""Form1.cs"",
                                    ""Resources1.Designer.cs""
                                 ]
            },
            ""After"": {
                ""Items"": {
                    ""Form1.cs"": { },
                    ""Resources1.Designer.cs"": {
                        ""DesignTime"": true
                    }
                }
            }
        }
    }
}");

            var configUpdate = IProjectSubscriptionUpdateFactory.FromJson(@"{
   ""ProjectChanges"": {
        ""ConfigurationGeneral"": {
        }
    }
}");

            var result = await mgr.TestProcessAsync(update, configUpdate, null);

            // One file should have been added
            Assert.Single(result.Inputs);
            Assert.Equal("Resources1.Designer.cs", result.Inputs.First());
            Assert.Empty(result.SharedInputs);
            Assert.Single(mgr.DirtyItems);
            Assert.Equal("Resources1.Designer.cs", mgr.DirtyItems.First());
            Assert.Empty(mgr.DeletedItems);
            Assert.Empty(mgr.CompiledItems);
        }
Exemplo n.º 6
0
        public async Task Process_BothDesignTimeInputsToNormalOnly_WatchesOneFile()
        {
            using (var mgr = new TestTempPEBuildManager())
            {
                await mgr.SetInputs(new[] { "Settings.Designer.cs" }, new[] { "Settings.Designer.cs" });

                // Apply our update
                var update = IProjectSubscriptionUpdateFactory.FromJson(@"{
    ""ProjectChanges"": {
        ""Compile"": {
            ""Difference"": { 
                ""ChangedItems"": [ ""Settings.Designer.cs"" ]
            },
            ""Before"": {
                ""Items"": {
                    ""Settings.Designer.cs"": {
                        ""DesignTimeSharedInput"": true,
                        ""DesignTime"": true
                    }
                }
            },
            ""After"": {
                ""Items"": {
                    ""Settings.Designer.cs"": {
                        ""DesignTime"": true
                    }
                }
            }
        }
    }
}");
                var result = await mgr.TestProcessAsync(update);

                Assert.Single(result.Inputs);
                Assert.Equal("Settings.Designer.cs", result.Inputs.First());
                Assert.Empty(result.SharedInputs);
                Assert.Single(mgr.DirtyItems);
                Assert.Equal("Settings.Designer.cs", mgr.DirtyItems.First());
                Assert.Empty(mgr.DeletedItems);
                Assert.Empty(mgr.CompiledItems);
            }
        }
        public async Task Process_RootNamespaceChanged_DirtiesAllPEs()
        {
            // Initial state is a single design time input
            using var mgr = new TestTempPEBuildManager();
            await mgr.SetInputs(new[] { "Resources1.Designer.cs", "Resources2.Designer.cs" }, null);

            var compileUpdate = IProjectSubscriptionUpdateFactory.FromJson(@"{
   ""ProjectChanges"": {
        ""Compile"": { }
    }
}");

            var configUpdate = IProjectSubscriptionUpdateFactory.FromJson(@"{
   ""ProjectChanges"": {
        ""ConfigurationGeneral"": {
            ""Difference"": {
                ""ChangedProperties"": [ ""RootNamespace"" ]
            },
            ""After"": {
                ""Properties"": {
                    ""RootNamespace"": ""After_Namespace""
                }
            }
        }
    }
}");

            var result = await mgr.TestProcessAsync(compileUpdate, configUpdate);

            // One file should have been added
            Assert.Equal(2, result.Inputs.Count);
            Assert.Equal("Resources1.Designer.cs", result.Inputs.First());
            Assert.Equal("Resources2.Designer.cs", result.Inputs.Last());
            Assert.Empty(result.SharedInputs);
            Assert.Equal(2, mgr.DirtyItems.Count);
            Assert.Equal("Resources1.Designer.cs", mgr.DirtyItems.First());
            Assert.Equal("Resources2.Designer.cs", mgr.DirtyItems.Last());
            Assert.Empty(mgr.DeletedItems);
            Assert.Equal(2, mgr.CompiledItems.Count);
            Assert.Equal("TempPE\\Resources1.Designer.cs.dll", mgr.CompiledItems.First());
            Assert.Equal("TempPE\\Resources2.Designer.cs.dll", mgr.CompiledItems.Last());
        }
Exemplo n.º 8
0
        public async Task Process_RemoveDesignTimeInput_ReturnsCorrectInput()
        {
            // Initial state is two design time inputs
            using (var mgr = new TestTempPEBuildManager())
            {
                await mgr.SetInputs(new[] {
                    "Resources1.Designer.cs",
                    "Resources2.Designer.cs"
                }, null);

                // Apply our update
                var update = IProjectSubscriptionUpdateFactory.FromJson(@"{
    ""ProjectChanges"": {
        ""Compile"": {
            ""Difference"": { 
                ""RemovedItems"": [
                    ""Resources2.Designer.cs""
                ]
            },
            ""Before"": {
                ""Items"": {
                    ""Resources2.Designer.cs"": {
                        ""DesignTime"": true
                    }
                }
            }
        }
    }
}");
                var result = await mgr.TestProcessAsync(update);

                // One file should have been removed
                Assert.Single(result.Inputs);
                Assert.Equal("Resources1.Designer.cs", result.Inputs.First());
                Assert.Empty(result.SharedInputs);
                Assert.Empty(mgr.DirtyItems);
                Assert.Single(mgr.DeletedItems);
                Assert.Equal("Resources2.Designer.cs", mgr.DeletedItems.First());
                Assert.Empty(mgr.CompiledItems);
            }
        }
Exemplo n.º 9
0
        public async Task Process_NonInputPropertyChangedOnNonItem_ReturnsEmptyCollections()
        {
            // Initial state is an empty object
            using (var mgr = new TestTempPEBuildManager())
            {
                // Apply our update
                var update = IProjectSubscriptionUpdateFactory.FromJson(@"{
    ""ProjectChanges"": {
        ""Compile"": {
            ""Difference"": { 
                ""ChangedItems"": [
                    ""Form1.Designer.cs""
                ]
            },
            ""Before"": {
                ""Items"": {
                    ""Form1.Designer.cs"": {
                    }
                }
            },
            ""After"": {
                ""Items"": {
                    ""Form1.Designer.cs"": {
                    }
                }
            }
        }
    }
}");
                var result = await mgr.TestProcessAsync(update);

                // Nothing should have been added
                Assert.Empty(result.Inputs);
                Assert.Empty(result.SharedInputs);
                Assert.Empty(mgr.DirtyItems);
                Assert.Empty(mgr.DeletedItems);
                Assert.Empty(mgr.CompiledItems);
            }
        }
        public async Task Process_AddDesignTimeInput_ReturnsCorrectInputs()
        {
            // Initial state is a single design time input
            using var mgr = new TestTempPEBuildManager();
            await mgr.SetInputs(new[] { "Resources1.Designer.cs" }, null);

            // Apply our update
            var update = IProjectSubscriptionUpdateFactory.FromJson(@"{
    ""ProjectChanges"": {
        ""Compile"": {
            ""Difference"": { 
                ""AddedItems"": [
                    ""Resources2.Designer.cs""
                ]
            },
            ""After"": {
                ""Items"": {
                    ""Resources2.Designer.cs"": {
                        ""DesignTime"": true
                    }
                }
            }
        }
    }
}");
            var result = await mgr.TestProcessAsync(update);

            // Should be two design time files now
            Assert.Equal(2, result.Inputs.Count);
            Assert.Contains("Resources1.Designer.cs", result.Inputs);
            Assert.Contains("Resources2.Designer.cs", result.Inputs);
            Assert.Empty(result.SharedInputs);
            Assert.Single(mgr.DirtyItems);
            Assert.Equal("Resources2.Designer.cs", mgr.DirtyItems.First());
            Assert.Empty(mgr.DeletedItems);
            Assert.Single(mgr.CompiledItems);
            Assert.Contains("TempPE\\Resources2.Designer.cs.dll", mgr.CompiledItems);
        }
Exemplo n.º 11
0
 internal TestBuildManager(TestTempPEBuildManager mgr)
     : base(IProjectThreadingServiceFactory.Create(), IUnconfiguredProjectCommonServicesFactory.Create(UnconfiguredProjectFactory.Create()))
 {
     _mgr = mgr;
 }