Beispiel #1
0
        public void TestEquals()
        {
            // double
            bool expectedBoolean = false;
            bool resultBoolean = false;
            EcellData data1 = new EcellData("Value", new EcellValue(1), "Variable:/:Test:Value");
            EcellData data2 = new EcellData("Value1", new EcellValue(1), "Variable:/:Test:Value");
            EcellData data3 = new EcellData("Value", new EcellValue(2), "Variable:/:Test:Value");
            EcellData data4 = new EcellData("Value", new EcellValue(1), "Variable:/:Test:Test");
            EcellData data5 = new EcellData("Value", new EcellValue(1), "Variable:/:Test:Value");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data2);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data3);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data4);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = true;
            resultBoolean = data1.Equals(data5);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            // double
            data1 = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");
            data2 = new EcellData("Value1", new EcellValue(0.1), "Variable:/:Test:Value");
            data3 = new EcellData("Value", new EcellValue(0.2), "Variable:/:Test:Value");
            data4 = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Test");
            data5 = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data2);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data3);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data4);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = true;
            resultBoolean = data1.Equals(data5);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            // string
            data1 = new EcellData("Value", new EcellValue("Test"), "Variable:/:Test:Value");
            data2 = new EcellData("Value1", new EcellValue("Test"), "Variable:/:Test:Value");
            data3 = new EcellData("Value", new EcellValue("Test2"), "Variable:/:Test:Value");
            data4 = new EcellData("Value", new EcellValue("Test"), "Variable:/:Test:Test");
            data5 = new EcellData("Value", new EcellValue("Test"), "Variable:/:Test:Value");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data2);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data3);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data4);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = true;
            resultBoolean = data1.Equals(data5);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            // List
            List<object> list1 = new List<object>();
            list1.Add("Test1");
            EcellValue value1 = new EcellValue(list1);
            List<object> list2 = new List<object>();
            list2.Add("Test2");
            EcellValue value2 = new EcellValue(list2);

            data1 = new EcellData("Value", value1.Clone(), "Variable:/:Test:Value");
            data2 = new EcellData("Value1", value1.Clone(), "Variable:/:Test:Value");
            data3 = new EcellData("Value", value2.Clone(), "Variable:/:Test:Value");
            data4 = new EcellData("Value", value1.Clone(), "Variable:/:Test:Test");
            data5 = new EcellData("Value", value1.Clone(), "Variable:/:Test:Value");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data2);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data3);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(data4);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = true;
            resultBoolean = data1.Equals(data5);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            expectedBoolean = false;
            resultBoolean = data1.Equals(new object());
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            EcellData data6 = data1.Clone();
            //object obj = null;
            //data6.Value = new EcellValue(obj);
            //expectedBoolean = false;
            //resultBoolean = data1.Equals(data6);
            //Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");
            //resultBoolean = data6.Equals(data1);
            //Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6.Value = null;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");
            resultBoolean = data6.Equals(data1);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Gettable = false;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Loadable = false;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Logable = true;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Logged = true;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Saveable = false;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");

            data6 = data1.Clone();
            data6.Settable = false;
            expectedBoolean = false;
            resultBoolean = data1.Equals(data6);
            Assert.AreEqual(expectedBoolean, resultBoolean, "Equals method returned unexpected result.");
        }
Beispiel #2
0
        public void TestGetHashCode()
        {
            EcellData data = new EcellData();
            EcellData dataCopy = data.Clone();
            Assert.AreEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            data = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");
            dataCopy = data.Clone();
            Assert.AreEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            // NotEqual
            dataCopy = data.Clone();
            dataCopy.Gettable = false;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Settable = false;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Loadable = false;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Saveable = false;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Logable = true;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Logged = true;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Name = "Test";
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Name = null;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.EntityPath = "Variable:/:Test:Test";
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.EntityPath = null;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Value = new EcellValue(0);
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");

            dataCopy = data.Clone();
            dataCopy.Value = null;
            Assert.AreNotEqual(data.GetHashCode(), dataCopy.GetHashCode(), "TestGetHashCode method returned unexpected result.");
        }
Beispiel #3
0
        public void TestClone()
        {
            EcellData data1 =new EcellData();
            EcellData data1Copy = data1.Clone();
            Assert.AreEqual(data1, data1Copy, "Clone method returned unexpected result.");

            EcellData data2 = new EcellData("Value", new EcellValue(0.1), "Variable:/:Test:Value");
            EcellData data2Copy = data2.Clone();
            Assert.AreEqual(data2, data2Copy, "Clone method returned unexpected result.");

            object obj = ((ICloneable)data1).Clone();
            Assert.AreEqual(data1, obj, "Clone method returned unexpected result.");

            obj = ((ICloneable)data2).Clone();
            Assert.AreEqual(data2, obj, "Clone method returned unexpected result.");
        }