public void APITest_restrictions_restrictionsAll_fail_unique() { string path = tmpFile("unique"); try { SkillFile sf = SkillFile.open(path, Mode.Create, Mode.Write); // create objects restrictionsAll.Operator op_2 = (restrictionsAll.Operator)sf.Operators().make(); restrictionsAll.Operator op_1 = (restrictionsAll.Operator)sf.Operators().make(); // set fields op_2.name = (string)"Minus"; op_1.name = (string)"Minus"; sf.close(); { // read back and assert correctness SkillFile sf2 = SkillFile.open(sf.currentPath(), Mode.Read, Mode.ReadOnly); // check count per Type Assert.AreEqual(2, sf.Operators().staticSize()); // create objects from file restrictionsAll.Operator op_2_2 = (restrictionsAll.Operator)sf2.Operators().getByID(op_2.SkillID); restrictionsAll.Operator op_1_2 = (restrictionsAll.Operator)sf2.Operators().getByID(op_1.SkillID); // assert fields Assert.IsTrue(op_2_2.name != null && op_2_2.name.Equals("Minus")); Assert.IsTrue(op_1_2.name != null && op_1_2.name.Equals("Minus")); } } catch (SkillException) { return; } File.Delete(path); }
/// <summary> /// Used for internal construction, full allocation. /// </summary> public Term(int skillID, System.Collections.ArrayList arguments, restrictionsAll.Operator Zoperator) : base(skillID) { this.arguments = arguments; this.Zoperator = Zoperator; }
public void APITest_core_restrictionsAll_acc_example() { string path = tmpFile("example"); SkillFile sf = SkillFile.open(path, Mode.Create, Mode.Write); // create objects restrictionsAll.Operator op = (restrictionsAll.Operator)sf.Operators().make(); restrictionsAll.RangeBoarderCases rbc = (restrictionsAll.RangeBoarderCases)sf.RangeBoarderCasess().make(); restrictionsAll.DefaultBoarderCases dbc = (restrictionsAll.DefaultBoarderCases)sf.DefaultBoarderCasess().make(); restrictionsAll.None none_obj = (restrictionsAll.None)sf.Nones().make(); restrictionsAll.ZSystem sys_obj = (restrictionsAll.ZSystem)sf.ZSystems().make(); restrictionsAll.Term trm = (restrictionsAll.Term)sf.Terms().make(); restrictionsAll.RegularProperty rp = (restrictionsAll.RegularProperty)sf.RegularPropertys().make(); restrictionsAll.Comment cmnt = (restrictionsAll.Comment)sf.Comments().make(); // set fields op.name = (string)"Minus"; rbc.negative = (int)0; rbc.negative2 = (long)0L; rbc.degrees2 = (double)(double)360; rbc.positive2 = (short)(short)0; rbc.positive = (sbyte)(sbyte)0; rbc.degrees = (float)(float)0; dbc.system = ([email protected])sys_obj; dbc.nopDefault = (long)0L; dbc.none = (Properties)none_obj; dbc.Zfloat = (float)(float)-1; dbc.message = (string)"Hello World!"; sys_obj.name = (string)"Hexadecimal"; sys_obj.version = (float)(float)1.1; trm.arguments = (System.Collections.ArrayList)array <Term>(trm, (Term)null); trm.Zoperator = (Operator)op; cmnt.property = (Properties)sys_obj; cmnt.text = (string)"A comment"; cmnt.target = ([email protected])op; sf.close(); { // read back and assert correctness SkillFile sf2 = SkillFile.open(sf.currentPath(), Mode.Read, Mode.ReadOnly); // check count per Type Assert.AreEqual(1, sf.DefaultBoarderCasess().staticSize()); Assert.AreEqual(1, sf.ZSystems().staticSize()); Assert.AreEqual(1, sf.Operators().staticSize()); Assert.AreEqual(1, sf.RangeBoarderCasess().staticSize()); Assert.AreEqual(1, sf.Comments().staticSize()); Assert.AreEqual(1, sf.Nones().staticSize()); Assert.AreEqual(1, sf.RegularPropertys().staticSize()); Assert.AreEqual(1, sf.Terms().staticSize()); // create objects from file restrictionsAll.Operator op_2 = (restrictionsAll.Operator)sf2.Operators().getByID(op.SkillID); restrictionsAll.RangeBoarderCases rbc_2 = (restrictionsAll.RangeBoarderCases)sf2.RangeBoarderCasess().getByID(rbc.SkillID); restrictionsAll.DefaultBoarderCases dbc_2 = (restrictionsAll.DefaultBoarderCases)sf2.DefaultBoarderCasess().getByID(dbc.SkillID); restrictionsAll.None none_obj_2 = (restrictionsAll.None)sf2.Nones().getByID(none_obj.SkillID); restrictionsAll.ZSystem sys_obj_2 = (restrictionsAll.ZSystem)sf2.ZSystems().getByID(sys_obj.SkillID); restrictionsAll.Term trm_2 = (restrictionsAll.Term)sf2.Terms().getByID(trm.SkillID); restrictionsAll.RegularProperty rp_2 = (restrictionsAll.RegularProperty)sf2.RegularPropertys().getByID(rp.SkillID); restrictionsAll.Comment cmnt_2 = (restrictionsAll.Comment)sf2.Comments().getByID(cmnt.SkillID); // assert fields Assert.IsTrue(op_2.name != null && op_2.name.Equals("Minus")); Assert.IsTrue(rbc_2.negative == 0); Assert.IsTrue(rbc_2.negative2 == 0L); Assert.IsTrue(rbc_2.degrees2 == (double)360); Assert.IsTrue(rbc_2.positive2 == (short)0); Assert.IsTrue(rbc_2.positive == (sbyte)0); Assert.IsTrue(rbc_2.degrees == (float)0); Assert.IsTrue(dbc_2.nopDefault == 0L); Assert.IsTrue(dbc_2.none == none_obj_2); Assert.IsTrue(dbc_2.Zfloat == (float)-1); Assert.IsTrue(dbc_2.message != null && dbc_2.message.Equals("Hello World!")); Assert.IsTrue(sys_obj_2.name != null && sys_obj_2.name.Equals("Hexadecimal")); Assert.IsTrue(sys_obj_2.version == (float)1.1); Assert.IsTrue(trm_2.arguments != null && ArrayListEqual(trm_2.arguments, array <Term>(trm_2, (Term)null))); Assert.IsTrue(trm_2.Zoperator == op_2); Assert.IsTrue(cmnt_2.property == sys_obj_2); Assert.IsTrue(cmnt_2.text != null && cmnt_2.text.Equals("A comment")); Assert.IsTrue(cmnt_2.target == op_2); } File.Delete(path); }