Exemplo n.º 1
0
        public void ThrowsExceptionOnReadWhenPathDoesntExist()
        {
            using var reader = new MemoryMappedFileReader <TestStruct>(FileName);
            Assert.Throws <FileNotFoundException>(() => reader.Read());

            WithMMFile(FileName, new TestStruct(), (_, _) => {
                // Verify that file is opened when available
                reader.Read();
            });
        }
Exemplo n.º 2
0
        public void CanReadAMemoryMappedStruct()
        {
            var expectedStruct = new TestStruct()
            {
                Field = SequentialByteArray(FieldSize)
            };

            WithMMFile(FileName, expectedStruct, (path, writtenData) => {
                using (var reader = new MemoryMappedFileReader <TestStruct>(path))
                {
                    Assert.Equal(writtenData.Field, reader.Read().Field);
                    // Verify that the same data can be read more than once
                    Assert.Equal(writtenData.Field, reader.Read().Field);
                }
            });
        }
Exemplo n.º 3
0
        public ISourceBlock <Pipeline.Telemetry.V0.IGameTelemetry> CreateTelemetrySource()
        {
            var mmReader  = new MemoryMappedFileReader <Contrib.Data.Shared>(Contrib.Constant.SharedMemoryName);
            var telemetry = new Telemetry();

            return(PollingSource.Create <Pipeline.Telemetry.V0.IGameTelemetry>(_config.PollingInterval, () => telemetry.Transform(mmReader.Read())));
        }