| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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;
- [SetUp]
- public void Setup()
- {
- _setting = new ModuleSettingFake();
- }
- [Test(TestOf = typeof(ModuleSetting))]
- public void GetDataOk()
- {
- var data = _setting.GetData().ToArray();
- Assert.That(data.Length, Is.EqualTo(7));
- 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", "System.DateTime", string.IsNullOrEmpty(ModuleSettingFake.DefPropertyDateTime2String)
- ? (DateTime?)null
- : DateTime.Parse(ModuleSettingFake.DefPropertyDateTime2String!)));
- 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", "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));
- }
- [Test(TestOf = typeof(ModuleSetting))]
- public void GetSetIntegrityOk()
- {
- var now = DateTime.Now;
- var intv = 22;
- var stringv = "this is a test";
- _setting.PropertyDateTime2 = now;
- _setting.PropertyDateTime1 = now;
- _setting.PropertyInt = intv;
- _setting.PropertyString2 = stringv;
- var data = _setting.GetData();
- var settings = new ModuleSettingFake();
- settings.SetData(data);
- Assert.That(settings.PropertyDateTime2,Is.EqualTo(_setting.PropertyDateTime2));
- Assert.That(settings.PropertyDateTime1,Is.EqualTo(_setting.PropertyDateTime1));
- Assert.That(settings.PropertyInt,Is.EqualTo(_setting.PropertyInt));
- Assert.That(settings.PropertyString2,Is.EqualTo(_setting.PropertyString2));
- }
- }
- }
|