public async Task Create_Branch_Exception() { var InputOwner = "foo"; var InputRepo = "bar"; var InputBranchName = "baz"; var InputSha = "qux"; var ExpectedURL = $"https://api.github.com/repos/{InputOwner}/{InputRepo}/git/refs"; var branchRef = new BranchRef() { Ref = $"refs/heads/{InputBranchName}", sha = InputSha }; var ExpectedJson = JsonConvert.SerializeObject(branchRef); var fixture = new GitHubFixture(); fixture.SetupCreateBranchWithFailure(ExpectedURL, ExpectedJson); var repository = new GitHubRepository(fixture.GitHubContext); var ex = await Assert.ThrowsAsync <RestAPICallException>(async() => await repository.CreateBranchAsync(InputOwner, InputRepo, InputBranchName, InputSha) ); Assert.Equal("InternalServerError", ex.StatusCode); Assert.Equal("Internal Server Error", ex.Message); Assert.Equal(ExpectedURL, ex.RequestMessage.RequestUri.ToString()); }
public void Can_use_Save_References_with_ForeignKey() { using (var db = OpenDbConnection()) { CreateRefTables(db); //Generate dummy data var branch = new BranchRef { Address = new AddressRef { StreetAddress = "2100 Gotham Lane", City = "Gotham", State = "NJ", ZipCode = "12345" } }; db.Save(branch, references: true); Assert.That(branch.Id, Is.Not.EqualTo(Guid.Empty)); Assert.That(branch.Address.Id, Is.Not.EqualTo(Guid.Empty)); Assert.That(branch.Id, Is.EqualTo(branch.Address.BranchRefId)); } }
public async Task Create_Branch_Normal() { var InputOwner = "foo"; var InputRepo = "bar"; var InputBranchName = "baz"; var InputSha = "qux"; // public async Task CreateBranchAsync(string owner, string repo, string branchName, string sha) var ExpectedURL = $"https://api.github.com/repos/{InputOwner}/{InputRepo}/git/refs"; var branchRef = new BranchRef() { Ref = $"refs/heads/{InputBranchName}", sha = InputSha }; var ExpectedJson = JsonConvert.SerializeObject(branchRef); var fixture = new GitHubFixture(); fixture.SetupCreateBranch(ExpectedURL, ExpectedJson); var repository = new GitHubRepository(fixture.GitHubContext); await repository.CreateBranchAsync(InputOwner, InputRepo, InputBranchName, InputSha); fixture.VerifyCreateBranch(ExpectedURL, ExpectedJson); }
static void AddElements(DialogueSequenceBuilder builder, IEnumerable<Element> elements) { foreach (var e in elements) { AddActors(builder, e); if (e is LineElement) { var le = (LineElement)e; builder.AddLine(le.phraseKey, le.actor); } else if (e is EnglishLineElement) { var ele = (EnglishLineElement)e; builder.AddEnglishLine(ele.line); } //else if (e is AnimationElement) { // var ae = (AnimationElement)e; // builder.AddAnimation(ae.animation, ae.actor); //} else if (e is EventElement) { var ee = (EventElement)e; builder.AddEvent(ee.Event); } //else if (e is MessageElement) { // var me = (MessageElement)e; // builder.AddMessage(me.message); //} else if (e is ExitDialogueElement) { builder.Break(); } else if (e is BranchElement) { var be = (BranchElement)e; int index = 0; BranchRef[] branchRefs = new BranchRef[0]; if (be.isEnglish) { branchRefs = be.branches.Select(b => new BranchRef(new PhraseSequence(b.promptKey))).ToArray(); builder.AddEnglishBranch(branchRefs); } else { branchRefs = be.branches.Select( b => b.isEnglish ? new BranchRef(new PhraseSequence(b.promptKey)) : new BranchRef(builder.GetPhrase(b.promptKey)) ).ToArray(); builder.AddJapaneseBranch(branchRefs); } foreach (var b in be.branches) { builder.SetOpenLink(branchRefs[index]); index++; AddElements(builder, b.responseElements); builder.OpenBranch(); } builder.CloseBranches(); } } }
void ResolveNextID(DialogueElement element) { if (readyToCloseBranches) { CloseBranches(element.ID); } if (openLink != null) { openLink.Index = element.ID; openLink = null; } if (lastElement != null) { lastElement.DefaultNextID = element.ID; } thisElement = element; lastElement = element; }
public void SetOpenLink(BranchRef branch) { openLink = branch; }