Skip to content

Commit

Permalink
Merge pull request #14 from Szpi/Settings
Browse files Browse the repository at this point in the history
Settings
  • Loading branch information
Szpi authored Jul 21, 2018
2 parents 52f0122 + 19995d5 commit c1a957e
Show file tree
Hide file tree
Showing 64 changed files with 889 additions and 154 deletions.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Add code that you are using ( configuration class, invoking and creating IniWrapper)
2. If possible please add ini file if you are loading configuration

**Expected behavior**
A clear and concise description of what you expected to happen.

**Desktop (please complete the following information):**
- Version [e.g. 22]
- Version [e.g. 1.0.0]

**Additional context**
Add any other context about the problem here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace IniWrapper.IntegrationTests.Main.Configuration.Properties
{
public class ComplexNullConfiguration
{
public NullableConfiguration NullableConfiguration { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;

namespace IniWrapper.IntegrationTests.Main.Configuration.Properties
{
public static class DefaultValuesConfigurationConsts
{
public const int DefaultInt = 100;
public const string DefaultString = "StringDefault";
public const string DefaultList = "10,11,12,13";
}
public class DefaultValuesConfiguration
{
public int DefaultInt { get; set; } = DefaultValuesConfigurationConsts.DefaultInt;
public string DefaultString { get; set; } = DefaultValuesConfigurationConsts.DefaultString;
public List<int> DefaultList { get; set; } = new List<int>() { 10, 11, 12, 13 };
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace IniWrapper.IntegrationTests.Main.Configuration.Properties
{
public class TwoDepthNullComplexConfiguration
{
public ComplexNullConfiguration ComplexTestConfiguration { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class IniIgnoreReadAttributeTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class IniOptionsAttributeReadTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class IniOptionsOnlyKeyAttributeReadTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class IniOptionsOnlySectionAttributeReadTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace IniWrapper.IntegrationTests.Main.Read.Fields
{
[TestFixture]
public class IniParserComplexDataSavePropertiesTests
public class IniWrapperComplexDataSavePropertiesTests
{
private IIniWrapper _iniWrapper;

Expand All @@ -20,7 +20,7 @@ public class IniParserComplexDataSavePropertiesTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace IniWrapper.IntegrationTests.Main.Read.Fields
{
[TestFixture]
public class IniParserIEnumerableOfComplexDataTests
public class IniWrapperIEnumerableOfComplexDataTests
{
private IIniWrapper _iniWrapper;

Expand All @@ -21,15 +21,15 @@ public class IniParserIEnumerableOfComplexDataTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
public void SaveConfiguration_ShouldThrowException_WhenConfigurationHasCollectionOfComplexType()
{
Action loadConfiguration = () => _iniWrapper.LoadConfiguration<ListOfComplesDataConfigurationField>();

loadConfiguration.Should().Throw<CollectionOfCopmexTypeException>();
loadConfiguration.Should().Throw<CollectionOfComplexTypeException>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace IniWrapper.IntegrationTests.Main.Read.Fields
{
[TestFixture]
public sealed class IniParserReadFieldsConfigurationTests
public sealed class IniWrapperReadFieldsConfigurationTests
{
private IIniWrapper _iniWrapper;

Expand All @@ -21,7 +21,7 @@ public sealed class IniParserReadFieldsConfigurationTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace IniWrapper.IntegrationTests.Main.Read.Properties
{
[TestFixture]
public class IniParserComplexDataReadPropertiesTests
public class IniWrapperComplexDataReadPropertiesTests
{
private IIniWrapper _iniWrapper;

Expand All @@ -20,7 +20,7 @@ public class IniParserComplexDataReadPropertiesTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace IniWrapper.IntegrationTests.Main.Read.Properties
{
[TestFixture]
public class IniParserIEnumerableNullableTests
public class IniWrapperIEnumerableNullableTests
{
private IIniWrapper _iniWrapper;

Expand All @@ -20,7 +20,7 @@ public class IniParserIEnumerableNullableTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace IniWrapper.IntegrationTests.Main.Read.Properties
{
[TestFixture]
public class IniParserIEnumerableReadingOfComplexDataTests
public class IniWrapperIEnumerableReadingOfComplexDataTests
{
private IIniWrapper _iniWrapper;

Expand All @@ -21,15 +21,15 @@ public class IniParserIEnumerableReadingOfComplexDataTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
public void LoadConfiguration_ShouldThrowException_WhenConfigurationHasCollectionOfComplexType()
{
Action loadConfiguration = () => _iniWrapper.LoadConfiguration<ListOfComplexDataConfiguration>();

loadConfiguration.Should().Throw<CollectionOfCopmexTypeException>();
loadConfiguration.Should().Throw<CollectionOfComplexTypeException>();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Collections.Generic;
using FluentAssertions;
using IniWrapper.IntegrationTests.Main.Configuration.Properties;
using IniWrapper.IntegrationTests.MockParser;
using IniWrapper.ParserWrapper;
using IniWrapper.Wrapper;
using NSubstitute;
using NUnit.Framework;

namespace IniWrapper.IntegrationTests.Main.Read.Properties
{
[TestFixture]
public class IniWrapperReadDefaultValuesTests
{
private IIniWrapper _iniWrapper;

private IIniParser _iniParser;

[SetUp]
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
public void SaveConfiguration_ShouldSaveCorrectDefaultValues()
{
var result = _iniWrapper.LoadConfiguration<DefaultValuesConfiguration>();

result.DefaultInt.Should().Be(DefaultValuesConfigurationConsts.DefaultInt);
result.DefaultString.Should().Be(DefaultValuesConfigurationConsts.DefaultString);
result.DefaultList.Should().BeEquivalentTo(new List<int> { 10, 11, 12, 13 });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace IniWrapper.IntegrationTests.Main.Read.Properties
{
[TestFixture]
public class IniParserReadDictionaryTests
public class IniWrapperReadDictionaryTests
{
private IIniWrapper _iniWrapper;

Expand All @@ -20,7 +20,7 @@ public class IniParserReadDictionaryTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace IniWrapper.IntegrationTests.Main.Read.Properties
{
[TestFixture]
public class IniParserReadPropertiesConfigurationTests
public class IniWrapperReadPropertiesConfigurationTests
{
private IIniWrapper _iniWrapper;

Expand All @@ -20,7 +20,7 @@ public class IniParserReadPropertiesConfigurationTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using FluentAssertions;
using IniWrapper.IntegrationTests.Main.Configuration.Properties;
using IniWrapper.IntegrationTests.MockParser;
using IniWrapper.ParserWrapper;
using IniWrapper.Wrapper;
using NSubstitute;
using NUnit.Framework;

namespace IniWrapper.IntegrationTests.Main.Read.WrongFormat
{
[TestFixture]
public class ReadingEnumOutOfRangeTests
{
private IIniWrapper _iniWrapper;

private IIniParser _iniParser;

[SetUp]
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
public void LoadConfiguration_CorrectEnumOutOfRange()
{
_iniParser.Read(nameof(TestConfiguration), nameof(TestConfiguration.TestEnum)).Returns("1000");

var result = _iniWrapper.LoadConfiguration<TestConfiguration>();

result.TestEnum.Should().Be((TestEnum)1000);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace IniWrapper.IntegrationTests.Main.Read.WrongFormat
{
public class ReadingWrongFormattedIni
public class ReadingWrongFormattedIniTests
{
private IIniWrapper _iniWrapper;

Expand All @@ -20,7 +20,7 @@ public class ReadingWrongFormattedIni
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = MockParserFactory.CreateWithFileSystem(_iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using IniWrapper.IntegrationTests.Main.Configuration.Attribute.Ignore;
using IniWrapper.IntegrationTests.MockParser;
using IniWrapper.ParserWrapper;
using IniWrapper.Wrapper;
using NSubstitute;
Expand All @@ -17,7 +18,7 @@ public class IniIgnoreAttributeTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = new IniWrapperFactory().Create("", _iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using IniWrapper.IntegrationTests.Main.Configuration.Attribute.Save;
using IniWrapper.IntegrationTests.Main.Configuration.Properties;
using IniWrapper.IntegrationTests.MockParser;
using IniWrapper.ParserWrapper;
using IniWrapper.Wrapper;
using NSubstitute;
Expand All @@ -19,7 +20,7 @@ public class IniOptionsAttributeTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = new IniWrapperFactory().Create("", _iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using IniWrapper.IntegrationTests.Main.Configuration.Attribute.Save;
using IniWrapper.IntegrationTests.Main.Configuration.Properties;
using IniWrapper.IntegrationTests.MockParser;
using IniWrapper.ParserWrapper;
using IniWrapper.Wrapper;
using NSubstitute;
Expand All @@ -19,7 +20,7 @@ public class IniOptionsOnlyKeyAttributeTests
public void SetUp()
{
_iniParser = Substitute.For<IIniParser>();
_iniWrapper = new IniWrapperFactory().Create("", _iniParser);
_iniWrapper = MockWrapperFactory.CreateWithFileSystem(_iniParser);
}

[Test]
Expand Down
Loading

0 comments on commit c1a957e

Please sign in to comment.