public void TestSiteOptionMethodsInt() { Console.WriteLine("TestSiteOptionMethodsInt"); SiteOption soInt = new SiteOption(1, "sect", "name", "0", SiteOption.SiteOptionType.Int, "desc"); Assert.AreEqual(1, soInt.SiteId); Assert.AreEqual("sect", soInt.Section); Assert.AreEqual("name", soInt.Name); Assert.AreEqual(soInt.GetValueInt(), 0); Assert.IsFalse(soInt.IsTypeBool()); Assert.IsTrue(soInt.IsTypeInt()); try { soInt.GetValueBool(); } catch (SiteOptionInvalidTypeException ex) { Assert.AreEqual("Value is not a bool", ex.Message); } soInt.SetValueInt(1); Assert.AreEqual(1, soInt.GetValueInt()); soInt.SetValueInt(0); Assert.AreEqual(0, soInt.GetValueInt()); soInt.SetValueInt(int.MaxValue); Assert.AreEqual(int.MaxValue, soInt.GetValueInt()); soInt.SetValueInt(int.MinValue); Assert.AreEqual(int.MinValue, soInt.GetValueInt()); try { soInt.SetValueBool(false); } catch (SiteOptionInvalidTypeException ex) { Assert.AreEqual("Type is not a bool", ex.Message); } }
public void TestSiteOptionMethodsBool() { Console.WriteLine("TestSiteOptionMethodsBool"); SiteOption soBool = new SiteOption(1, "sect", "name", "0", SiteOption.SiteOptionType.Bool, "desc"); Assert.AreEqual(1, soBool.SiteId); Assert.AreEqual("sect", soBool.Section); Assert.AreEqual("name", soBool.Name); Assert.IsFalse(soBool.GetValueBool()); Assert.IsTrue(soBool.IsTypeBool()); Assert.IsFalse(soBool.IsTypeInt()); try { soBool.GetValueInt(); } catch (SiteOptionInvalidTypeException ex) { Assert.AreEqual("Value is not an int", ex.Message); } soBool = new SiteOption(1, "sect", "name", "1", SiteOption.SiteOptionType.Bool, "desc"); Assert.AreEqual(1, soBool.SiteId); Assert.AreEqual("sect", soBool.Section); Assert.AreEqual("name", soBool.Name); Assert.IsTrue(soBool.GetValueBool()); Assert.IsTrue(soBool.IsTypeBool()); Assert.IsFalse(soBool.IsTypeInt()); try { soBool.GetValueInt(); } catch (SiteOptionInvalidTypeException ex) { Assert.AreEqual("Value is not an int", ex.Message); } soBool.SetValueBool(true); Assert.IsTrue(soBool.GetValueBool()); soBool.SetValueBool(false); Assert.IsFalse(soBool.GetValueBool()); try { soBool.SetValueInt(42); } catch (SiteOptionInvalidTypeException ex) { Assert.AreEqual("Type is not an int", ex.Message); } }