Esempio n. 1
0
        private void PerformTestsForWorldspaceProject(WorldspaceProject project)
        {
            Console.WriteLine("Performing tests on {0}", project.Name);

            foreach (ZArchive archive in project.GetAllArchives())
            {
                WindWakerEntityData data = archive.GetFileByType <WindWakerEntityData>();
                if (data == null)
                {
                    continue;
                }

                foreach (List <WindWakerEntityData.BaseChunk> chunkList in data.GetAllChunks().Values)
                {
                    int chunkId = 0;
                    foreach (WindWakerEntityData.BaseChunk chunk in chunkList)
                    {
                        foreach (FieldInfo field in chunk.GetType().GetFields())
                        {
                            UnitTestValue attribute = (UnitTestValue)Attribute.GetCustomAttribute(field, typeof(UnitTestValue));
                            if (attribute != null)
                            {
                                object testValue   = field.GetValue(chunk);
                                object attribValue = attribute.Value;

                                bool bEquals = attribValue.Equals(testValue);
                                if (bEquals)
                                {
                                    continue;
                                }

                                //If they're not equals, we're going to want to print them to disk.
                                string failureText = string.Format("{0}|{1} #{2} failed. Field \"{5}\" Expected: {3} Got: {4}", project.Name, chunk.ChunkName, chunkId, attribValue, testValue, field.Name);
                                File.AppendAllText(_outputDir + "//results.txt", failureText + Environment.NewLine);
                            }
                        }

                        chunkId++;
                    }
                }
            }
        }
Esempio n. 2
0
        private void UpdateProjectFolderTreeview()
        {
            ProjectTreeview.BeginUpdate();
            ProjectTreeview.SuspendLayout();
            ProjectTreeview.Nodes.Clear();

            //Early out if the worldspace project is null (ie: We just unloaded the project)
            if (_loadedWorldspaceProject == null)
            {
                ProjectTreeview.EndUpdate();
                ProjectTreeview.ResumeLayout();
                return;
            }

            foreach (ZArchive archive in _loadedWorldspaceProject.GetAllArchives())
            {
                TreeNode arcRoot = ProjectTreeview.Nodes.Add(archive.Name, archive.Name);
                foreach (BaseArchiveFile archiveFile in archive.GetAllFiles())
                {
                    //Multiple files can share the same folder, so either find a node with the existing folder name or make a new one if it doesn't exist yet.
                    TreeNode folderNode = !arcRoot.Nodes.ContainsKey(archiveFile.FolderName) ? arcRoot.Nodes.Add(archiveFile.FolderName, archiveFile.FolderName) : arcRoot.Nodes.Find(archiveFile.FolderName, false)[0];

                    TreeNode fileName = folderNode.Nodes.Add(archiveFile.FileName);
                    fileName.Tag = archiveFile; //Store a reference to the archive file so we can get it later.

                    if (archiveFile is WindWakerEntityData && _selectedEntityFile == null)
                    {
                        _selectedEntityFile = (WindWakerEntityData)archiveFile;
                        UpdateLayersView(); //Updates the Entityview for us.

                        if (SelectedEntityFileChanged != null)
                        {
                            SelectedEntityFileChanged((WindWakerEntityData)archiveFile);
                        }
                    }
                }
            }

            ProjectTreeview.ResumeLayout();
            ProjectTreeview.EndUpdate();
        }
Esempio n. 3
0
        private void PerformTestsForWorldspaceProject(WorldspaceProject project)
        {
            Console.WriteLine("Performing tests on {0}", project.Name);

            foreach (ZArchive archive in project.GetAllArchives())
            {
                WindWakerEntityData data = archive.GetFileByType<WindWakerEntityData>();
                if (data == null)
                    continue;

                foreach (List<WindWakerEntityData.BaseChunk> chunkList in data.GetAllChunks().Values)
                {
                    int chunkId = 0;
                    foreach (WindWakerEntityData.BaseChunk chunk in chunkList)
                    {
                        foreach (FieldInfo field in chunk.GetType().GetFields())
                        {
                            UnitTestValue attribute = (UnitTestValue)Attribute.GetCustomAttribute(field, typeof(UnitTestValue));
                            if (attribute != null)
                            {
                                object testValue = field.GetValue(chunk);
                                object attribValue = attribute.Value;

                                bool bEquals = attribValue.Equals(testValue);
                                if (bEquals)
                                    continue;

                                //If they're not equals, we're going to want to print them to disk.
                                string failureText = string.Format("{0}|{1} #{2} failed. Field \"{5}\" Expected: {3} Got: {4}", project.Name, chunk.ChunkName, chunkId, attribValue, testValue, field.Name);
                                File.AppendAllText(_outputDir + "//results.txt", failureText + Environment.NewLine);
                            }
                        }

                        chunkId++;
                    }
                    
                }

            }
        }