Skip to content
This repository has been archived by the owner on Aug 7, 2022. It is now read-only.

Commit

Permalink
Disabled CSharp test, moved testing to the example
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Nov 30, 2019
1 parent 2d51030 commit 0cf8460
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 8 deletions.
1 change: 1 addition & 0 deletions OMODFramework.Example/OMODFramework.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScriptFunctions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
9 changes: 4 additions & 5 deletions OMODFramework.Example/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
using System.Reflection;

namespace OMODFramework.Example
Expand All @@ -9,15 +8,15 @@ internal class Program
private static void Main(string[] args)
{
// set the temp folder if you don't want it at %temp%/OMODFramework/
Framework.TempDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
Framework.TempDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestTempDir");

var omod = new OMOD("DarNified UI 1.3.2.omod");

var data = omod.GetDataFiles(); // extracts all data files
var plugins = omod.GetPlugins(); // extracts all plugins

Console.WriteLine($"Data files: {data}");
Console.WriteLine($"Plugins: {plugins}");
var scriptFunctions = new ScriptFunctions();
omod.RunScript(scriptFunctions, data, plugins);
}
}
}
149 changes: 149 additions & 0 deletions OMODFramework.Example/ScriptFunctions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
using System;
using System.Collections.Generic;
using OMODFramework.Scripting;

namespace OMODFramework.Example
{
public class ScriptFunctions : IScriptFunctions //IMPORTANT: DO NOT USE OblivionModManager.Scripting.IScriptFunctions
{
public void Warn(string msg)
{
Console.WriteLine($"[Warning]: {msg}");
}

public void Message(string msg)
{
Console.WriteLine($"[Message]: {msg}");
}

public void Message(string msg, string title)
{
Console.WriteLine($"[Message]: {title} - {msg}");
}

public List<int> Select(List<string> items, string title, bool isMultiSelect, List<string> previews, List<string> descriptions)
{
Console.WriteLine($"[Select]: {title} multi: {isMultiSelect}");
for (var i = 0; i < items.Count; i++)
{
var preview = previews?[i] != null ? previews[i] : "empty";
var description = descriptions?[i] != null ? descriptions[i] : "empty";
Console.Write($"Items: {items[i]} | preview: {preview} | description: {description}");
}
return new List<int>{0};
}

public string InputString(string title, string initialText, bool useRTF)
{
Console.WriteLine($"[InputString]: {title}, text: {initialText}, rtf: {useRTF}");
return "Hello World";
}

public int DialogYesNo(string title)
{
Console.WriteLine($"[DialogYesNo]: {title}");
return 1;
}

public int DialogYesNo(string title, string message)
{
Console.WriteLine($"[DialogYesNo]: {title} - {message}");
return 1;
}

public void DisplayImage(string path, string title)
{
Console.WriteLine($"[Image]: {title} - {path}");
}

public void DisplayText(string text, string title)
{
Console.WriteLine($"[Text]: {title} - {text}");
}

public void Patch(string from, string to)
{
Console.WriteLine($"[Patch]: {from} - {to}");
}

public string ReadOblivionINI(string section, string name)
{
Console.WriteLine($"[ReadOblivionINI]: {section} - {name}");
return "";
}

public string ReadRendererInfo(string name)
{
Console.WriteLine($"[ReadRendererInfo]: {name}");
return "";
}

public bool DataFileExists(string path)
{
Console.WriteLine($"[DataFileExists]: {path}");
return false;
}

public bool HasScriptExtender()
{
return true;
}

public bool HasGraphicsExtender()
{
return false;
}

public Version ScriptExtenderVersion()
{
return new Version(0, 0, 21, 4);
}

public Version GraphicsExtenderVersion()
{
return new Version("");
}

public Version OblivionVersion()
{
return new Version(1, 2, 416, 0);
}

public Version OBSEPluginVersion(string path)
{
return new Version(1,0,0,0);
}

public HashSet<ScriptESP> GetESPs()
{
return new HashSet<ScriptESP>
{
new ScriptESP
{
Active = true,
Name = "test"
}
};
}

public HashSet<string> GetActiveOMODNames()
{
throw new NotImplementedException();
}

public byte[] ReadExistingDataFile(string file)
{
throw new NotImplementedException();
}

public byte[] GetDataFileFromBSA(string file)
{
throw new NotImplementedException();
}

public byte[] GetDataFileFromBSA(string bsa, string file)
{
throw new NotImplementedException();
}
}
}
4 changes: 2 additions & 2 deletions OMODFramework.Test/CSharpTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace OMODFramework.Test
{
[TestClass]
//[TestClass]
public class CSharpTest : ATest
{
public override HashSet<NexusFile> Files { get; set; } = new HashSet<NexusFile>
Expand All @@ -17,7 +17,7 @@ public class CSharpTest : ATest
}
};

[TestMethod]
//[TestMethod]
public void TestCSharpScript()
{
Files.Do(f =>
Expand Down
9 changes: 8 additions & 1 deletion OMODFramework.Test/ScriptFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ public Version OBSEPluginVersion(string path)

public HashSet<ScriptESP> GetESPs()
{
throw new NotImplementedException();
return new HashSet<ScriptESP>
{
new ScriptESP
{
Active = true,
Name = "test"
}
};
}

public HashSet<string> GetActiveOMODNames()
Expand Down

0 comments on commit 0cf8460

Please sign in to comment.