Пример #1
0
        public void Parser_GarbageValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing garbage
            string[] garbageValue = { "ASDAWDSD ASCAASASSSFVRSDFFSEFSEFSEFSFSEF;';';AASDASD>AS:>DPASDPA<S?><./,>?A<S?>D,/.,./?A>S<d  as.d,./sd ,as/.", "ASD##@$?>?SDF{++_#_@$)#+_)+_V VV   S FDF SDF location", "location: d233 2aSDASd,/.,/.as,d/.as,das][[[=--=[=-[=-[" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(garbageValue, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.IsTrue(!ownDevice.Orientation.HasValue);
        }
Пример #2
0
        public void Parser_CorrectInput()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing Correct Input
            string[] correctInput = { "location:2.0 2.0", "orientation:90.0" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(correctInput, ownDevice);

            Assert.AreEqual(ownDevice.Orientation.Value, 90.0);
            Assert.AreEqual(ownDevice.Location.Value.ToString(), new Point(2.0, 2.0).ToString());
        }
Пример #3
0
        public void Parser_EmptyFile()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing empty file
            string[] emptyFile = { };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(emptyFile, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.IsTrue(!ownDevice.Orientation.HasValue);
        }
Пример #4
0
        public void Parser_InvalidLeftSide()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing invalid left side
            string[] invalidLeftValue = { "funk rating:20.0", "value:off the charts" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(invalidLeftValue, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.IsTrue(!ownDevice.Orientation.HasValue);
        }
Пример #5
0
        public void Parser_SlightlyOffValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing slightly off formatting that should be acceptable
            string[] slightlyOffValue = { "location: \t2.0    2", "orientation:    \t 90.0" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(slightlyOffValue, ownDevice);

            //         Assert.AreEqual(ownDevice.Orientation.Value, 90.0);
            //         Assert.AreEqual(ownDevice.Location.Value.ToString(), new Point(2.0, 2.0).ToString());
        }
Пример #6
0
        public void Parser_SingleLocationValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing single value for location
            string[] singleValue = { "location:20.0", "orientation:90.0" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(singleValue, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.AreEqual(ownDevice.Orientation.Value, 90.0);
        }
Пример #7
0
        public void Parser_NegativeValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing negative values
            string[] negativeValue = { "location:" + Double.MinValue.ToString("R") + " " + Double.MinValue.ToString("R"), "orientation:" + Double.MinValue.ToString("R") };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(negativeValue, ownDevice);

            Assert.AreEqual(ownDevice.Location.Value.ToString(), new Point(Double.MinValue, Double.MinValue).ToString());
            Assert.AreEqual(ownDevice.Orientation.Value, Double.MinValue);
        }
Пример #8
0
        public void Parser_LargeValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing large values. toString("R") prevents weird rounding that causes overflow
            string[] largeValue = { "location:" + Double.MaxValue.ToString("R") + " " + Double.MaxValue.ToString("R"), "orientation:" + Double.MaxValue.ToString("R") };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(largeValue, ownDevice);

            Assert.AreEqual(ownDevice.Location.Value.ToString(), new Point(Double.MaxValue, Double.MaxValue).ToString());
            Assert.AreEqual(ownDevice.Orientation.Value, Double.MaxValue);
        }
Пример #9
0
        public void Parser_InvalidRightSide()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing a non double value
            string[] nonDoubleValue = { "location:POTATO POTATO", "orientation:HELLOWORLD" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(nonDoubleValue, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.IsTrue(!ownDevice.Orientation.HasValue);
        }