90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
using TovarV2;
|
|
using Avalonia;
|
|
using Avalonia.Headless;
|
|
|
|
namespace TestTovarV2
|
|
{
|
|
[TestFixture]
|
|
public class MainWindowTests
|
|
{
|
|
private MainWindow _mainWindow;
|
|
|
|
[OneTimeSetUp]
|
|
public void OneTimeSetup()
|
|
{
|
|
AppBuilder.Configure<App>()
|
|
.UseHeadless(new AvaloniaHeadlessPlatformOptions())
|
|
.SetupWithoutStarting();
|
|
}
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
_mainWindow = new MainWindow();
|
|
|
|
ProductEdit.ResetState();
|
|
}
|
|
|
|
[Test]
|
|
public void BtnVhod_ShouldOpenProductEditWindow_WhenCodeInputTextIsZero()
|
|
{
|
|
_mainWindow.CodeInputBox.Text = "0";
|
|
|
|
_mainWindow.BtnVhod_OnClick(null, null);
|
|
|
|
Assert.That(0 == ListPr.codeUser);
|
|
Assert.IsTrue(ProductEdit.IsOpen);
|
|
}
|
|
|
|
[Test]
|
|
public void BtnVhod_ShouldOpenProductEditWindow_WhenCodeInputTextIsOne()
|
|
{
|
|
_mainWindow.CodeInputBox.Text = "1";
|
|
|
|
_mainWindow.BtnVhod_OnClick(null, null);
|
|
|
|
Assert.That(1 == ListPr.codeUser);
|
|
Assert.IsTrue(ProductEdit.IsOpen);
|
|
}
|
|
|
|
[Test]
|
|
public void BtnVhod_ShouldNotChangeCode_WhenCodeInputIsInvalidWithDigits()
|
|
{
|
|
_mainWindow.CodeInputBox.Text = "331";
|
|
ListPr.codeUser = -1;
|
|
|
|
_mainWindow.BtnVhod_OnClick(null, null);
|
|
|
|
Assert.That(0 != ListPr.codeUser);
|
|
Assert.That(1 != ListPr.codeUser);
|
|
Assert.IsFalse(MainWindow.IsOpen);
|
|
}
|
|
|
|
[Test]
|
|
public void BtnVhod_ShouldNotChangeCode_WhenCodeInputIsInvalidWithLetters()
|
|
{
|
|
_mainWindow.CodeInputBox.Text = "vefve";
|
|
ListPr.codeUser = -1;
|
|
|
|
_mainWindow.BtnVhod_OnClick(null, null);
|
|
|
|
Assert.That(0 != ListPr.codeUser);
|
|
Assert.That(1 != ListPr.codeUser);
|
|
Assert.IsFalse(MainWindow.IsOpen);
|
|
}
|
|
|
|
[Test]
|
|
public void BtnVhod_ShouldNotChangeCode_WhenCodeInputIsBlank()
|
|
{
|
|
_mainWindow.CodeInputBox.Text = "";
|
|
ListPr.codeUser = -1;
|
|
|
|
_mainWindow.BtnVhod_OnClick(null, null);
|
|
|
|
Assert.That(0 != ListPr.codeUser);
|
|
Assert.That(1 != ListPr.codeUser);
|
|
Assert.IsFalse(MainWindow.IsOpen);
|
|
}
|
|
|
|
}
|
|
} |