Пример #1
0
        public void ReadUShort_ValidDocument_ReturnsValidUShort()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            ushort actual = document.ReadUShort("Section", "ushort", 0);

            Assert.AreEqual(65535, actual);
        }
Пример #2
0
        public void ReadShort_ValidDocument_ReturnsValidShort(string section, string key, short defaultValue, short expected)
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            short actual = document.ReadShort(section, key, defaultValue);

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void GetPropertiesCount_ValidDocument_ValidatesCount(string section, int expected)
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            var actual = document.GetPropertiesCount(section);

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void ReadByte_ValidDocument_ReturnsValidByte(string section, string key, byte defaultValue, byte expected)
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            byte actual = document.ReadByte(section, key, defaultValue);

            Assert.AreEqual(expected, actual);
        }
Пример #5
0
        public void ReadBool_ValidDocument_ReturnsValidBool()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            bool actual = document.ReadBool("Section", "bool", false);

            Assert.AreEqual(true, actual);
        }
Пример #6
0
        public void ReadDecimal_ValidDocument_ReturnsValidDecimal()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            decimal actual = document.ReadDecimal("Section", "decimal", 0);

            Assert.AreEqual(-99.999, actual);
        }
Пример #7
0
        public void ReadDouble_ValidDocument_ReturnsValidDouble()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            double actual = document.ReadDouble("Section", "double", 0);

            Assert.AreEqual(3.14159265359, actual);
        }
Пример #8
0
        public void GetSectionCount_ValidDocument_ReturnsValidCount()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            var actual = document.GetSectionCount();

            Assert.AreEqual(2, actual);
        }
Пример #9
0
        public void ReadUInt_ValidDocument_ReturnsValidUInt()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            uint actual = document.ReadUInt("Section", "uint", 0);

            Assert.AreEqual(4294967295, actual);
        }
Пример #10
0
        public void ReadInt_ValidDocument_ReturnsValidInt()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            int actual = document.ReadInt("Section", "int", 0);

            Assert.AreEqual(-2147483648, actual);
        }
Пример #11
0
        public void Load_ValidDocument_ValidSections()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            var expected = GetIniConfiguration();
            var actual   = ((FakeIniDocument)document).GetConfiguration();

            Assert.AreEqual(expected, actual);
        }
Пример #12
0
        public void WriteFloat_ValidFloat_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteDouble("Section", "float", 3.141592);
            document.Save(Arg.Any <string>());

            var expected = "[Section]\r\nfloat=3.141592\r\n\r\n";
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #13
0
        public void WriteBool_ValidBool_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteBool("Section", "bool", true);
            document.Save(Arg.Any <string>());

            var expected = "[Section]\r\nbool=True\r\n\r\n";
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #14
0
        public void WriteDecimal_ValidDecimal_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteDecimal("Section", "decimal", -99.999m);
            document.Save(Arg.Any <string>());

            var expected = "[Section]\r\ndecimal=-99.999\r\n\r\n";
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #15
0
        public void Save_ValidDocument_ValidSections()
        {
            IniDocument document = new FakeIniDocument();

            ((FakeIniDocument)document).SetConfiguration(GetIniConfiguration());
            document.Save(Arg.Any <string>());

            var expected = CreateIniString();
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #16
0
        public void WriteUInt_ValidUInt_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteUInt("Section", "uint", 4294967295);
            document.Save(Arg.Any <string>());

            var expected = "[Section]\r\nuint=4294967295\r\n\r\n";
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #17
0
        public void WriteInt_ValidInt_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteInt("Section", "int", -2147483648);
            document.Save(Arg.Any <string>());

            var expected = "[Section]\r\nint=-2147483648\r\n\r\n";
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #18
0
        public void WriteUShort_ValidUShort_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteUShort("Section", "ushort", 65535);
            document.Save(Arg.Any <string>());

            var expected = "[Section]\r\nushort=65535\r\n\r\n";
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #19
0
        public void WriteDouble_ValidDouble_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteDouble("Section", "double", 3.14159265359);
            document.Save(Arg.Any <string>());

            var expected = "[Section]\r\ndouble=3.14159265359\r\n\r\n";
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #20
0
        public void WriteSByte_ValidSByte_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteSByte("Section", "sbyte", -128);
            document.Save(Arg.Any <string>());

            var expected = "[Section]\r\nsbyte=-128\r\n\r\n";
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #21
0
        public void WriteString_ValidString_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteString("Section", "key", "value");
            document.Save(Arg.Any <string>());

            var expected = "[Section]\r\nkey=value\r\n\r\n";
            var actual   = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #22
0
        public void SortIni()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            document.SortIni();
            document.Save(Arg.Any <string>());

            var expected = ((FakeIniDocument)document).SavedIni;
            var actual   = CreateSortedIniString();

            Assert.AreEqual(expected, actual);
        }
Пример #23
0
        public void GetSections_ValidDocument_ReturnsValidSections()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            var actual = document.GetSections();

            var expected = new List <string> {
                "Section", "General"
            };

            Assert.AreEqual(expected, actual);
        }
Пример #24
0
        public void RemoveSection_ValidSection_RemovesSection()
        {
            IniDocument document = new FakeIniDocument();

            document.Load(CreateIniString());

            document.RemoveSection("Section");
            document.Save(Arg.Any <string>());

            var expected =
                "[General]\r\n" +
                "MagazineName=magazine.mgd\r\n" +
                "MagazinePath=C:\\magazine.mgd\r\n" +
                "LeadFrameName=leadframe.lfd\r\n" +
                "LeadFramePath=C:\\leadframe.lfd\r\n" +
                "\r\n";
            var actual = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }
Пример #25
0
        public void WriteString_MultipleSections_WritesToDocument()
        {
            IniDocument document = new FakeIniDocument();

            document.WriteString("Section", "key", "value");
            document.WriteString("Section", "test", "output");
            document.WriteString("Section9", "Lieutenant", "Daisuke Aramaki");
            document.WriteString("Section9", "Major", "Motoko Kusanagi");
            document.Save(Arg.Any <string>());

            var expected =
                "[Section]\r\n" +
                "key=value\r\n" +
                "test=output\r\n" +
                "\r\n" +
                "[Section9]\r\n" +
                "Lieutenant=Daisuke Aramaki\r\n" +
                "Major=Motoko Kusanagi\r\n" +
                "\r\n";
            var actual = ((FakeIniDocument)document).SavedIni;

            Assert.AreEqual(expected, actual);
        }