Beispiel #1
0
        public void ReplaceWithActualValues()
        {
            var sourceMessage   = Load("MBBSEMU.MSG");
            var outputRawStream = new MemoryStream();

            using var sourceStream = new StreamStream(sourceMessage);
            using var outputStream = new StreamStream(outputRawStream);

            MsgFile.UpdateValues(sourceStream, outputStream, new Dictionary <string, string>()
            {
                { "SOCCCR", "128" }, { "SLOWTICS", "Whatever" }, { "MAXITEM", "45" }
            });

            outputRawStream.Flush();
            outputRawStream.Seek(0, SeekOrigin.Begin);
            var result = Encoding.ASCII.GetString(outputRawStream.ToArray());

            // expected should have the mods applied
            var expected = Encoding.ASCII.GetString(Load("MBBSEMU.MSG").ToArray());

            expected = expected.Replace("SOCCCR {SoC credit consumption rate adjustment, per min: 0}", "SOCCCR {SoC credit consumption rate adjustment, per min: 128}");
            expected = expected.Replace("SLOWTICS {Slow system factor: 10000}", "SLOWTICS {Slow system factor: Whatever}");
            expected = expected.Replace("MAXITEM {Maximum number of items: 954}", "MAXITEM {Maximum number of items: 45}");

            result.Should().Be(expected);
        }
Beispiel #2
0
        public void ReplaceFileEmptyDictionary()
        {
            var fileName = Path.Combine(_modulePath, "MBBSEMU.MSG");

            Directory.CreateDirectory(_modulePath);
            File.WriteAllBytes(fileName, Load("MBBSEMU.MSG").ToArray());

            MsgFile.UpdateValues(fileName, new Dictionary <string, string>());

            File.ReadAllBytes(fileName).Should().BeEquivalentTo(Load("MBBSEMU.MSG").ToArray());
        }
Beispiel #3
0
        public void ReplaceWithEmptyDictionary()
        {
            var sourceMessage   = Load("MBBSEMU.MSG");
            var outputRawStream = new MemoryStream();

            using var sourceStream = new StreamStream(sourceMessage);
            using var outputStream = new StreamStream(outputRawStream);

            MsgFile.UpdateValues(sourceStream, outputStream, new Dictionary <string, string>());

            outputRawStream.Flush();
            outputRawStream.Seek(0, SeekOrigin.Begin);
            var result = outputRawStream.ToArray();

            sourceMessage.Seek(0, SeekOrigin.Begin);
            var expected = sourceMessage.ToArray();

            result.Should().BeEquivalentTo(expected);
        }
Beispiel #4
0
        public void ReplaceFileWithActualValues()
        {
            var fileName = Path.Combine(_modulePath, "MBBSEMU.MSG");

            Directory.CreateDirectory(_modulePath);
            File.WriteAllBytes(fileName, Load("MBBSEMU.MSG").ToArray());

            MsgFile.UpdateValues(fileName, new Dictionary <string, string>()
            {
                { "SOCCCR", "128" }, { "SLOWTICS", "Whatever" }, { "MAXITEM", "45" }
            });

            // expected should have the mods applied
            var expected = Encoding.ASCII.GetString(Load("MBBSEMU.MSG").ToArray());

            expected = expected.Replace("SOCCCR {SoC credit consumption rate adjustment, per min: 0}", "SOCCCR {SoC credit consumption rate adjustment, per min: 128}");
            expected = expected.Replace("SLOWTICS {Slow system factor: 10000}", "SLOWTICS {Slow system factor: Whatever}");
            expected = expected.Replace("MAXITEM {Maximum number of items: 954}", "MAXITEM {Maximum number of items: 45}");

            File.ReadAllBytes(fileName).Should().BeEquivalentTo(Encoding.ASCII.GetBytes(expected));
        }