Exemple #1
0
        public void Test_Conv_ToObsInt()
        {
            int    a   = 17;
            ObsInt oiA = a;

            Assert.AreEqual(oiA.Value, a);
        }
Exemple #2
0
        public void Test_Conv_ToInt()
        {
            ObsInt oiA = new ObsInt(17);
            int    a   = oiA;

            Assert.AreEqual(oiA.Value, a);
        }
Exemple #3
0
        public void Test_Add_ObsInt_Int()
        {
            ObsInt oiA = new ObsInt(10);
            int    b   = 24;

            ObsInt oiC = oiA + b;

            Assert.AreEqual(34, oiC.Value);
        }
Exemple #4
0
        public void Test_Add_ObsInt_ObsInt()
        {
            ObsInt oiA = new ObsInt(10);
            ObsInt oiB = new ObsInt(24);

            ObsInt oiC = oiA + oiB;

            Assert.AreEqual(34, oiC.Value);
        }
Exemple #5
0
        public void Test_Assign_WithValue()
        {
            ObsInt oiA = new ObsInt(10);

            Assert.AreEqual(10, oiA.Value);

            oiA.Value = 22;
            Assert.AreEqual(22, oiA.Value);
        }
Exemple #6
0
        public void Test_Sub_ObsInt_ObsInt()
        {
            ObsInt oiA = new ObsInt(32);
            ObsInt oiB = new ObsInt(15);

            ObsInt oiC = oiA - oiB;

            Assert.AreEqual(17, oiC.Value);
        }
Exemple #7
0
        public void Test_Sub_ObsInt_Int()
        {
            ObsInt oiA = new ObsInt(32);
            int    b   = 15;

            ObsInt oiC = oiA - b;

            Assert.AreEqual(17, oiC.Value);
        }
Exemple #8
0
        public void Test_Mult_Int_ObsInt()
        {
            int    a   = 12;
            ObsInt oiB = new ObsInt(17);

            ObsInt oiC = a * oiB;

            Assert.AreEqual(204, oiC.Value);
        }
Exemple #9
0
        public void Test_Mult_ObsInt_Int()
        {
            ObsInt oiA = new ObsInt(12);
            int    b   = 17;

            ObsInt oiC = oiA * b;

            Assert.AreEqual(204, oiC.Value);
        }
Exemple #10
0
        public void Test_Mult_ObsInt_ObsInt()
        {
            ObsInt oiA = new ObsInt(12);
            ObsInt oiB = new ObsInt(17);

            ObsInt oiC = oiA * oiB;

            Assert.AreEqual(204, oiC.Value);
        }
Exemple #11
0
        public void Test_Add_Int_ObsInt()
        {
            int    a   = 10;
            ObsInt oiB = new ObsInt(24);

            ObsInt oiC = a + oiB;

            Assert.AreEqual(34, oiC.Value);
        }
Exemple #12
0
        public void Test_Sub_Int_ObsInt()
        {
            int    a   = 32;
            ObsInt oiB = new ObsInt(15);

            ObsInt oiC = a - oiB;

            Assert.AreEqual(17, oiC.Value);
        }
Exemple #13
0
        public void Test_Subscribe_OneSub_SubCreateAndSubscribe()
        {
            ObsInt    oiA  = new ObsInt(17);
            ObserverA obsA = new ObserverA();

            Assert.AreEqual(obsA.InitialState, obsA.State);

            oiA.Value = 22;
            Assert.AreEqual(obsA.InitialState, obsA.State);

            oiA.ValueChanged += obsA.MethodA;
            Assert.AreEqual(obsA.InitialState, obsA.State);
        }
Exemple #14
0
        public static ObsInt[][] ReadValueObsIntArray2(CsvSpreadSheet sheet, int index, string headerName)
        {
            int row    = sheet.GetRecord(index).StartRow;
            int column = sheet.GetHeaderRecord(headerName).Index;
            int len    = sheet.GetRecord(index).HeaderContentLength[column];

            ObsInt[][] result = new ObsInt[len][];

            for (int i = 0; i < len; i++)
            {
                result[i] = ParseObsIntArray(sheet.GetValue(i + row, column));
            }
            return(result);
        }
Exemple #15
0
        public void Test_Subscribe_TwoSub_Complete()
        {
            ObsInt    oiA  = new ObsInt(17);
            ObserverA obsA = new ObserverA();
            ObserverB obsB = new ObserverB();

            Assert.AreEqual(obsA.InitialState, obsA.State);
            Assert.AreEqual(obsB.InitialState, obsB.State);

            oiA.ValueChanged += obsA.MethodA;
            oiA.ValueChanged += obsB.MethodB;
            oiA.Value         = 35;
            Assert.AreEqual($"Value was updated to 35", obsA.State);
            Assert.AreEqual($"Value is now 35", obsB.State);
        }
Exemple #16
0
        public static ObsInt[]    ParseObsIntArray(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return(new ObsInt[0]);
            }
            var line = s.Split(new Char[] { '|', '#' });

            ObsInt[] result = new ObsInt[line.Length];

            for (int i = 0; i < line.Length; i++)
            {
                result[i] = ParseObsInt(line[i]);
            }
            return(result);
        }
Exemple #17
0
        public void Test_Subscribe_OneSub_Complete()
        {
            ObsInt    oiA  = new ObsInt(17);
            ObserverA obsA = new ObserverA();

            Assert.AreEqual(obsA.InitialState, obsA.State);

            oiA.Value = 22;
            Assert.AreEqual(obsA.InitialState, obsA.State);

            oiA.ValueChanged += obsA.MethodA;
            oiA.Value         = 35;
            Assert.AreNotEqual(obsA.InitialState, obsA.State);
            Assert.AreNotEqual($"Value was updated to 22", obsA.State);
            Assert.AreEqual($"Value was updated to 35", obsA.State);
        }
Exemple #18
0
        public static ObsInt[] ReadValueObsIntArrayLine(CsvSpreadSheet sheet, int index, string headerName)
        {
            int row    = sheet.GetRecord(index).StartRow;
            int column = sheet.GetHeaderRecord(headerName).Index;
            var v      = sheet.GetValue(row, column);

            string[] line;
            if (string.IsNullOrEmpty(v))
            {
                line = new string[0];
            }
            else
            {
                line = sheet.GetValue(row, column).Split(new Char[] { '|', '#' });
            }

            ObsInt[] result = new ObsInt[line.Length];

            for (int i = 0; i < line.Length; i++)
            {
                result[i] = ParseObsInt(line[i]);
            }
            return(result);
        }
Exemple #19
0
        public void Test_Create_WithValue()
        {
            ObsInt oiA = new ObsInt(12);

            Assert.AreEqual(12, oiA.Value);
        }
Exemple #20
0
        public void Test_Create_Default()
        {
            ObsInt oiA = new ObsInt();

            Assert.AreEqual(0, oiA.Value);
        }
Exemple #21
0
        public void Test_ToString()
        {
            ObsInt oiA = new ObsInt(17);

            Assert.AreEqual("17", oiA.ToString());
        }