| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- 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));
- }
- }
- }
|