|
|
@@ -1,7 +1,9 @@
|
|
|
+using Quadarax.Application.QLiberace.Common.Settings;
|
|
|
using Quadarax.Application.QLiberace.Common.Tests.Settings.Fakes;
|
|
|
|
|
|
namespace Quadarax.Application.QLiberace.Common.Tests.Settings
|
|
|
{
|
|
|
+ [TestFixture(Category = "Dto")]
|
|
|
public class ModuleSettingsTest
|
|
|
{
|
|
|
private ModuleSettingFake _setting;
|
|
|
@@ -14,26 +16,56 @@ namespace Quadarax.Application.QLiberace.Common.Tests.Settings
|
|
|
_setting = new ModuleSettingFake();
|
|
|
}
|
|
|
|
|
|
- [Test]
|
|
|
- public void GetData()
|
|
|
+ [Test(TestOf = typeof(ModuleSetting))]
|
|
|
+ public void GetDataOk()
|
|
|
{
|
|
|
- //TODO: fix test
|
|
|
var data = _setting.GetData().ToArray();
|
|
|
|
|
|
Assert.That(data.Length, Is.EqualTo(7));
|
|
|
- CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyString1", string.Empty, ModuleSettingFake.DefPropertyString1));
|
|
|
- CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyString2", string.Empty, ModuleSettingFake.DefPropertyString2));
|
|
|
- CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyDateTime1", string.Empty, string.IsNullOrEmpty(ModuleSettingFake.DefPropertyDateTime1String)
|
|
|
+ CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyString1", "System.String", ModuleSettingFake.DefPropertyString1));
|
|
|
+ CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyString2", "System.String", ModuleSettingFake.DefPropertyString2));
|
|
|
+ CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyDateTime1", "System.DateTime", string.IsNullOrEmpty(ModuleSettingFake.DefPropertyDateTime1String)
|
|
|
? (DateTime?)null
|
|
|
: DateTime.Parse(ModuleSettingFake.DefPropertyDateTime1String!)));
|
|
|
- CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyDateTime2", string.Empty, string.IsNullOrEmpty(ModuleSettingFake.DefPropertyDateTime2String)
|
|
|
+ CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyDateTime2", "System.DateTime", string.IsNullOrEmpty(ModuleSettingFake.DefPropertyDateTime2String)
|
|
|
? (DateTime?)null
|
|
|
: DateTime.Parse(ModuleSettingFake.DefPropertyDateTime2String!)));
|
|
|
- CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyTimeSpan", string.Empty, string.IsNullOrEmpty(ModuleSettingFake.DefPropertyTimeSpanString)
|
|
|
+ CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyTimeSpan", "System.TimeSpan", string.IsNullOrEmpty(ModuleSettingFake.DefPropertyTimeSpanString)
|
|
|
? (TimeSpan?)null
|
|
|
: TimeSpan.Parse(ModuleSettingFake.DefPropertyTimeSpanString!)));
|
|
|
- CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyInt", string.Empty, ModuleSettingFake.DefPropertyInt));
|
|
|
- CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyBool", string.Empty, ModuleSettingFake.DefPropertyBool));
|
|
|
+ CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyInt", "System.Int32", ModuleSettingFake.DefPropertyInt));
|
|
|
+ CollectionAssert.Contains(data,new Tuple<string, string, object?>("PropertyBool", "System.Boolean", ModuleSettingFake.DefPropertyBool));
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test(TestOf = typeof(ModuleSetting))]
|
|
|
+ public void SetDataOk()
|
|
|
+ {
|
|
|
+ var data = new[]
|
|
|
+ {
|
|
|
+ new Tuple<string, string, object?>("PropertyString1", "System.String",
|
|
|
+ ModuleSettingFake.DefPropertyString1),
|
|
|
+ new Tuple<string, string, object?>("PropertyString2", "System.String",
|
|
|
+ ModuleSettingFake.DefPropertyString2),
|
|
|
+ new Tuple<string, string, object?>("PropertyDateTime1", "System.DateTime",
|
|
|
+ string.IsNullOrEmpty(ModuleSettingFake.DefPropertyDateTime1String)
|
|
|
+ ? (DateTime?)null
|
|
|
+ : DateTime.Parse(ModuleSettingFake.DefPropertyDateTime1String!)),
|
|
|
+ new Tuple<string, string, object?>("PropertyDateTime2", "System.DateTime",
|
|
|
+ string.IsNullOrEmpty(ModuleSettingFake.DefPropertyDateTime2String)
|
|
|
+ ? (DateTime?)null
|
|
|
+ : DateTime.Parse(ModuleSettingFake.DefPropertyDateTime2String!)),
|
|
|
+ new Tuple<string, string, object?>("PropertyTimeSpan", "System.TimeSpan",
|
|
|
+ string.IsNullOrEmpty(ModuleSettingFake.DefPropertyTimeSpanString)
|
|
|
+ ? (TimeSpan?)null
|
|
|
+ : TimeSpan.Parse(ModuleSettingFake.DefPropertyTimeSpanString!)),
|
|
|
+ new Tuple<string, string, object?>("PropertyInt", "System.Int32", ModuleSettingFake.DefPropertyInt),
|
|
|
+ new Tuple<string, string, object?>("PropertyBool", "System.Boolean", ModuleSettingFake.DefPropertyBool)
|
|
|
+ };
|
|
|
+
|
|
|
+ _setting.Clear();
|
|
|
+ _setting.SetData(data);
|
|
|
+ var newSettings = new ModuleSettingFake();
|
|
|
+ Assert.That(_setting,Is.EqualTo(newSettings));
|
|
|
}
|
|
|
}
|
|
|
}
|