public static TestSetup Create() { var tempDir = TempDir.Create(); var repository = TempRepository.Create(tempDir); return(new TestSetup(repository, tempDir)); }
public ActionResult _Create([DataSourceRequest]DataSourceRequest request, TempExt model) { if (ModelState.IsValid) { string Msg = ""; try { TempRepository modelRepo = new TempRepository(); if (modelRepo.Create(model, ref Msg, this) == false) { return this.Json(new DataSourceResult { Errors = Msg }); } } catch (Exception ex) { string hostName1 = Dns.GetHostName(); string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString(); string PageName = Convert.ToString(Session["PageName"]); //string GetUserIPAddress = GetUserIPAddress1(); using (BaseRepository baseRepo = new BaseRepository()) { //BizContext BizContext1 = new BizContext(); BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress); } Session["PageName"] = ""; string error = ErrorHandling.HandleException(ex); return this.Json(new DataSourceResult { Errors = error }); } } return Json(new[] { model }.ToDataSourceResult(request, ModelState)); }
public static void TestRepositoryPattern() { var storeName = "TestRepositoryPattern" + DateTime.Now.Ticks; string id; using ( var context = new MyEntityContext()) { var uow = new TempUnitOfWork(context); var repo = new TempRepository<IPerson>(uow); var derived = repo.Create(); derived.FirstName = "Danny"; derived.FirstName = "Mayers"; context.SaveChanges(); id = derived.Id; } using ( var context = new MyEntityContext()) { var uow = new TempUnitOfWork(context); var repo = new TempRepository<IPerson>(uow); var derived = repo.GetById(id); } }
private Repository SetupRepositoryWithRemote(string remoteName, string pushUrl) { var workingDirectory = TempDir.Create(); var repo = TempRepository.Create(workingDirectory); foreach (var existingRemoteName in repo.Network.Remotes.Select(remote => remote.Name)) { repo.Network.Remotes.Remove(existingRemoteName); } repo.Network.Remotes.Add(remoteName, pushUrl); return(repo); }
public void ShouldExitIfWorkingCopyContainsNoProjects() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); var workingCopy = WorkingCopy.Discover(workingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages[0].ShouldBe($"Could not find any projects files in {workingDirectory} that have a <Version> defined in their csproj file."); Cleanup.DeleteDirectory(workingDirectory); }
public void ShouldExitIfWorkingCopyIsDirty() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); TempCsProject.Create(workingDirectory); var workingCopy = WorkingCopy.Discover(workingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages.ShouldHaveSingleItem(); _testPlatformAbstractions.Messages[0].ShouldBe($"Repository {workingDirectory} is dirty. Please commit your changes."); Cleanup.DeleteDirectory(workingDirectory); }
public void ShouldExitIfProjectsUseInconsistentNaming() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); TempCsProject.Create(Path.Join(workingDirectory, "project1"), "1.1.0"); TempCsProject.Create(Path.Join(workingDirectory, "project2"), "2.0.0"); CommitAll(tempRepository); var workingCopy = WorkingCopy.Discover(workingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages[0].ShouldBe($"Some projects in {workingDirectory} have an inconsistent <Version> defined in their csproj file. Please update all versions to be consistent or remove the <Version> elements from projects that should not be versioned"); Cleanup.DeleteDirectory(workingDirectory); }
public void ShouldIgnoreInsignificantCommits() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); TempCsProject.Create(workingDirectory); var workingFilePath = Path.Join(workingDirectory, "hello.txt"); // Create and commit a test file File.WriteAllText(workingFilePath, "First line of text"); CommitAll(tempRepository); // Run versionize var workingCopy = WorkingCopy.Discover(workingDirectory); workingCopy.Versionize(); // Add insignificant change File.AppendAllText(workingFilePath, "This is another line of text"); CommitAll(tempRepository, "chore: Added line of text"); // Get last commit var lastCommit = tempRepository.Head.Tip; // Run versionize, ignoring insignificant commits try { workingCopy.Versionize(ignoreInsignificant: true); throw new InvalidOperationException("Expected to throw in Versionize call"); } catch (CommandLineExitException ex) { ex.ExitCode.ShouldBe(0); } lastCommit.ShouldBe(tempRepository.Head.Tip); // Cleanup Cleanup.DeleteDirectory(workingDirectory); }