public void DotNetCoreAlias_AddProject_Default_NoTestFilters()
        {
            var context    = this.GetMoqContext(new Dictionary <string, bool>(), new Dictionary <string, string>());
            var defaultSln = SolutionFixture.GetDefaultSolution(context.FileSystem);

            context.AddDotNetCoreProject(defaultSln.SlnFile.Path.FullPath);

            var helperSetting = SingletonFactory.GetHelperSettings();

            Assert.IsNotNull(helperSetting);

            helperSetting.DotNetCoreSettings.TestSettings.TestProjectNameFilters.Clear();
            var projects = helperSetting.DotNetCoreSettings.Projects.ToArray();

            Assert.AreEqual(1, projects.Length);
            Assert.IsTrue(projects.Any(t => t.ProjectAlias == "CakeHelpers"));

            var slnProj = projects.FirstOrDefault();

            Assert.IsNotNull(slnProj);
            Assert.AreEqual("CakeHelpers", slnProj.ProjectAlias);
            slnProj.ProjectAlias = "Test";
            Assert.AreEqual("Test", slnProj.ProjectAlias);
            Assert.IsTrue(string.IsNullOrWhiteSpace(slnProj.Configuration));
            Assert.IsTrue(string.IsNullOrWhiteSpace(slnProj.Framework));
            Assert.IsTrue(string.IsNullOrWhiteSpace(slnProj.Platform));
            Assert.AreEqual(2, slnProj.AllProjects.Count());
            Assert.AreEqual(2, slnProj.SrcProjects.Count());
            Assert.AreEqual(0, slnProj.TestProjects.Count());
        }
Ejemplo n.º 2
0
        public static SolutionFixture GetDefaultSolution(IFileSystem fs)
        {
            var slnFilePath = Properties.Resources.DefaultSlnFileLocation;
            var sln         = new SolutionFixture(slnFilePath, fs);

            sln.SetContents(Properties.Resources.DefaultSlnContent);
            sln.AddProject(Properties.Resources.DefaultProject1Location, Properties.Resources.DefaultProject1Content);
            sln.AddProject(Properties.Resources.DefaultProject2Location, Properties.Resources.DefaultProject2Content);
            sln.FakeFs.CreateDirectory("./BuildTemp");

            return(sln);
        }
Ejemplo n.º 3
0
        public void DotNetCoreHelper_TempFolders_Success()
        {
            var context    = this.GetMoqContext(new Dictionary <string, bool>(), new Dictionary <string, string>());
            var defaultSln = SolutionFixture.GetDefaultSolution(context.FileSystem);

            SingletonFactory.Context = context;
            var helper = SingletonFactory.GetDotNetCoreHelper();

            Assert.IsNotNull(helper.BuildTempFolder);
            Assert.AreEqual("BuildTemp", helper.BuildTempFolder.FullPath);
            Assert.IsNotNull(helper.TestTempFolder);
            Assert.AreEqual("TestTemp", helper.TestTempFolder.FullPath);
        }
Ejemplo n.º 4
0
        public void DotNetCoreHelper_Projects_Success()
        {
            var context    = this.GetMoqContext(new Dictionary <string, bool>(), new Dictionary <string, string>());
            var settings   = this.GetSettings(context);
            var defaultSln = SolutionFixture.GetDefaultSolution(context.FileSystem);

            SingletonFactory.Context = context;
            var dotNethelper = SingletonFactory.GetDotNetCoreHelper();
            var projConfig   = context.AddDotNetCoreProject(defaultSln.SlnFile.Path.FullPath);

            projConfig.AddTestConfig("Unit");
            settings.SetupSetting();

            var anotherConfig = dotNethelper.AddProjectConfiguration(projConfig);

            Assert.AreEqual(1, dotNethelper.Projects.Count());
            Assert.AreEqual(1, dotNethelper.Tests.Count());
            Assert.AreEqual(projConfig, anotherConfig);

            projConfig.AddTestConfig("System");
            Assert.AreEqual(2, dotNethelper.Tests.Count());

            var newProjConfig = dotNethelper.GetProjectConfiguration(defaultSln.SlnFile.Path.FullPath);

            Assert.IsNotNull(newProjConfig);
            var fancyProjConfig = dotNethelper.AddProjectConfiguration(defaultSln.SlnFile.Path.FullPath, config =>
            {
                config.ProjectAlias = "TestProjects";
            });

            Assert.IsNotNull(fancyProjConfig);
            Assert.AreEqual(2, dotNethelper.Projects.Count());


            Assert.ThrowsException <ArgumentNullException>(() => ((IDotNetCoreHelper)null)
                                                           .AddProjectConfiguration("slh.sln"));
            Assert.ThrowsException <ArgumentNullException>(() => dotNethelper.AddProjectConfiguration(string.Empty));
            Assert.ThrowsException <FileNotFoundException>(() => dotNethelper.AddProjectConfiguration("test.sln"));
        }
        public void DotNetCoreAlias_AddProject_Custom_Success()
        {
            var context    = this.GetMoqContext(new Dictionary <string, bool>(), new Dictionary <string, string>());
            var defaultSln = SolutionFixture.GetDefaultSolution(context.FileSystem);

            context.AddDotNetCoreProject(defaultSln.SlnFile.Path.FullPath, proj =>
            {
                proj.Configuration = "Release";
            });

            var helperSetting = SingletonFactory.GetHelperSettings();

            Assert.IsNotNull(helperSetting);

            var projects = helperSetting.DotNetCoreSettings.Projects.ToArray();

            Assert.AreEqual(1, projects.Length);
            Assert.IsTrue(projects.Any(t => t.ProjectAlias == "CakeHelpers"));

            var slnProj = projects.FirstOrDefault();

            Assert.IsNotNull(slnProj);
            Assert.AreEqual("Release", slnProj.Configuration);
            Assert.AreEqual("BuildTemp/CakeHelpers/Release", slnProj.BuildTempDirectory.FullPath);

            slnProj.Framework = "net40";
            Assert.AreEqual("net40", slnProj.Framework);
            Assert.AreEqual("BuildTemp/CakeHelpers/Release/net40", slnProj.BuildTempDirectory.FullPath);

            slnProj.Platform = "x86";
            Assert.AreEqual("x86", slnProj.Platform);
            Assert.AreEqual("BuildTemp/CakeHelpers/Release/net40/x86", slnProj.BuildTempDirectory.FullPath);

            helperSetting.DotNetCoreSettings.BuildSettings.BuildTempFolder = string.Empty;
            Assert.IsNull(slnProj.BuildTempDirectory);

            Assert.AreEqual(2, slnProj.AllProjects.Count());
            Assert.AreEqual(1, slnProj.SrcProjects.Count());
            Assert.AreEqual(1, slnProj.TestProjects.Count());

            var unitConfig = slnProj.AddTestConfig("Unit");

            Assert.IsNotNull(unitConfig);
            Assert.IsTrue(string.IsNullOrWhiteSpace(unitConfig.Logger));
            unitConfig.Logger = "teamcity";
            Assert.IsFalse(string.IsNullOrWhiteSpace(unitConfig.Logger));

            Assert.AreEqual("Unit", unitConfig.TestCategory);

            Assert.AreEqual(TestTypeEnum.Default, unitConfig.TestType);
            unitConfig.TestType = TestTypeEnum.MsTest;
            Assert.AreEqual(TestTypeEnum.MsTest, unitConfig.TestType);

            Assert.IsNotNull(unitConfig.Context);

            var systemTest = "System";
            var testAdded  = string.Empty;

            slnProj.TestConfigAdded += (configuration, testConfiguration) =>
            {
                testAdded = testConfiguration.TestCategory;
            };

            var systemTestConfig = slnProj.AddTestConfig(systemTest);

            Assert.AreEqual(systemTest, testAdded);
            Assert.AreEqual(2, slnProj.TestConfigurations.Count());
            Assert.AreEqual("TestCategory=System", systemTestConfig.GetDotNetCoreCategoryString());
            systemTestConfig.TestType = TestTypeEnum.XUnit;
            Assert.AreEqual("Category=System", systemTestConfig.GetDotNetCoreCategoryString());
            Assert.ThrowsException <ArgumentNullException>(() => ((ITestConfiguration)null).GetDotNetCoreCategoryString());

            var sameProj = context.AddDotNetCoreProject(defaultSln.SlnFile.Path.FullPath);

            Assert.IsNotNull(sameProj);
            Assert.AreEqual(slnProj, sameProj);
            var outputPaths = slnProj.GetAllProjectOutputDirectoryPaths().ToArray();

            Assert.AreEqual(4, outputPaths.Length);

            Assert.ThrowsException <ArgumentNullException>(() => sameProj.AddTestConfig((ITestConfiguration)null));
            Assert.ThrowsException <ArgumentNullException>(() => ((IProjectConfiguration)null).AddTestConfig("test"));
            Assert.ThrowsException <ArgumentNullException>(() => ((IProjectConfiguration)null)
                                                           .GetAllProjectOutputDirectoryPaths());
            Assert.ThrowsException <ArgumentNullException>(() => ((IProjectConfiguration)null)
                                                           .GetRelativeSlnFilePath());
        }