public void copies_grammars() { const string fixtureKey = "a key"; var lib = new FixtureLibrary(); var original = new FixtureModel(fixtureKey); lib.Models[fixtureKey] = original; original.AddGrammar(new Sentence { key = "sentence", format = "a format" }); var overrides = new FixtureLibrary(); var overriden = new FixtureModel(fixtureKey); overrides.Models[fixtureKey] = overriden; var result = lib.ApplyOverrides(overrides); result.Models.Count.ShouldBe(1); var fixture = result.Models[fixtureKey]; ReferenceEquals(fixture, overrides.Models[fixtureKey]).ShouldBeFalse(); fixture.key.ShouldBe(fixtureKey); fixture.grammars.Length.ShouldBe(1); var sentence = fixture.grammars[0] as Sentence; sentence.key.ShouldBe("sentence"); sentence.format.ShouldBe("a format"); }
public ActionResult AddResult(FixtureModel FixtureObj) { AddResultViewModel rvm = new AddResultViewModel(); rvm.Details = FixtureObj; if (FixtureObj.FixtureType == 0) { rvm.FixtureTypeList = resRepo.LeagueResult_GetFixtureTypes(); } var players = resRepo.LeagueResult_GetTeamsForFixture(FixtureObj.FixtureRef); rvm.HomePlayers = new List <PlayerModel>(); rvm.AwayPlayers = new List <PlayerModel>(); foreach (var p in players) { PlayerModel play = new PlayerModel(); play.Id = p.PlayerRef; play.RegistrationId = p.RegistrationId; play.Name = p.Forename.Substring(0, 1) + " " + p.Surname; if (p.TeamRef == FixtureObj.HomeTeamRef) { rvm.HomePlayers.Add(play); } else { rvm.AwayPlayers.Add(play); } } return(PartialView("Partial_AddResult", rvm)); }
public void derive_the_key_from_a_title_3() { var fixture = FixtureModel.BuildFromKeyOrTitle("Going to the store - Walmart"); fixture.title.ShouldBe("Going to the store - Walmart"); fixture.key.ShouldBe("GoingToTheStoreWalmart"); }
public void ProcessRequest(HttpContext context) { List <TemporaryFixtureInfo> infos = new List <TemporaryFixtureInfo>(); try { using (FixtureModel model = new FixtureModel()) { var fixes = model.JDJS_WMS_Fixture_Temporary_Table; foreach (var item in fixes) { TemporaryFixtureInfo info = new TemporaryFixtureInfo() { Id = item.Id, FixtureOrderNum = item.FixtureOrderNum, FixtureSpecification = item.FixtureSpecification, InTime = item.InTime, Name = item.Name, Remark = item.Remark == null?"":item.Remark, StockNum = item.StockNum == null?0:Convert.ToInt32(item.StockNum) }; infos.Add(info); } } } catch (Exception ex) { } System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var json = serializer.Serialize(infos); context.Response.Write(json); return; }
public void create_a_fixture_from_a_key() { var fixture = FixtureModel.BuildFromKeyOrTitle("Something"); fixture.key.ShouldBe("Something"); fixture.title.ShouldBe("Something"); }
public void derive_the_title_for_a_complex_key() { var fixture = FixtureModel.BuildFromKeyOrTitle("SomethingElse"); fixture.key.ShouldBe("SomethingElse"); fixture.title.ShouldBe("Something Else"); }
public string CreateFixture(string keyOrTitle) { var fixture = FixtureModel.BuildFromKeyOrTitle(keyOrTitle); var file = FileFor(fixture.key); if (File.Exists(file)) { ConsoleWriter.Write(ConsoleColor.White, $"Fixture file '{file}' already exists"); } else { _watcher.Latch(() => { FixtureWriter.Write(fixture, file); }); _overrides.Models[fixture.key] = fixture; sendUpdatesToClient(); ConsoleWriter.Write(ConsoleColor.Green, $"Successfully created a new Fixture {fixture.key}: {fixture.title}"); } return(file); }
public static string Write(FixtureModel model) { var writer = new StringWriter(); Write(model, writer); return writer.ToString(); }
public TableMode(string key, string title, FixtureModel fixture) { _table = new Table(); _table.key = key; _table.title = title; fixture.AddGrammar(_table); }
public void overrides_original_title() { const string key = "a key"; var lib = new FixtureLibrary(); var original = new FixtureModel(key); original.title = "A title"; original.implementation = "some implementation"; lib.Models[key] = original; var overrides = new FixtureLibrary(); var overriden = new FixtureModel(key); overriden.title = "A new title"; overrides.Models[key] = overriden; var result = lib.ApplyOverrides(overrides); result.Models.Count.ShouldBe(1); var fixture = result.Models[key]; ReferenceEquals(fixture, overrides.Models[key]).ShouldBeFalse(); fixture.title.ShouldBe(overriden.title); fixture.implementation.ShouldBe(original.implementation); }
private void processFixtures(Task <IDocument> response) { Fixtures.ClearItems(); IDocument document = response.Result; var tables = document.QuerySelectorAll(".FTable"); foreach (var table in tables) { var fixture = new FixtureModel(); var headerRow = table.QuerySelector(".FHeader"); fixture.Date = headerRow.QuerySelector("td").TextContent; var matches = table.QuerySelectorAll(".FRow"); foreach (var match in matches) { var matchModel = new MatchModel(); matchModel.Time = match.QuerySelector(".FDate").TextContent; try { matchModel.TeamA = match.QuerySelector(".FHomeTeam").TextContent; matchModel.TeamAHref = match.QuerySelector(".FHomeTeam").QuerySelector("a").GetAttribute("href"); matchModel.TeamB = match.QuerySelector(".FAwayTeam").TextContent; matchModel.TeamBHref = match.QuerySelector(".FAwayTeam").QuerySelector("a").GetAttribute("href"); matchModel.Court = match.QuerySelector(".FPlayingArea").TextContent; matchModel.Score = match.QuerySelector(".FScore").TextContent; } catch (Exception ex) { } fixture.Matches.AddOnUIThread(matchModel); } Fixtures.AddOnUIThread(fixture); } }
protected void Page_Init(object sender, EventArgs e) { doc = SiteCache.FixtureData; doc1 = SiteCache.HandicapData; model = new FixtureModel(); model2 = new PlayerModel(); }
public ActionResult DeleteConfirmed(int id) { FixtureModel fixtureModel = db.Fixtures.Find(id); db.Fixtures.Remove(fixtureModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public static string Write(FixtureModel model) { var writer = new StringWriter(); Write(model, writer); return(writer.ToString()); }
public void ReadTotalSamplesTest(FixtureModel model) { if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor)) { Fin <ulong> totalSamples = Flac.ReadTotalSamples(model.ToTargetInformation(this.RealFileSystem).FileStream); Assert.True(totalSamples.IsSucc); ((ulong)totalSamples).Should().Be(model.Record.TotalSamples); } }
public void to_missing_code_if_nothing_is_missing() { var fixture = new FixtureModel("Something") { IsMissing = false }; fixture.missingCode.ShouldBe(FixtureModel.FullyImplementedMessage); }
public void HasLogFileTest(FixtureModel model) { if (model.Process.ContainsKey(FixtureModel.FrontierLabsLogFileExtractor)) { TargetInformation ti = model.ToTargetInformation(this.RealFileSystem); Assert.True(ti.TargetSupportFiles.ContainsKey(LogFile.LogFileKey)); } }
public void ReadSampleRateTest(FixtureModel model) { if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor)) { Fin <uint> sampleRate = Flac.ReadSampleRate(model.ToTargetInformation(this.RealFileSystem).FileStream); Assert.True(sampleRate.IsSucc); ((uint)sampleRate).Should().Be(model.Record.SampleRateHertz); } }
public void ReadNumChannelsTest(FixtureModel model) { if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor)) { Fin <byte> channels = Flac.ReadNumChannels(model.ToTargetInformation(this.RealFileSystem).FileStream); Assert.True(channels.IsSucc); ((byte)channels).Should().Be((byte)model.Record.Channels); } }
public void ReadBitDepthTest(FixtureModel model) { if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor)) { Fin <byte> bitDepth = Flac.ReadBitDepth(model.ToTargetInformation(this.RealFileSystem).FileStream); Assert.True(bitDepth.IsSucc); ((byte)bitDepth).Should().Be(model.Record.BitDepth); } }
public void ProcessRequest(HttpContext context) { try { int id = int.Parse(context.Request["id"]);//id using (FixtureModel model = new FixtureModel()) { var fx = model.JDJS_WMS_Fixture_System_Table.Where(r => r.Id == id).FirstOrDefault(); if (fx == null) { context.Response.Write("该治具不存在!"); return; } using (System.Data.Entity.DbContextTransaction mytran = model.Database.BeginTransaction()) { try { model.JDJS_WMS_Fixture_System_Table.Remove(fx); model.SaveChanges(); mytran.Commit(); PathInfo info = new PathInfo(); if (System.IO.File.Exists(System.IO.Path.Combine(info.GetFixtrue_SurfMillFilePath(), fx.FileName))) { System.IO.File.Delete(System.IO.Path.Combine(info.GetFixtrue_SurfMillFilePath(), fx.FileName)); } using (JDJS_WMS_DB_USEREntities wms = new JDJS_WMS_DB_USEREntities()) { var status = wms.JDJS_WMS_Device_Status_Table.Where(r => r.SystemId == id).FirstOrDefault(); if (status != null) { wms.JDJS_WMS_Device_Status_Table.Remove(status); } wms.SaveChanges(); } string str = ""; Fixture_SurfMill.DeleteChildJIG(fx.Name, fx.Desc, fx.StockAllNum.ToString(), fx.StockCurrNum.ToString(), ref str); context.Response.Write(str); return; } catch (Exception ex) { mytran.Rollback(); context.Response.Write(ex.Message); return; } } } } catch (Exception ex) { context.Response.Write(ex.Message); return; } }
public void to_missing_code_with_the_fixture_itself_being_missing() { var fixture = new FixtureModel("Something") { IsMissing = true }; fixture.missingCode.ShouldNotBe(FixtureModel.FullyImplementedMessage); fixture.missingCode.ShouldContain("public class SomethingFixture"); }
public ActionResult Edit([Bind(Include = "FixtureId,FixtureName,Team1Id,Team2Id,Matchdate,Executed")] FixtureModel fixtureModel) { if (ModelState.IsValid) { db.Entry(fixtureModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Team1Id = new SelectList(db.Teams, "TeamId", "TeamName", fixtureModel.Team1Id); ViewBag.Team2Id = new SelectList(db.Teams, "TeamId", "TeamName", fixtureModel.Team2Id); return(View(fixtureModel)); }
public MetadataDurationBugTests(FixtureHelper.FixtureData data) { this.fixture = data[FixtureModel.MetadataDurationBug]; this.target = TempFile.FromExisting(this.fixture.AbsoluteFixturePath); this.fileUtilities = new FileUtilities(Helpers.NullLogger <FileUtilities>(), new FileSystem()); this.fixer = new MetadataDurationBug(Helpers.NullLogger <MetadataDurationBug>(), this.fileUtilities); this.dryRunLogger = Helpers.NullLogger <DryRun>(); this.data = data; this.fileSystem = new FileSystem(); }
public static void Write(FixtureModel model, TextWriter writer) { writer.WriteLine($"# {model.title}"); writer.WriteLine(); writer.WriteLine(); var grammars = model.grammars.Where(x => x.key != "TODO").OrderBy(x => x.key); foreach (var grammar in grammars) { writeGrammar(model, writer, grammar, false); } }
private (byte[] FormatChunk, RangeHelper.Range DataChunk) ReadChunkRanges(FixtureModel model) { using var stream = model.ToTargetInformation(this.RealFileSystem).FileStream; var riffChunk = Wave.FindRiffChunk(stream); var waveChunk = riffChunk.Bind(r => Wave.FindWaveChunk(stream, r)); var formatChunk = waveChunk.Bind(w => Wave.FindFormatChunk(stream, w)); var dataChunk = waveChunk.Bind(w => Wave.FindDataChunk(stream, w)); var formatSpan = RangeHelper.ReadRange(stream, (RangeHelper.Range)formatChunk); return(formatSpan.ToArray(), (RangeHelper.Range)dataChunk); }
public static void Write(FixtureModel model, string file) { using (var stream = new FileStream(file, FileMode.Create)) { var writer = new StreamWriter(stream); Write(model, writer); } var text = Write(model); new FileSystem().WriteStringToFile(file, text); }
private static void writeParagraph(Paragraph paragraph, FixtureModel model, TextWriter writer) { for (int i = 0; i < paragraph.children.Length; i++) { var child = paragraph.children[i]; if (child is Silent) continue; writeGrammar(model, writer, child, true); } writer.WriteLine(); writer.WriteLine(); }
// GET: FixtureModels/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FixtureModel fixtureModel = db.Fixtures.Find(id); if (fixtureModel == null) { return(HttpNotFound()); } return(View(fixtureModel)); }
public void ProcessRequest(HttpContext context) { try { int id = int.Parse(context.Request["id"]); string fxNum = ""; List <File> file = new List <File>(); using (FixtureModel wms = new FixtureModel()) { var fx = wms.JDJS_WMS_Fixture_System_Table.Where(r => r.Id == id).FirstOrDefault(); if (fx != null) { fxNum = fx.FixtureOrderNum; } } if (fxNum != "") { PathInfo info = new PathInfo(); string path = System.IO.Path.Combine(info.upLoadPath(), @"特殊治具管理", fxNum, @"设计文件"); DirectoryInfo root = new DirectoryInfo(path); if (root.Exists) { FileInfo[] files = root.GetFiles(); foreach (var item in files) { file.Add(new File { fileName = item.Name, filePath = item.FullName, fileSize = (item.Length / 1024).ToString() + " kB", fileTime = item.CreationTime.ToString() }); } } } System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var model = new { msg = "", code = 0, count = file.Count, data = file }; var json = serializer.Serialize(model); context.Response.Write(json); } catch (Exception ex) { context.Response.Write(ex.Message); } }
private static void writeParagraph(Paragraph paragraph, FixtureModel model, TextWriter writer) { for (int i = 0; i < paragraph.children.Length; i++) { var child = paragraph.children[i]; if (child is Silent) { continue; } writeGrammar(model, writer, child, true); } writer.WriteLine(); writer.WriteLine(); }
public void does_not_overwrite_an_existing_fixture() { var file = theFixtureDirectory.AppendPath("One.md"); var original = new FixtureModel("One") { title = "a fancier title" }; FixtureWriter.Write(original, file); theController.CreateFixture("One"); FixtureReader.ReadFromFile(file) .title.ShouldBe(original.title); theClient.ReceivedCalls().Any().ShouldBeFalse(); }
private static void writeGrammar(FixtureModel model, TextWriter writer, GrammarModel grammar, bool inParagraph) { if (inParagraph) { writer.WriteLine($"* {grammar.TitleOrFormat()}"); } else { writer.WriteLine($"## {grammar.key}"); writer.WriteLine($"### {grammar.TitleOrFormat()}"); } if (grammar is Sentence) { writeSentence((Sentence) grammar, writer); } if (grammar is Table) { writeTable((Table) grammar, writer); } if (grammar is EmbeddedSection) { writeEmbed((EmbeddedSection) grammar, writer); } if (grammar is Paragraph) { writeParagraph(grammar.As<Paragraph>(), model, writer); } if (!inParagraph) { writer.WriteLine(); writer.WriteLine(); } }
public GrammarMode(FixtureModel fixture, Action<GrammarModel> adder) { _fixture = fixture; _adder = adder; }
public ParagraphMode(Paragraph paragraph, FixtureModel fixture) { _paragraph = paragraph; _fixture = fixture; }
public HeaderMode(FixtureModel fixture) { _fixture = fixture; }
public CommentMode(FixtureModel fixture) { _fixture = fixture; }