public void files_are_just_the_one_file() { var file = new AssetFile("something.js"); var source = new FileRead(file); source.Files.Single().ShouldBeTheSameAs(file); }
public void no_inner_content_sources() { var file = new AssetFile("something.js"); var source = new FileRead(file); source.InnerSources.Any().ShouldBeFalse(); }
public static uint[] Open(string txtStartOffset, string txtEndOffset, string txtReadHashes, string txtSkipHashes, string filePath) { var startOffset = Convert.ToInt64(txtStartOffset); var endOffset = Convert.ToInt64(txtEndOffset); var readHashes = Convert.ToInt32(txtReadHashes); var skipHashes = Convert.ToInt32(txtSkipHashes); var arrayFromFile = new FileRead().ReadFile(filePath, startOffset, endOffset); var arrayFromFileWithHashesSkipped = new List <uint>(); var countHashesRead = 1; for (int i = 0; i < arrayFromFile.Length; i++) { arrayFromFileWithHashesSkipped.Add(arrayFromFile[i]); if (countHashesRead >= readHashes) { i += skipHashes; countHashesRead = 1; } else { countHashesRead++; } } return(arrayFromFileWithHashesSkipped.ToArray()); }
/// <summary> /// Handle any additional receiving the node might want to do /// in the receiver class. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void HandleAdditionalReceiving(object sender, DataReceivedEventArgs e) { NodeComm receivedData = e as NodeComm; if (receivedData != null) { switch (receivedData.Protocol) { case NodeComm.MessageType.File: // This will block on the IOStream until the file reading // is over. The next thing sent over the network must be a file. _job = JsonConvert.DeserializeObject <JobRef>(receivedData.Args[1]); FileRead.ReadInWriteOut(Proxy.IOStream, _job.FileName); //job = receivedData; // after we have finished reading the data, let node manager know OnDataReceived(new NodeComm(DataReceivedEventArgs.ConstructMessage("fileread"))); break; case NodeComm.MessageType.Execute: //TODO, this should be its own task/thread _parent.Logger.Log("Node: executing"); JobLauncher j = new JobLauncher(_job, _parent); j.LaunchJob(); break; case NodeComm.MessageType.Shutdown: case NodeComm.MessageType.Quit: // shutting down or quitting, we are done receving DoneReceiving = true; break; } } }
public void DoFile(string path) { FileRead fr = new FileRead(); fr.ReadGed(path); var results = fr.Data; int indi = 0; int fam = 0; foreach (var result in results) { if ((result as IndiRecord) != null) { indi++; } if ((result as FamRecord) != null) { fam++; } } Assert.AreNotEqual(0, indi, path); Assert.AreNotEqual(0, fam, path); }
public List <GEDCommon> CommonBasic(string txt, Encoding fileEnc) { // Exercise a file encoding var tmppath = Path.GetTempFileName(); FileStream fStream = null; try { fStream = new FileStream(tmppath, FileMode.Create); // Code analysis claims fStream will be disposed twice if 'using' using (StreamWriter stream = new StreamWriter(fStream, fileEnc)) { stream.Write(txt); } } finally { if (fStream != null) { fStream.Dispose(); } } FileRead fr = new FileRead(); fr.ReadGed(tmppath); File.Delete(tmppath); return(fr.Data.Select(o => o as GEDCommon).ToList()); }
public void gpsdata(int dbsk, int dbgsk) { //declaration of varibles //int i = ; int sk = dbsk; int gsk = dbgsk; string gstr1; //declaration of class object FileRead rd = new FileRead(); FilegRead grd = new FilegRead(); FileWrite wr = new FileWrite(); GPStringFromating gdata = new GPStringFromating(); //code to setup gps string updates rd.ReadData(sk); //sk = sk + 69; //reading strings and processing them gstr1 = grd.ReadgData(gsk); Console.WriteLine(gstr1); //gsk = gsk + 69; gdata.Gpsplit(gstr1); //creating a wait at output Console.ReadLine(); }
public void Test_FillContent() { var factoryMock = Substitute.For <Func <string> >(); var optionsMock = Substitute.For <IOptions <MemoryCacheOptions> >(); optionsMock.Value.Returns(callInfo => new MemoryCacheOptions()); var memoryCache = new MemoryCache(optionsMock); ICacheService cacheService = new CacheService(memoryCache); IConfiguration _configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); var anonymousData = new { Name = "Riya", Occupation = "Kavin Brother." }; string content = Helper.GetAdTemplateFileContent(); IFileRead read = new FileRead(_configuration, cacheService); content = read.FillContent(content, anonymousData); Action act = () => content.Should().Contain(anonymousData.Name); act.Should().NotThrow(); Action act1 = () => content.Should().Contain(anonymousData.Occupation); act1.Should().NotThrow(); }
public MetafileTaskVerified(MetafileTaskVerified task, FileRead read) { this.data = task.data; this.algorithm = task.algorithm; this.read = read; }
public MetafileTaskVerified(HashAlgorithm algorithm, FileRead read) { this.algorithm = algorithm; this.read = read; data = new List <byte[]>(); }
public static string Write(FileRead fr, bool noHead = true, bool unix = true) { MemoryStream mem = new MemoryStream(); FileWrite.WriteRecs(mem, fr.Data, noHead, unix); return(Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length)); }
public void to_string_because_automated_tests_depend_on_it() { var file = new AssetFile("something.js"); var read = new FileRead(file); read.ToString().ShouldEqual("FileRead:something.js"); }
/// <summary> /// Fired when a new CSV file is created. /// </summary> private protected override void OnNewFile(object eventSource, FileSystemEventArgs e) { string filePath = e.FullPath; IEnumerable <Computer> computerAssets = ReadNewDataFile(filePath).ToList(); FileRead?.Invoke(computerAssets); }
static void Main() { string path = @"..\..\..\FileToRead.txt"; string[] arr = FileRead.ReadFileToArr(path); PrintData.ArrPrint(arr, 50); Console.ReadLine(); }
private string SaveIcon(int ProductID, int CultureID, FileRead FileReadModel) { var _Container = "product-icon"; var _ContainerReference = ProductID + "/" + CultureID + "/" + FileReadModel.FileName; new Utils.FileUtil().DeleteFolder(_Container, ProductID + "/" + CultureID + "/"); new Utils.FileUtil().UploadImage(Utils.ImageUtil.StringToStream(FileReadModel.FileContent), _Container, _ContainerReference); return(StorageUrl + "/" + _Container + "/" + _ContainerReference); }
public WEM(FileRead fr = null) { if (fr != null) { _id = fr.read_uint32(); _offset = fr.read_uint32(); _size = fr.read_uint32(); } }
public static string GetAdTemplateFileContent() { int days = Helper.GetCacheExpireDays(); string fileName = Helper.GetAdFileName(); IMemoryCache _memoryCache = Helper.GetDefaultMemoryCacheObject(); string content = new FileRead(_memoryCache).FileAsString(fileName, days, "_AdHtmlFileTemplate"); return(content); }
private void Start() { URL = FileRead.FindPathFromConfig(configPath, "CHATBOT_SERVER_URL"); toAnimate = false; //toSpeak = false; //audio = GetComponent<AudioSource>(); keys = head.GetComponent <SkinnedMeshRenderer>(); shapekeys = new List <int>(); }
public static FileRead GetFileReadReport(DebuggerThread Context, DataProcessor Data) { FileRead Report = new FileRead(); Report.Handle = new IntPtr(Data.Pop()); Report.Length = Data.Pop(); Report.Offset = Data.Pop(); return(Report); }
public void startSphere() { fileRead = FindObjectOfType <FileRead>(); vec = fileRead.UpdatePosition(); SphereName = fileRead.UpdateSphereName(); Sphere.transform.SetParent(GameObject.FindGameObjectWithTag("Canvas").transform, false); creator(vec, SphereName); }
public static FileRead GetFileReadReport(DebuggerThread Context, uint[] Data) { FileRead Report = new FileRead(); Report.Handle = new IntPtr(Data[0]); Report.Length = Data[1]; Report.Offset = Data[2]; return(Report); }
/// <summary> /// Factory pattern implementation /// </summary> private Game() { _fileReader = FileRead.Instance(); _gameSettings = _fileReader.GetGameSettings(); _validateSettings = new ValidateSettings(_gameSettings); _turtleStartPoint = _gameSettings.StartPoint; _grid = new Grid(_gameSettings.Size.Y, _gameSettings.Size.X); _observer = new Observer(_grid); Initialize(); }
public void GetLookUp_Test() { var factoryMock = Substitute.For <Func <string> >(); var optionsMock = Substitute.For <IOptions <MemoryCacheOptions> >(); optionsMock.Value.Returns(callInfo => new MemoryCacheOptions()); var memoryCache = new MemoryCache(optionsMock); ICacheService cacheService = new CacheService(memoryCache); IConfiguration _configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); IFileRead read = new FileRead(_configuration, cacheService); IJsonDataService jsonService = new JsonDataService(_configuration, cacheService, read); var list = jsonService.GetCategories(); Action act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); list = jsonService.GetCategories(); act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); list = jsonService.GetCategories(); act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); list = jsonService.GetCategories(); act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); list = jsonService.GetConditions(); act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); list = jsonService.GetMileOptionsBy(); act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); list = jsonService.GetSortOptionsBy(); act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); list = jsonService.GetConditions(); act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); list = jsonService.GetMileOptionsBy(); act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); list = jsonService.GetSortOptionsBy(); act = () => list.Count.Should().BeGreaterThan(0); act.Should().NotThrow(); }
public void DiffTests() //Should fail, as fileRead should handle invalid file names { List <List <string[]> > contents = new List <List <string[]> >(); List <List <string[]> > invalidContents = new List <List <string[]> >(); contents = FileRead.Read("test1.txt", "test2.txt"); invalidContents = FileRead.Read("notA.txt", "realFile.txt"); Assert.ThrowsException <System.Exception>(() => Diff.Difference(contents)); Assert.ThrowsException <System.Exception>(() => Diff.Difference(invalidContents)); }
// For those tests which need to verify errors at the topmost level public static FileRead ReadItHigher(string testString) { // TODO as implemented, trailing newline in original string will cause an "empty line" error record to be generated FileRead fr = new FileRead(); using (var stream = new StreamReader(ToStream(testString))) { fr.ReadGed(null, stream); } return(fr); }
public void OnCompleted(FileRead data) { if (data.Count > 0) { long offset = data.Position + data.Count; long position = completed + data.Count + routine.offset - routine.entries[index].Start; Receiver receiver = new Receiver(routine, index, completed + data.Count); RepositoryViewEntry entry = routine.entries[index]; if (routine.entries.Length > index + 1 && position >= routine.entries[index].Size) { receiver = new Receiver(routine, index + 1, completed + data.Count); entry = routine.entries[index + 1]; position = 0; offset = 0; } if (completed + data.Count == routine.buffer.Count) { routine.callback.Invoke(new RepositoryViewRead { Piece = routine.piece, Block = routine.block, Buffer = routine.buffer, Count = routine.buffer.Count }); } else { int left = routine.buffer.Count - completed - data.Count; long count = entry.Size - position; if (count > left) { count = left; } entry.File.Read(offset, new FileBuffer(routine.buffer.Data, routine.buffer.Offset + completed + data.Count, (int)count), receiver.OnCompleted); } } else { routine.callback.Invoke(new RepositoryViewRead { Piece = routine.piece, Block = routine.block, Buffer = routine.buffer, Count = completed }); } }
public void Test_FileAsStream() { var anonymousData = new { Name = "Riya", Occupation = "Kavin Brother." }; string content = new FileRead(Helper.GetDefaultMemoryCacheObject()).FillContent(Helper.GetAdTemplateFileContent(), anonymousData); Stream stream = new FileRead(Helper.GetDefaultMemoryCacheObject()).FileAsStream(content); Action act = () => stream.Should().NotBeNull(); act.Should().NotThrow(); }
public string Render() { string followersHtml = FileRead.HtmlDocument("../../Content/following.html"); StringBuilder pageBuilder = new StringBuilder(); foreach (var userViewModel in Model) { pageBuilder.Append( $@"<li><h4><strong><a href=""/followers/profile?id={userViewModel.Id}"">{userViewModel.Username}</a></strong> </h4></li>"); } followersHtml = followersHtml.Replace("##followers##", pageBuilder.ToString()); return(followersHtml); }
public void LoadFromStream(StreamReader stream) { _issues = new List <Issue>(); _gedReader = new FileRead(); _gedReader.ReadGed(null, stream); if (_gedReader.Data.Count < 1) // nothing to do! { return; } BuildTree(); CalcTrees(); }
/// Load the templates from a txt file public void LoadTemplates(string path, string filename) { Templates = new Dictionary <string, string>(); string key = null; string template = null; using (FileRead reader = new FileRead(path, filename)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line.Left(2) == "%%") // Template Key line found { if (key != null) { if (template == null) { throw new Exception("Empty template for key '" + key + "'"); } Templates.Add(key, template); } key = line.Substring(2).Trim(); template = null; } else { if (key == null) { throw new Exception("Missing Template Key"); } if (template == null) { template = line; } else { template += "\n" + line; } } } if (key != null) { if (template == null) { throw new Exception("Empty template for key '" + key + "'"); } Templates.Add(key, template); } } }
public void read_content() { var context = MockRepository.GenerateMock<IContentPipeline>(); var file = new AssetFile("something.js"){ FullPath = "some/path" }; var theContents = "some contents"; context.Stub(x => x.ReadContentsFrom(file.FullPath)).Return(theContents); var source = new FileRead(file); source.GetContent(context).ShouldEqual(theContents); }
static void Main(string[] args) { League AFC = new League(); FileWrite fw = new FileWrite(); FileRead fr = new FileRead(); AFC.TradePlayer(AFC._teams[0], AFC._teams[1], AFC._teams[0]._roster.Players[3]); fw.WriteToFile("../../Team1Roster.txt", AFC._teams[0]._roster.ToString()); fw.WriteToFile("../../Team2Roster.txt", AFC._teams[1]._roster.ToString()); Console.WriteLine("Top 5 Players for the " + AFC._teams[0]._name); foreach(string msg in AFC._teams[0]) { Console.WriteLine(msg); } Console.ReadKey(); Console.WriteLine(fr.readFile("../../Team1Roster.txt")); Console.WriteLine(fr.readFile("../../Team2Roster.txt")); Console.ReadKey(); }