Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillGutyrchik committed Dec 17, 2024
1 parent 33d6ab4 commit 9dd9ed6
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 4 deletions.
6 changes: 6 additions & 0 deletions EasyEplanner.Tests/EasyEplanner.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
</ItemGroup>

<ItemGroup>
<None Update="InterprojectExchange.Test\TestData\project\main.io.lua">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="InterprojectExchange.Test\TestData\mock_script.lua">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="ProjectImportICP.Test\TestData\Compare.dst.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using NUnit.Framework;
using InterprojectExchange;
using System.IO;

namespace Tests.InterprojectExchangeTest
{
Expand All @@ -17,5 +18,35 @@ public void SaveTest()
Assert.Throws<ApplicationException>(() => ipe.Save());
}

[Test]
public void LoadMainIOData_undefined()
{
var ipe = new InterprojectExchangeStarter();

var method = typeof(InterprojectExchangeStarter).GetMethod("LoadMainIOData",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

Assert.IsFalse((bool)method.Invoke(ipe, new object[] {"", ""}));
}

[Test]
public void LoadMainIOData()
{
var ipe = new InterprojectExchangeStarter();

var initLua = typeof(InterprojectExchangeStarter).GetMethod("InitLuaInstance",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
var loadScript = typeof(InterprojectExchangeStarter).GetMethod("LoadScript",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
var method = typeof(InterprojectExchangeStarter).GetMethod("LoadMainIOData",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

initLua.Invoke(ipe, null);
loadScript.Invoke(ipe,
new object[] { Path.Combine(TestContext.CurrentContext.TestDirectory, "InterprojectExchange.Test", "TestData", "mock_script.lua") });

Assert.IsTrue((bool)method.Invoke(ipe,
new object[] { Path.Combine(TestContext.CurrentContext.TestDirectory, "InterprojectExchange.Test", "TestData"), "project" }));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using InterprojectExchange;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyEplannerEasyEplannerTests.InterprojectExchangeTest
{

public class ProjectModelTest
{
[Test]
public void LoadedGetSetTest()
{
var model = new AdvancedProjectModel
{
Loaded = true
};

Assert.IsTrue(model.Loaded);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function init_io_file (projecrt_name)
-- do nothing
return 0
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PAC_name = ''
PAC_id = ''

nodes = { }

devices = { }
4 changes: 1 addition & 3 deletions src/InterprojectExchange/Forms/InterprojectExchangeForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace InterprojectExchange
/// <summary>
/// Форма межпроектного обмена сигналами
/// </summary>
[ExcludeFromCodeCoverage]
public partial class InterprojectExchangeForm : Form
{
public InterprojectExchangeForm()
Expand Down Expand Up @@ -132,7 +133,6 @@ private void LoadCurrentProjectDevices()
/// true - есть ошибка
/// false - ошибки нет
/// </returns>
[ExcludeFromCodeCoverage]
private void CheckBindingSignals()
{
string err = interprojectExchange.CheckBindingSignals();
Expand Down Expand Up @@ -975,7 +975,6 @@ private void AddAndSelectModelToList(DirectoryInfo dirInfo)
/// <summary>
/// Событие изменение текста в списке с именами загруженных проектов
/// </summary>
[ExcludeFromCodeCoverage]
private void advProjNameComboBox_SelectedItemChanged(object sender,
EventArgs e)
{
Expand Down Expand Up @@ -1137,7 +1136,6 @@ private void saveButton_Click(object sender, EventArgs e)
/// Проект загружен - обычный шрифт <br/>
/// Проект не загружен - серый текст
/// </summary>
[ExcludeFromCodeCoverage]
private void advProjNameComboBox_DrawItem(object sender, DrawItemEventArgs e)
{
var model = interprojectExchange.GetModel(advProjNameComboBox.Items[e.Index].ToString());
Expand Down
2 changes: 1 addition & 1 deletion src/InterprojectExchange/InterprojectExchangeStarter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private bool LoadMainIOData(string pathToProjectsDir,
}
else
{
form.ShowErrorMessage($"Не найден файл main.io.lua проекта" +
form?.ShowErrorMessage($"Не найден файл main.io.lua проекта" +
$" \"{projName}\"");
return false;
}
Expand Down

0 comments on commit 9dd9ed6

Please sign in to comment.