Beispiel #1
0
        public void GetFullPath_ShouldReturnPathWhenItIsParent(IStructure obj, string expectedPath)
        {
            //Arrange

            //Act
            string pathResult = obj.GetFullPath();

            //Assert
            Assert.Equal(expectedPath, pathResult);
        }
Beispiel #2
0
        public void GetFullPath_ShouldReturnPathWhenHasParent(Subsystem parent, IStructure obj, string expectedPath)
        {
            //Arrange

            //Act
            parent.AddChild(obj);
            string pathResult = obj.GetFullPath();

            //Assert
            Assert.Equal(expectedPath, pathResult);
        }
Beispiel #3
0
        public void GenerateDataTable(IStructure structure)
        {
            _gridSource = new DataTable();
            bool _isarchive = HasArchives(structure);

            _gridSource.Columns.Add("Name", typeof(string));
            _gridSource.Columns.Add("RAM", typeof(int));
            if (!_isarchive)
            {
                _gridSource.Columns.Add("Section Name", typeof(string));
                _gridSource.Columns.Add("Address", typeof(long));
            }
            else
            {
                _gridSource.Columns.Add("Usage", typeof(string));
                _gridSource.Columns.Add("Budget", typeof(string));
                _gridSource.Columns.Add("Size", typeof(string));
            }

            if (_isarchive)
            {
                Random  rnd   = new Random();
                int     usage = 0;
                DataRow _frow = _gridSource.NewRow();
                _frow["Name"]   = "TOTAL";
                _frow["RAM"]    = structure.Size;
                _frow["Usage"]  = usage.ToString() + "%";
                _frow["Budget"] = -1;
                _frow["Size"]   = -1;
                _gridSource.Rows.Add(_frow);

                var containers = structure.Children.Where(c => !(c is Section));
                foreach (IStructure child in containers)
                {
                    DataRow _drow = _gridSource.NewRow();
                    _drow["Name"] = child.Name;
                    _drow["RAM"]  = child.Size;
                    int localUsage = rnd.Next(1, 150);
                    usage          += localUsage;
                    _drow["Usage"]  = localUsage.ToString() + "%";
                    _drow["Budget"] = -1;
                    _drow["Size"]   = -1;
                    _gridSource.Rows.Add(_drow);
                }
                _gridSource.Rows[0].SetField("Usage", usage.ToString() + "%");
            }
            else
            {
                DataRow _drow = _gridSource.NewRow();
                _drow["Name"]         = "TOTAL";
                _drow["RAM"]          = structure.Size;
                _drow["Section Name"] = structure.Name;
                if ((structure as Section) != null)
                {
                    _drow["Address"] = (structure as Section).Address;
                }
                _gridSource.Rows.Add(_drow);

                var sections = structure.Children.Where(c => c is Section);
                foreach (Section child in sections)
                {
                    _drow                 = _gridSource.NewRow();
                    _drow["Name"]         = child.Name;
                    _drow["RAM"]          = child.Size;
                    _drow["Section Name"] = child.Name;
                    _drow["Address"]      = child.Address;
                    _gridSource.Rows.Add(_drow);
                }
            }
            Path = structure.GetFullPath();

            OnPropertyChanged("GridSourceDataTable");
        }