public void CompilationArgumentsCacheDoesNotReturnReloadedProjectWithRemovedCompilationConstantsAsProjectWithChangedConstantsMoreThenOnceIfAlreadyReported() { var mockArgumentsProvider = new Mock <ICompilationArgumentsProvider>(); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 1 }, { "other", 14 } }); var argumentsProvider = mockArgumentsProvider.Object; var argumentsCache = new CompilationArgumentsCache(argumentsProvider); argumentsCache.ReloadCompilationArguments(new[] { "test" }); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 1 } }); argumentsCache.ReloadCompilationArguments(new[] { "test" }); var projectsWithChangedConstants = argumentsCache.ProjectWhoseCompilationArgumentsChanged(); var expectedCount = 1; var actualCount = projectsWithChangedConstants.Count; Assert.AreEqual(expectedCount, actualCount); Assert.IsTrue(projectsWithChangedConstants.Contains("test")); }
public void CompilationArgumentsCacheReturnsReloadedProjectWithRemovedCompilationConstantsAsProjectWithChangedConstants() { var mockArgumentsProvider = new Mock <ICompilationArgumentsProvider>(); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 1 }, { "other", 14 } }); var argumentsProvider = mockArgumentsProvider.Object; var argumentsCache = new CompilationArgumentsCache(argumentsProvider); argumentsCache.ReloadCompilationArguments(new[] { "test" }); argumentsCache.ClearProjectWhoseCompilationArgumentsChanged(); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 1 } }); argumentsCache.ReloadCompilationArguments(new[] { "test" }); var projectsWithChangedConstants = argumentsCache.ProjectWhoseCompilationArgumentsChanged(); var expected = "test"; var actual = projectsWithChangedConstants.Single(); Assert.AreEqual(expected, actual); }
public void CompilationArgumentsCacheUpdatesCachedUserConstantsOnReload() { var mockArgumentsProvider = new Mock <ICompilationArgumentsProvider>(); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 1 } }); var argumentsProvider = mockArgumentsProvider.Object; var argumentsCache = new CompilationArgumentsCache(argumentsProvider); argumentsCache.ReloadCompilationArguments(new[] { "test" }); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 2 } }); argumentsCache.ReloadCompilationArguments(new[] { "test" }); var userCompilationConstants = argumentsCache.UserDefinedCompilationArguments("test"); var expected = 2; var actual = userCompilationConstants["constant"]; Assert.AreEqual(expected, actual); }
public void CompilationArgumentsCacheDoesNotReturnReloadedProjectWithoutChangeOfCompilationConstantsAsProjectWithChangedConstants() { var mockArgumentsProvider = new Mock <ICompilationArgumentsProvider>(); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 1 } }); var argumentsProvider = mockArgumentsProvider.Object; var argumentsCache = new CompilationArgumentsCache(argumentsProvider); argumentsCache.ReloadCompilationArguments(new[] { "test" }); argumentsCache.ClearProjectWhoseCompilationArgumentsChanged(); argumentsCache.ReloadCompilationArguments(new[] { "test" }); var projectsWithChangedConstants = argumentsCache.ProjectWhoseCompilationArgumentsChanged(); Assert.IsTrue(projectsWithChangedConstants.Count == 0); }
public void CompilationArgumentsCacheDoesNotRemoveProjectsWithChangedConstantsOnReloadFromChangedCollection() { var mockArgumentsProvider = new Mock <ICompilationArgumentsProvider>(); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 1 } }); var argumentsProvider = mockArgumentsProvider.Object; var argumentsCache = new CompilationArgumentsCache(argumentsProvider); argumentsCache.ReloadCompilationArguments(new[] { "test" }); argumentsCache.ReloadCompilationArguments(new[] { "notTest" }); var projectsWithChangedConstants = argumentsCache.ProjectWhoseCompilationArgumentsChanged(); var expectedCount = 2; var actualCount = projectsWithChangedConstants.Count; Assert.AreEqual(expectedCount, actualCount); Assert.IsTrue(projectsWithChangedConstants.Contains("test")); }
public void CompilationArgumentsCacheReturnsNoUserConstantsForNotLoadedProject() { var mockArgumentsProvider = new Mock <ICompilationArgumentsProvider>(); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 1 } }); var argumentsProvider = mockArgumentsProvider.Object; var argumentsCache = new CompilationArgumentsCache(argumentsProvider); argumentsCache.ReloadCompilationArguments(new[] { "test" }); var userCompilationConstants = argumentsCache.UserDefinedCompilationArguments("notTest"); Assert.IsTrue(userCompilationConstants.Count == 0); }
public void CompilationArgumentsCacheReturnsUserConstantsAfterLoadOfTheProjectAndRemovalOfAnother() { var mockArgumentsProvider = new Mock <ICompilationArgumentsProvider>(); mockArgumentsProvider.Setup(m => m.UserDefinedCompilationArguments(It.IsAny <string>())) .Returns(() => new Dictionary <string, short> { { "constant", 1 } }); var argumentsProvider = mockArgumentsProvider.Object; var argumentsCache = new CompilationArgumentsCache(argumentsProvider); argumentsCache.ReloadCompilationArguments(new[] { "test", "notTest" }); argumentsCache.RemoveCompilationArgumentsFromCache(new[] { "notTest" }); var userCompilationConstants = argumentsCache.UserDefinedCompilationArguments("test"); var expected = 1; var actual = userCompilationConstants["constant"]; Assert.AreEqual(expected, actual); }