public void Well_Has_Invalid_Name()
        {
            ApplicationServices appServ = new ApplicationServices();
            Well b = new Well("Well B", new Point(2, 2), new Point(1, 1));

            appServ.AddWell(b);
            Well c = new Well("Well B", new Point(5, 5), new Point(1, 1));

            appServ.AddWell(c);
        }
        public void Well_Is_Invalid_Location()
        {
            ApplicationServices appServ = new ApplicationServices();
            Well d = new Well("Well D", new Point(130, 130), new Point(1, 1));

            appServ.AddWell(d);
            Well e = new Well("Well E", new Point(130, 130), new Point(1, 1));

            appServ.AddWell(e);
        }
        public void Well_Has_Valid_Name_Across_Groups()
        {
            ApplicationServices appServ = new ApplicationServices();
            Group x = new Group("Group X", new Point(110, 110), 1);
            Well  a = new Well("Well A", new Point(110, 110), new Point(1, 1));
            Group y = new Group("Group Y", new Point(120, 120), 1);
            Well  b = new Well("Well A", new Point(120, 120), new Point(1, 1));

            try {
                appServ.AddGroup(x);
                appServ.AddGroup(y);
                appServ.AddWell(a);
                appServ.AddWell(b);
            }catch (Exception e) {
                Assert.Fail("Expected no error, got " + e.Message);
            }
        }
        public void Well_Is_Added()
        {
            ApplicationServices appServ = new ApplicationServices();
            Well a = new Well("Well A", new Point(1, 1), new Point(1, 1));

            appServ.AddWell(a);
            int expected = 1;
            int actual   = appServ.GetWells().Count;

            Assert.AreEqual(expected, actual);
        }
        public void Well_Is_Orphan()
        {
            ApplicationServices appServ = new ApplicationServices();
            Well x = new Well("Well X", new Point(1000, 1000), new Point(1, 1));

            appServ.AddWell(x);
            bool expected = true;
            bool actual   = x.GetUniqueName().Contains("Orphan");

            Assert.AreEqual(expected, actual);
        }
        public void Well_Belong_To_Group()
        {
            ApplicationServices appServ = new ApplicationServices();
            Group zed = new Group("Group Z", new Point(1010, 1010), 1);

            appServ.AddGroup(zed);
            Well z = new Well("Well Z", new Point(1010, 1010), new Point(1, 1));

            appServ.AddWell(z);
            bool expected = true;
            bool actual   = z.GetUniqueName().Contains("Group Z");

            Assert.AreEqual(expected, actual);
        }
        public void Orphan_Well_Is_Reassigned()
        {
            ApplicationServices appServ = new ApplicationServices();
            Well g = new Well("Well G", new Point(2000, 2000), new Point(1, 1));

            appServ.AddWell(g);
            Group ge = new Group("Group G", new Point(2000, 2000), 1);

            appServ.AddGroup(ge);
            appServ.CheckOrphanWells();

            bool expected = true;
            bool actual   = g.GetUniqueName().Contains("Group G");

            Assert.AreEqual(expected, actual);
        }
Beispiel #8
0
        /// <summary>
        /// Loop through each index in wIndex, using it to access specific elements in the lines array. Although this is theoretically a O(n) operation in practice it should be
        /// faster than loop through every line in the lines array. After a line is accessed it is split using the passed delimiter and the arguments are fed to the factory
        /// to create a Well object, the object is then passed to the service layer to be persisted and the operation is logged.
        /// </summary>
        /// <param name="lines">The array containing all the lines read from the input file</param>
        /// <param name="delimiter">The delimiter used in the file</param>
        /// <param name="wIndexs">A list containing the indexes from the lines that describe Well objects</param>
        private static void CreateWells(String[] lines, char delimiter, List <int> wIndexs)
        {
            ApplicationServices appServ = new ApplicationServices();
            Logger logger = Logger.GetInstance();

            foreach (int i in wIndexs)
            {
                //Split the line with the given delimiter, isolation the potential object's attributes
                String[] args = lines[i].Split(delimiter);
                if (String.Equals(args[0], "Well", StringComparison.OrdinalIgnoreCase))
                {
                    try {
                        Well w = Factory.CreateWell(args);
                        appServ.AddWell(w);
                        logger.add(lines[i], "Loaded successfully");
                    } catch (CustomException e) {
                        logger.add(lines[i], e.Message);
                    }
                }
            }
        }