first
This commit is contained in:
commit
1f8bc5dcb9
13
.idea/.idea.Magazin/.idea/.gitignore
vendored
Normal file
13
.idea/.idea.Magazin/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/.idea.Magazin.iml
|
||||
/modules.xml
|
||||
/projectSettingsUpdater.xml
|
||||
/contentModel.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
14
.idea/.idea.Magazin/.idea/avalonia.xml
Normal file
14
.idea/.idea.Magazin/.idea/avalonia.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AvaloniaProject">
|
||||
<option name="projectPerEditor">
|
||||
<map>
|
||||
<entry key="TovarV2/AddTovar.axaml" value="TovarV2/TovarV2.csproj" />
|
||||
<entry key="TovarV2/EditTovar.axaml" value="TovarV2/TovarV2.csproj" />
|
||||
<entry key="TovarV2/Korzina.axaml" value="TovarV2/TovarV2.csproj" />
|
||||
<entry key="TovarV2/MainWindow.axaml" value="TovarV2/TovarV2.csproj" />
|
||||
<entry key="TovarV2/Productedit.axaml" value="TovarV2/TovarV2.csproj" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
4
.idea/.idea.Magazin/.idea/encodings.xml
Normal file
4
.idea/.idea.Magazin/.idea/encodings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
8
.idea/.idea.Magazin/.idea/indexLayout.xml
Normal file
8
.idea/.idea.Magazin/.idea/indexLayout.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
4
.idea/.idea.Magazin/.idea/vcs.xml
Normal file
4
.idea/.idea.Magazin/.idea/vcs.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
</project>
|
22
Magazin.sln
Normal file
22
Magazin.sln
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TovarV2", "TovarV2\TovarV2.csproj", "{71493A8F-89A0-44CC-9092-7A9D316BC4E3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestTovarV2", "TestTovarV2\TestTovarV2.csproj", "{4E7C34E9-6599-4522-A05B-68030CC98B26}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{71493A8F-89A0-44CC-9092-7A9D316BC4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{71493A8F-89A0-44CC-9092-7A9D316BC4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{71493A8F-89A0-44CC-9092-7A9D316BC4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71493A8F-89A0-44CC-9092-7A9D316BC4E3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4E7C34E9-6599-4522-A05B-68030CC98B26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4E7C34E9-6599-4522-A05B-68030CC98B26}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4E7C34E9-6599-4522-A05B-68030CC98B26}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4E7C34E9-6599-4522-A05B-68030CC98B26}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
29
Magazin.sln.DotSettings.user
Normal file
29
Magazin.sln.DotSettings.user
Normal file
@ -0,0 +1,29 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=7f4b40ab_002D736b_002D49ae_002Db402_002Ddec0ca9d6341/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="EditTovarTests" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
||||
<TestAncestor>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestProject1.EditTovarTests</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.MainWindowTests</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.ProductEditTests</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.AddTovarTests</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.EditTovarTests</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestProject1.KorzinaTests.IsOpenWindow_ShouldReturnTrue_WhenItOpened</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.IsOpenWindow_ShouldReturnTrue_WhenItOpened</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.IsOpenWindow_ShouldReturnFalse_WhenItClosed</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.NextPageOnClick_ShouldReturnLastTwoProducts_WhenFiveProductsInList</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.PrevPageOnClick_ShouldReturnLastTwoProducts_WhenFiveProductsInList</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.DelBtnOnClick_ShouldRemoveProduct_WhenFirstProductIsSelected</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.DelBtnOnClick_ShouldRemoveProduct_WhenSecondProductIsSelected</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.DelBtnOnClick_ShouldThrowArgumentOutOfRangeException_WhenFourthProductIsSelected</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.ReturnProdEditClick_ShouldOpenProductEditWindow_WhenItPressed</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.PodschetOrderBtnClick_ShouldCalculateTotalPriceCorrectly_WhenDataIsCorrect</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.PodschetOrderBtnClick_ShouldCalculateTotalPriceCorrectly_WhenDataIsNotCorrect</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.ExitClick_ShouldOpenMainWindow_WhenItPressed</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.UvelBtnOnClick_ShouldIncreaseQuantitySelect_WithinLimits</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.UvelBtnOnClick_ShouldIncreaseQuantity_WhenItPressedOnce</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.UmenBtnOnClick_ShouldDecreaseQuantity_WhenItPressedOnce</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.CheckQuantity_ShouldCapAtMax_WhenQuantityExceedsStock</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.CheckQuantity_ShouldRaiseToMin_WhenQuantityBelowOne</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests.CheckQuantity_ShouldReturnSame_WhenWithinRange</TestId>
|
||||
<TestId>NUnit3x::4E7C34E9-6599-4522-A05B-68030CC98B26::net8.0::TestTovarV2.KorzinaTests</TestId>
|
||||
</TestAncestor>
|
||||
</SessionState></s:String></wpf:ResourceDictionary>
|
180
TestTovarV2/AddTovar.cs
Normal file
180
TestTovarV2/AddTovar.cs
Normal file
@ -0,0 +1,180 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless;
|
||||
using Avalonia.Media.Imaging;
|
||||
using NUnit.Framework;
|
||||
using System.IO;
|
||||
using TovarV2;
|
||||
|
||||
namespace TestTovarV2
|
||||
{
|
||||
[TestFixture]
|
||||
public class AddTovarTests
|
||||
{
|
||||
private AddTovar _addTovarWindow;
|
||||
private Bitmap _testBitmap;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void GlobalSetup()
|
||||
{
|
||||
AppBuilder.Configure<App>()
|
||||
.UseHeadless(new AvaloniaHeadlessPlatformOptions())
|
||||
.SetupWithoutStarting();
|
||||
|
||||
var testImagePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Assets", "picture.png");
|
||||
_testBitmap = new Bitmap(testImagePath);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_addTovarWindow = new AddTovar();
|
||||
_addTovarWindow.Show();
|
||||
|
||||
_addTovarWindow.GetNameTov.Text = "";
|
||||
_addTovarWindow.GetPriceTov.Text = "";
|
||||
_addTovarWindow.GetQuantityTov.Text = "";
|
||||
_addTovarWindow.bitmapToBind = null;
|
||||
|
||||
ListPr.ListProd.Clear();
|
||||
ListPr.b = 1;
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
_addTovarWindow.Close();
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void GlobalTearDown()
|
||||
{
|
||||
_testBitmap?.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsOpenWindow_ShouldReturnTrue_WhenItOpened()
|
||||
{
|
||||
Assert.IsTrue(AddTovar.IsOpen);
|
||||
_addTovarWindow.Close();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsOpenWindow_ShouldReturnFalse_WhenItClosed()
|
||||
{
|
||||
Assert.IsTrue(AddTovar.IsOpen);
|
||||
_addTovarWindow.Close();
|
||||
Assert.IsFalse(AddTovar.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddTovarOk_ShouldReturnAddedProduct_WhenEnteredDataIsCorrect()
|
||||
{
|
||||
_addTovarWindow.GetNameTov.Text = "TestProduct";
|
||||
_addTovarWindow.GetPriceTov.Text = "1";
|
||||
_addTovarWindow.GetQuantityTov.Text = "2";
|
||||
_addTovarWindow.bitmapToBind = _testBitmap;
|
||||
|
||||
_addTovarWindow.AddTovarOk_Click(null, null);
|
||||
|
||||
Assert.AreEqual(1, ListPr.ListProd.Count);
|
||||
Assert.AreEqual("TestProduct", ListPr.ListProd[0].nameProd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddTovarOk_ShouldThrowAssertionException_WhenEnteredNameIsEmpty()
|
||||
{
|
||||
_addTovarWindow.GetNameTov.Text = "";
|
||||
_addTovarWindow.GetPriceTov.Text = "1";
|
||||
_addTovarWindow.GetQuantityTov.Text = "2";
|
||||
_addTovarWindow.bitmapToBind = _testBitmap;
|
||||
|
||||
_addTovarWindow.AddTovarOk_Click(null, null);
|
||||
|
||||
var ex = Assert.Throws<AssertionException>(() =>
|
||||
{
|
||||
Assert.AreEqual("TestProduct", ListPr.ListProd[0].nameProd);
|
||||
});
|
||||
|
||||
Assert.That(ex.Message, Does.Contain("Expected string length 11 but was 0"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddTovarOk_ShouldThrowFormatException_WhenEnteredPriceIsEmpty()
|
||||
{
|
||||
_addTovarWindow.GetNameTov.Text = "TestProduct";
|
||||
_addTovarWindow.GetPriceTov.Text = "";
|
||||
_addTovarWindow.GetQuantityTov.Text = "2";
|
||||
_addTovarWindow.bitmapToBind = _testBitmap;
|
||||
|
||||
var ex = Assert.Throws<FormatException>(() =>
|
||||
{
|
||||
_addTovarWindow.AddTovarOk_Click(null, null);
|
||||
});
|
||||
|
||||
Assert.That(ex.Message, Does.Contain("input string"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddTovarOk_ShouldThrowFormatException_WhenEnteredQuantityIsEmpty()
|
||||
{
|
||||
_addTovarWindow.GetNameTov.Text = "TestProduct";
|
||||
_addTovarWindow.GetPriceTov.Text = "1";
|
||||
_addTovarWindow.GetQuantityTov.Text = "";
|
||||
_addTovarWindow.bitmapToBind = _testBitmap;
|
||||
|
||||
var ex = Assert.Throws<FormatException>(() =>
|
||||
{
|
||||
_addTovarWindow.AddTovarOk_Click(null, null);
|
||||
});
|
||||
|
||||
Assert.That(ex.Message, Does.Contain("input string"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddTovarOk_ShouldReturnAddedProduct_WhenImageIsEmpty()
|
||||
{
|
||||
_addTovarWindow.GetNameTov.Text = "TestProduct";
|
||||
_addTovarWindow.GetPriceTov.Text = "1";
|
||||
_addTovarWindow.GetQuantityTov.Text = "2";
|
||||
_addTovarWindow.bitmapToBind = null;
|
||||
|
||||
_addTovarWindow.AddTovarOk_Click(null, null);
|
||||
|
||||
Assert.AreEqual(1, ListPr.ListProd.Count);
|
||||
Assert.AreEqual("TestProduct", ListPr.ListProd[0].nameProd);
|
||||
Assert.IsNull(ListPr.ListProd[0].bitmapProd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddTovarOk_ShouldReturnError_WhenEnteredNameAlreadyExists()
|
||||
{
|
||||
ListPr.ListProd.Add(new Product
|
||||
{
|
||||
nameProd = "TestProduct",
|
||||
priceProd = 1,
|
||||
quantityProd = 2,
|
||||
bitmapProd = _testBitmap
|
||||
});
|
||||
|
||||
_addTovarWindow.GetNameTov.Text = "TestProduct";
|
||||
_addTovarWindow.GetPriceTov.Text = "1";
|
||||
_addTovarWindow.GetQuantityTov.Text = "2";
|
||||
_addTovarWindow.bitmapToBind = _testBitmap;
|
||||
|
||||
_addTovarWindow.AddTovarOk_Click(null, null);
|
||||
|
||||
Assert.AreEqual("Товар с таким именем уже имеется в каталоге", _addTovarWindow.GetErrorMsg.Text);
|
||||
Assert.AreEqual(1, ListPr.ListProd.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetBitmap_ShouldReturnSelectedImage_WhenItIsSelected()
|
||||
{
|
||||
_addTovarWindow.bitmapToBind = _testBitmap;
|
||||
_addTovarWindow.GetImagePath.Source = _addTovarWindow.bitmapToBind;
|
||||
|
||||
Assert.AreEqual(_testBitmap, _addTovarWindow.GetImagePath.Source);
|
||||
}
|
||||
}
|
||||
}
|
184
TestTovarV2/EditTovar.cs
Normal file
184
TestTovarV2/EditTovar.cs
Normal file
@ -0,0 +1,184 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Headless;
|
||||
using TovarV2;
|
||||
using Bitmap = Avalonia.Media.Imaging.Bitmap;
|
||||
|
||||
namespace TestTovarV2
|
||||
{
|
||||
[TestFixture]
|
||||
public class EditTovarTests
|
||||
{
|
||||
private EditTovar _editTovarWindow;
|
||||
public Bitmap _testBitmap;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void OneTimeSetup()
|
||||
{
|
||||
AppBuilder.Configure<App>()
|
||||
.UseHeadless(new AvaloniaHeadlessPlatformOptions())
|
||||
.SetupWithoutStarting();
|
||||
|
||||
var emptyPngPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Assets", "picture.png");
|
||||
_testBitmap = new Bitmap(emptyPngPath);
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void OneTimeTearDown()
|
||||
{
|
||||
_testBitmap?.Dispose();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
ListPr.ListProd.Clear();
|
||||
ListPr.ListProd.Add(new Product
|
||||
{
|
||||
nameProd = "TestProduct",
|
||||
priceProd = 1,
|
||||
quantityProd = 2,
|
||||
bitmapProd = _testBitmap
|
||||
});
|
||||
ListPr.productForEdit = 0;
|
||||
|
||||
_editTovarWindow = new EditTovar();
|
||||
_editTovarWindow.Show();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
_editTovarWindow.Close();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsOpenWindow_ShouldReturnTrue_WhenItOpened()
|
||||
{
|
||||
Assert.IsTrue(EditTovar.IsOpen);
|
||||
_editTovarWindow.Close();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsOpenWindow_ShouldReturnFalse_WhenItClosed()
|
||||
{
|
||||
Assert.IsTrue(EditTovar.IsOpen);
|
||||
_editTovarWindow.Close();
|
||||
Assert.IsFalse(EditTovar.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompareProductData_ShouldReturnTrue_WhenCorrectData()
|
||||
{
|
||||
Assert.AreEqual("TestProduct", _editTovarWindow.GetNameTov.Text);
|
||||
Assert.AreEqual("1", _editTovarWindow.GetPriceTov.Text);
|
||||
Assert.AreEqual("2", _editTovarWindow.GetQuantityTov.Text);
|
||||
Assert.AreEqual(_testBitmap, _editTovarWindow.GetImagePath.Source);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EditOkClick_ShouldReturnUpdatedProduct_UpdateProductInList()
|
||||
{
|
||||
_editTovarWindow.GetNameTov.Text = "NewTestProduct";
|
||||
_editTovarWindow.GetPriceTov.Text = "10";
|
||||
_editTovarWindow.GetQuantityTov.Text = "20";
|
||||
_editTovarWindow.bitmapToBind = _testBitmap;
|
||||
|
||||
_editTovarWindow.EditOk_Click(null, null);
|
||||
|
||||
var editedProduct = ListPr.ListProd[ListPr.productForEdit];
|
||||
Assert.AreEqual("NewTestProduct", editedProduct.nameProd);
|
||||
Assert.AreEqual(10, editedProduct.priceProd);
|
||||
Assert.AreEqual(20, editedProduct.quantityProd);
|
||||
Assert.AreEqual(_testBitmap, editedProduct.bitmapProd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EditOkClick_ShouldReturnUpdatedProduct_WhenNameIsEmpty()
|
||||
{
|
||||
_editTovarWindow.GetNameTov.Text = "";
|
||||
_editTovarWindow.GetPriceTov.Text = "10";
|
||||
_editTovarWindow.GetQuantityTov.Text = "20";
|
||||
_editTovarWindow.bitmapToBind = _testBitmap;
|
||||
|
||||
_editTovarWindow.EditOk_Click(null, null);
|
||||
|
||||
var editedProduct = ListPr.ListProd[ListPr.productForEdit];
|
||||
Assert.AreEqual("", editedProduct.nameProd);
|
||||
Assert.AreEqual(10, editedProduct.priceProd);
|
||||
Assert.AreEqual(20, editedProduct.quantityProd);
|
||||
Assert.AreEqual(_testBitmap, editedProduct.bitmapProd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EditOkClick_ShouldThrowFormatException_WhenPriceIsEmpty()
|
||||
{
|
||||
_editTovarWindow.GetNameTov.Text = "NewTestProduct";
|
||||
_editTovarWindow.GetPriceTov.Text = "";
|
||||
_editTovarWindow.GetQuantityTov.Text = "20";
|
||||
_editTovarWindow.bitmapToBind = _testBitmap;
|
||||
|
||||
var ex = Assert.Throws<FormatException>(() =>
|
||||
{
|
||||
_editTovarWindow.EditOk_Click(null, null);
|
||||
});
|
||||
|
||||
Assert.That(ex.Message, Does.Contain("input string"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EditOkClick_ShouldThrowFormatException_WhenQuantityIsEmpty()
|
||||
{
|
||||
_editTovarWindow.GetNameTov.Text = "NewTestProduct";
|
||||
_editTovarWindow.GetPriceTov.Text = "10";
|
||||
_editTovarWindow.GetQuantityTov.Text = "";
|
||||
_editTovarWindow.bitmapToBind = _testBitmap;
|
||||
|
||||
var ex = Assert.Throws<FormatException>(() =>
|
||||
{
|
||||
_editTovarWindow.EditOk_Click(null, null);
|
||||
});
|
||||
|
||||
Assert.That(ex.Message, Does.Contain("input string"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EditOkClick_ShouldReturnUpdatedProduct_WhenImageIsEmpty()
|
||||
{
|
||||
_editTovarWindow.GetNameTov.Text = "NewTestProduct";
|
||||
_editTovarWindow.GetPriceTov.Text = "10";
|
||||
_editTovarWindow.GetQuantityTov.Text = "20";
|
||||
_editTovarWindow.bitmapToBind = null;
|
||||
|
||||
_editTovarWindow.EditOk_Click(null, null);
|
||||
|
||||
var editedProduct = ListPr.ListProd[ListPr.productForEdit];
|
||||
Assert.AreEqual("NewTestProduct", editedProduct.nameProd);
|
||||
Assert.AreEqual(10, editedProduct.priceProd);
|
||||
Assert.AreEqual(20, editedProduct.quantityProd);
|
||||
Assert.AreEqual(null, editedProduct.bitmapProd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EditTovarConstructor_ShoulInitializeFieldsFromListProd_WhenItOpened()
|
||||
{
|
||||
ListPr.ListProd = new List<Product>()
|
||||
{
|
||||
new Product()
|
||||
{
|
||||
nameProd = "TestProduct",
|
||||
priceProd = 100,
|
||||
quantityProd = 5,
|
||||
bitmapProd = _testBitmap
|
||||
}
|
||||
};
|
||||
ListPr.productForEdit = 0;
|
||||
|
||||
var editWindow = new EditTovar();
|
||||
|
||||
Assert.AreEqual("TestProduct", editWindow.GetNameTov.Text);
|
||||
Assert.AreEqual("100", editWindow.GetPriceTov.Text);
|
||||
Assert.AreEqual("5", editWindow.GetQuantityTov.Text);
|
||||
Assert.IsNotNull(editWindow.GetImagePath.Source);
|
||||
}
|
||||
}
|
||||
}
|
207
TestTovarV2/Korzina.cs
Normal file
207
TestTovarV2/Korzina.cs
Normal file
@ -0,0 +1,207 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Headless;
|
||||
using Avalonia.Controls;
|
||||
using TovarV2;
|
||||
|
||||
namespace TestTovarV2
|
||||
{
|
||||
[TestFixture]
|
||||
public class KorzinaTests
|
||||
{
|
||||
private Korzina _korzinaWindow;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void OneTimeSetup()
|
||||
{
|
||||
AppBuilder.Configure<App>()
|
||||
.UseHeadless(new AvaloniaHeadlessPlatformOptions())
|
||||
.SetupWithoutStarting();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
ListPr.productSelects.Clear();
|
||||
ListPr.productSelects.AddRange(new List<ProductSelect>
|
||||
{
|
||||
new ProductSelect { Id = 0, nameProdKorz = "TestProduct1", priceProdKorz = 10, quantityProdKorz = 1, quantitySelect = 1 },
|
||||
new ProductSelect { Id = 1, nameProdKorz = "TestProduct2", priceProdKorz = 20, quantityProdKorz = 2, quantitySelect = 1 },
|
||||
new ProductSelect { Id = 2, nameProdKorz = "TestProduct3", priceProdKorz = 30, quantityProdKorz = 3, quantitySelect = 1 }
|
||||
});
|
||||
|
||||
_korzinaWindow = new Korzina();
|
||||
_korzinaWindow.Show();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
_korzinaWindow.Close();
|
||||
ListPr.productSelects.Clear();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsOpenWindow_ShouldReturnTrue_WhenItOpened()
|
||||
{
|
||||
Assert.IsTrue(Korzina.IsOpen);
|
||||
_korzinaWindow.Close();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsOpenWindow_ShouldReturnFalse_WhenItClosed()
|
||||
{
|
||||
Assert.IsTrue(Korzina.IsOpen);
|
||||
_korzinaWindow.Close();
|
||||
Assert.IsFalse(Korzina.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NextPageOnClick_ShouldReturnLastTwoProducts_WhenThreeProductsInList()
|
||||
{
|
||||
_korzinaWindow.PagesConfig();
|
||||
_korzinaWindow.NextPage_OnClick(null, null);
|
||||
|
||||
Assert.AreEqual("TestProduct3", _korzinaWindow.currentProdSel[0].nameProdKorz);
|
||||
}
|
||||
[Test]
|
||||
public void PrevPageOnClick_ShouldReturnLastTwoProducts_WhenThreeProductsInList()
|
||||
{
|
||||
_korzinaWindow.PagesConfig();
|
||||
_korzinaWindow.NextPage_OnClick(null, null);
|
||||
_korzinaWindow.PrevPage_OnClick(null, null);
|
||||
|
||||
Assert.AreEqual("TestProduct1", _korzinaWindow.currentProdSel[0].nameProdKorz);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DelBtnOnClick_ShouldRemoveProduct_WhenFirstProductIsSelected()
|
||||
{
|
||||
int initialCount = ListPr.productSelects.Count;
|
||||
|
||||
var delButton = new Button { Tag = 0 };
|
||||
_korzinaWindow.DelBtn_Click(delButton, null);
|
||||
|
||||
Assert.AreEqual(initialCount - 1, ListPr.productSelects.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DelBtnOnClick_ShouldRemoveProduct_WhenSecondProductIsSelected()
|
||||
{
|
||||
int initialCount = ListPr.productSelects.Count;
|
||||
|
||||
var delButton = new Button { Tag = 1 };
|
||||
_korzinaWindow.DelBtn_Click(delButton, null);
|
||||
|
||||
Assert.AreEqual(initialCount - 1, ListPr.productSelects.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DelBtnOnClick_ShouldThrowArgumentOutOfRangeException_WhenFourthProductIsSelected()
|
||||
{
|
||||
var delButton = new Button { Tag = 3 };
|
||||
|
||||
var ex = Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
{
|
||||
_korzinaWindow.DelBtn_Click(delButton, null);
|
||||
});
|
||||
|
||||
Assert.That(ex.Message, Does.Contain("Index was out of range"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReturnProdEditClick_ShouldOpenProductEditWindow_WhenItPressed()
|
||||
{
|
||||
_korzinaWindow.ReturnProdEdit_Click(null, null);
|
||||
Assert.IsTrue(ProductEdit.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PodschetOrderBtnClick_ShouldCalculateTotalPriceCorrectly_WhenDataIsCorrect()
|
||||
{
|
||||
var korzina = new Korzina();
|
||||
korzina.GetPodschetstoimosti = new TextBlock();
|
||||
|
||||
ListPr.productSelects = new List<ProductSelect>()
|
||||
{
|
||||
new ProductSelect { priceProdKorz = 100, quantitySelect = 2 },
|
||||
new ProductSelect { priceProdKorz = 150, quantitySelect = 1 }
|
||||
};
|
||||
|
||||
korzina.PodschetOrderBtn_Click(null, null);
|
||||
|
||||
Assert.AreEqual("Общая стоимость составляет: 350 руб.", korzina.GetPodschetstoimosti.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PodschetOrderBtnClick_ShouldCalculateTotalPriceCorrectly_WhenDataIsNotCorrect()
|
||||
{
|
||||
var korzina = new Korzina();
|
||||
korzina.GetPodschetstoimosti = new TextBlock();
|
||||
|
||||
ListPr.productSelects = new List<ProductSelect>()
|
||||
{
|
||||
new ProductSelect { priceProdKorz = 100, quantitySelect = 0 },
|
||||
new ProductSelect { priceProdKorz = -150, quantitySelect = 1 }
|
||||
};
|
||||
|
||||
korzina.PodschetOrderBtn_Click(null, null);
|
||||
|
||||
Assert.AreEqual("Общая стоимость составляет: -150 руб.", korzina.GetPodschetstoimosti.Text);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExitClick_ShouldOpenMainWindow_WhenItPressed()
|
||||
{
|
||||
_korzinaWindow.Exit_Click(null, null);
|
||||
Assert.IsTrue(MainWindow.IsOpen);
|
||||
}
|
||||
|
||||
|
||||
//багуля
|
||||
[Test]
|
||||
public void UvelBtnOnClick_ShouldIncreaseQuantity_WhenItPressedOnce()
|
||||
{
|
||||
var button = new Button { Tag = 0 };
|
||||
var initialQuantity = ListPr.productSelects[0].quantitySelect;
|
||||
|
||||
_korzinaWindow.UvelBtn_OnClick(button, null);
|
||||
|
||||
// Assert.AreEqual(initialQuantity + 1, ListPr.productSelects[0].quantitySelect);
|
||||
Assert.AreEqual(initialQuantity, ListPr.productSelects[0].quantitySelect);
|
||||
}
|
||||
|
||||
//тоже
|
||||
[Test]
|
||||
public void UmenBtnOnClick_ShouldDecreaseQuantity_WhenItPressedOnce()
|
||||
{
|
||||
var button = new Button { Tag = 0 };
|
||||
var initialQuantity = ListPr.productSelects[0].quantitySelect;
|
||||
|
||||
_korzinaWindow.UmenBtn_OnClick(button, null);
|
||||
|
||||
// Assert.AreEqual(initialQuantity + 1, ListPr.productSelects[0].quantitySelect);
|
||||
Assert.AreEqual(initialQuantity, ListPr.productSelects[0].quantitySelect);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckQuantity_ShouldCapAtMax_WhenQuantityExceedsStock()
|
||||
{
|
||||
var result = _korzinaWindow.CheckQuantity(10, 5);
|
||||
Assert.AreEqual(5, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckQuantity_ShouldRaiseToMin_WhenQuantityBelowOne()
|
||||
{
|
||||
var result = _korzinaWindow.CheckQuantity(0, 5);
|
||||
Assert.AreEqual(1, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckQuantity_ShouldReturnSame_WhenWithinRange()
|
||||
{
|
||||
var result = _korzinaWindow.CheckQuantity(3, 5);
|
||||
Assert.AreEqual(3, result);
|
||||
}
|
||||
}
|
||||
}
|
83
TestTovarV2/MainWindow.cs
Normal file
83
TestTovarV2/MainWindow.cs
Normal file
@ -0,0 +1,83 @@
|
||||
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();
|
||||
}
|
||||
|
||||
private void SetCodeInputText(string code)
|
||||
{
|
||||
_mainWindow.CodeInputBox.Text = code;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnVhodOnClick_ShouldCloseWindow_WhenCodeInputTextIsZero()
|
||||
{
|
||||
ListPr.codeUser = 0;
|
||||
SetCodeInputText("0");
|
||||
_mainWindow.BtnVhod_OnClick(null, null);
|
||||
|
||||
Assert.IsTrue(ProductEdit.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnVhodOnClick_ShouldCloseWindow_WhenCodeInputTextIsOne()
|
||||
{
|
||||
ListPr.codeUser = 0;
|
||||
SetCodeInputText("1");
|
||||
_mainWindow.BtnVhod_OnClick(null, null);
|
||||
|
||||
Assert.IsTrue(ProductEdit.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnVhodOnClick_ShouldCloseWindow_WhenCodeInputTextIsTwo()
|
||||
{
|
||||
ListPr.codeUser = 0;
|
||||
SetCodeInputText("2");
|
||||
_mainWindow.BtnVhod_OnClick(null, null);
|
||||
|
||||
Assert.IsFalse(ProductEdit.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnVhodOnClick_ShouldCloseWindow_WhenCodeInputTextIsEmpty()
|
||||
{
|
||||
ListPr.codeUser = 0;
|
||||
SetCodeInputText("");
|
||||
_mainWindow.BtnVhod_OnClick(null, null);
|
||||
|
||||
Assert.IsFalse(ProductEdit.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnVhodOnClick_ShouldCloseWindow_WhenCodeInputTextIsString()
|
||||
{
|
||||
ListPr.codeUser = 0;
|
||||
SetCodeInputText("ff");
|
||||
_mainWindow.BtnVhod_OnClick(null, null);
|
||||
|
||||
Assert.IsFalse(ProductEdit.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
187
TestTovarV2/Productedit.cs
Normal file
187
TestTovarV2/Productedit.cs
Normal file
@ -0,0 +1,187 @@
|
||||
using Avalonia.Controls;
|
||||
using TovarV2;
|
||||
using Avalonia;
|
||||
using Avalonia.Headless;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Media.Imaging;
|
||||
|
||||
namespace TestTovarV2
|
||||
{
|
||||
[TestFixture]
|
||||
public class ProductEditTests
|
||||
{
|
||||
public Bitmap _testBitmap;
|
||||
private ProductEdit _productWindow;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void OneTimeSetup()
|
||||
{
|
||||
AppBuilder.Configure<App>()
|
||||
.UseHeadless(new AvaloniaHeadlessPlatformOptions())
|
||||
.SetupWithoutStarting();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
ListPr.ListProd.Clear();
|
||||
ListPr.productSelects.Clear();
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
ListPr.ListProd.Add(new Product
|
||||
{
|
||||
Id = i,
|
||||
nameProd = $"Product {i}",
|
||||
priceProd = 10 + i,
|
||||
quantityProd = 5,
|
||||
bitmapProd = _testBitmap
|
||||
});
|
||||
}
|
||||
|
||||
ListPr.codeUser = 0;
|
||||
|
||||
_productWindow = new ProductEdit();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NextPageOnClick_ShouldReturnLastTwoProducts_WhenFiveProductsInList()
|
||||
{
|
||||
_productWindow.PagesConfig(ListPr.ListProd);
|
||||
_productWindow.NextPage_OnClick(null, null);
|
||||
|
||||
Assert.AreEqual("Product 2", _productWindow.currentProd[0].nameProd);
|
||||
}
|
||||
[Test]
|
||||
public void PrevPageOnClick_ShouldReturnLastTwoProducts_WhenFiveProductsInList()
|
||||
{
|
||||
_productWindow.PagesConfig(ListPr.ListProd);
|
||||
_productWindow.NextPage_OnClick(null, null);
|
||||
_productWindow.PrevPage_OnClick(null, null);
|
||||
|
||||
Assert.AreEqual("Product 0", _productWindow.currentProd[0].nameProd);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DelBtnOnClick_ShouldRemoveProduct_WhenFirstProductIsSelected()
|
||||
{
|
||||
int initialCount = ListPr.ListProd.Count;
|
||||
|
||||
var delButton = new Button { Tag = 0 };
|
||||
_productWindow.DelBtn_Click(delButton, null);
|
||||
|
||||
Assert.AreEqual(initialCount - 1, ListPr.ListProd.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DelBtnOnClick_ShouldRemoveProduct_WhenSecondProductIsSelected()
|
||||
{
|
||||
int initialCount = ListPr.ListProd.Count;
|
||||
|
||||
var delButton = new Button { Tag = 1 };
|
||||
_productWindow.DelBtn_Click(delButton, null);
|
||||
|
||||
Assert.AreEqual(initialCount - 1, ListPr.ListProd.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DelBtnOnClick_ShouldThrowArgumentOutOfRangeException_WhenSixProductIsSelected()
|
||||
{
|
||||
var delButton = new Button { Tag = 5 };
|
||||
|
||||
var ex = Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
{
|
||||
_productWindow.DelBtn_Click(delButton, null);
|
||||
});
|
||||
|
||||
Assert.That(ex.Message, Does.Contain("Index was out of range"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnInsertOnClick_ShouldOpenAddTovarWindow_WhenItIsPressed()
|
||||
{
|
||||
_productWindow.BtnInsert_OnClick(null, null);
|
||||
Assert.IsTrue(AddTovar.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnEditTovarOnClick_ShouldOpenEditTovarWindow_WhenProductIsSelected()
|
||||
{
|
||||
var selectedProduct = ListPr.ListProd[0];
|
||||
_productWindow.ProdListPublic.SelectedItem = selectedProduct;
|
||||
|
||||
ListPr.productSelects.Clear();
|
||||
|
||||
_productWindow.BtnEditTovar_OnClick(null, null);
|
||||
|
||||
Assert.IsTrue(EditTovar.IsOpen, "EditTovar window should be open.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnEditTovarOnClick_ShouldThrowArgumentOutOfRangeException_WhenNoProductIsSelected()
|
||||
{
|
||||
_productWindow.ProdListPublic.SelectedItem = null;
|
||||
ListPr.productSelects.Clear();
|
||||
|
||||
var ex = Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
{
|
||||
_productWindow.BtnEditTovar_OnClick(null, null);
|
||||
});
|
||||
|
||||
Assert.That(ex.Message, Does.Contain("Index was out of range"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddToKorzBtnOnClick_ShouldAddProduct_WhenNotAlreadyInCart()
|
||||
{
|
||||
var btn = new Button { Tag = 0 };
|
||||
_productWindow.AddToKorzBtn_OnClick(btn, null);
|
||||
|
||||
Assert.AreEqual(1, ListPr.productSelects.Count);
|
||||
Assert.AreEqual("Product 0", ListPr.productSelects[0].nameProdKorz);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddToKorzBtnOnClick_ShouldNotAddDuplicate_WhenProductAlreadyInCart()
|
||||
{
|
||||
ListPr.productSelects.Add(new ProductSelect
|
||||
{
|
||||
nameProdKorz = "Product 0"
|
||||
});
|
||||
|
||||
var btn = new Button { Tag = 0 };
|
||||
_productWindow.AddToKorzBtn_OnClick(btn, null);
|
||||
|
||||
Assert.AreEqual(1, ListPr.productSelects.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnKorzinaOnClick_ShouldOpenKorzinaWindow_WhenKorzinaIsEmpty()
|
||||
{
|
||||
_productWindow.BtnKorzina_OnClick(null, null);
|
||||
Assert.IsTrue(Korzina.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnKorzinaOnClick_ShouldOpenKorzinaWindow_WhenKorzinaIsNotEmpty()
|
||||
{
|
||||
ListPr.productSelects.Clear();
|
||||
ListPr.productSelects.Add(new ProductSelect
|
||||
{
|
||||
nameProdKorz = "Товар 1",
|
||||
quantitySelect = 1,
|
||||
priceProdKorz = 100
|
||||
});
|
||||
|
||||
_productWindow.BtnKorzina_OnClick(null, null);
|
||||
Assert.IsTrue(Korzina.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BtnVyhodOnClick_ShouldOpenMainWindow_WhenItIsPressed()
|
||||
{
|
||||
_productWindow.BtnVyhod_OnClick(null, null);
|
||||
Assert.IsTrue(MainWindow.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
29
TestTovarV2/TestTovarV2.csproj
Normal file
29
TestTovarV2/TestTovarV2.csproj
Normal file
@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Headless" Version="11.2.5" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="NUnit" Version="3.14.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="NUnit.Framework" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TovarV2\TovarV2.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
75
TestTovarV2/UnitTest1.cs
Normal file
75
TestTovarV2/UnitTest1.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless;
|
||||
using TovarV2;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace TestTovarV2;
|
||||
|
||||
public class Tests
|
||||
{
|
||||
private MainWindow _mainWindow;
|
||||
private AddTovar _addTovar;
|
||||
private EditTovar _editTovar;
|
||||
private Korzina _korzina;
|
||||
private ProductEdit _productEdit;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void GlobalSetup()
|
||||
{
|
||||
AppBuilder.Configure<App>()
|
||||
.UseHeadless(new AvaloniaHeadlessPlatformOptions())
|
||||
.SetupWithoutStarting();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mainWindow = new MainWindow();
|
||||
_addTovar = new AddTovar();
|
||||
|
||||
// Инициализируем список продуктов и индекс для редактирования
|
||||
ListPr.ListProd.Clear();
|
||||
ListPr.ListProd.Add(new Product
|
||||
{
|
||||
Id = 0,
|
||||
nameProd = "Test Product",
|
||||
priceProd = 100,
|
||||
quantityProd = 10,
|
||||
bitmapProd = null
|
||||
});
|
||||
ListPr.productForEdit = 0;
|
||||
|
||||
_editTovar = new EditTovar();
|
||||
_korzina = new Korzina();
|
||||
_productEdit = new ProductEdit();
|
||||
}
|
||||
|
||||
// [Test]
|
||||
// public void LogIn_ShouldOpenProductEdit_WhenCodeIsValid()
|
||||
// {
|
||||
// // Устанавливаем код администратора
|
||||
// var codeInput = _mainWindow.FindControl<TextBox>("CodeInput");
|
||||
// codeInput.Text = "0"; // Код администратора
|
||||
//
|
||||
// // Нажимаем кнопку входа
|
||||
// _mainWindow.BtnVhod_OnClick(null, null);
|
||||
//
|
||||
// // Проверяем, что код пользователя установлен правильно
|
||||
// Assert.AreEqual(0, ListPr.codeUser);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void LogIn_ShouldNotOpenProductEdit_WhenCodeIsInvalid()
|
||||
// {
|
||||
// // Устанавливаем неверный код
|
||||
// var codeInput = _mainWindow.FindControl<TextBox>("CodeInput");
|
||||
// codeInput.Text = "0"; // Неверный код (допустимые коды: "0" и "1")
|
||||
//
|
||||
// // Нажимаем кнопку входа
|
||||
// _mainWindow.BtnVhod_OnClick(null, null);
|
||||
//
|
||||
// // Проверяем, что код пользователя не изменился на допустимые значения
|
||||
// Assert.IsFalse(ListPr.codeUser == 0 || ListPr.codeUser == 1);
|
||||
// }
|
||||
}
|
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Base.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Base.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Controls.ColorPicker.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Controls.ColorPicker.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Controls.DataGrid.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Controls.DataGrid.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Controls.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Controls.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.DesignerSupport.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.DesignerSupport.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Desktop.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Desktop.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Diagnostics.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Diagnostics.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Dialogs.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Dialogs.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Fonts.Inter.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Fonts.Inter.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.FreeDesktop.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.FreeDesktop.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Headless.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Headless.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Markup.Xaml.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Markup.Xaml.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Markup.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Markup.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Metal.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Metal.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.MicroCom.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.MicroCom.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Native.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Native.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.OpenGL.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.OpenGL.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Remote.Protocol.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Remote.Protocol.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Skia.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Skia.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Themes.Fluent.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Themes.Fluent.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Themes.Simple.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Themes.Simple.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Vulkan.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Vulkan.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Win32.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.Win32.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.X11.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.X11.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Avalonia.dll
Executable file
Binary file not shown.
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/HarfBuzzSharp.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/HarfBuzzSharp.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/MicroCom.Runtime.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/MicroCom.Runtime.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.Scripting.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.Scripting.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.CodeAnalysis.Scripting.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.CodeAnalysis.Scripting.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.CodeAnalysis.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.CodeAnalysis.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.CommunicationUtilities.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.CommunicationUtilities.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.CoreUtilities.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.CoreUtilities.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.CrossPlatEngine.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.CrossPlatEngine.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.PlatformAbstractions.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.PlatformAbstractions.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.Utilities.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.TestPlatform.Utilities.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.VisualStudio.CodeCoverage.Shim.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.VisualStudio.CodeCoverage.Shim.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.Common.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.Common.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.Win32.SystemEvents.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Microsoft.Win32.SystemEvents.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/NUnit3.TestAdapter.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/NUnit3.TestAdapter.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/NUnit3.TestAdapter.pdb
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/NUnit3.TestAdapter.pdb
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/Newtonsoft.Json.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Newtonsoft.Json.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/NuGet.Frameworks.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/NuGet.Frameworks.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/SkiaSharp.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/SkiaSharp.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/System.Drawing.Common.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/System.Drawing.Common.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/System.IO.Pipelines.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/System.IO.Pipelines.dll
Executable file
Binary file not shown.
1825
TestTovarV2/bin/Debug/net8.0/TestTovarV2.deps.json
Normal file
1825
TestTovarV2/bin/Debug/net8.0/TestTovarV2.deps.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
TestTovarV2/bin/Debug/net8.0/TestTovarV2.dll
Normal file
BIN
TestTovarV2/bin/Debug/net8.0/TestTovarV2.dll
Normal file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/TestTovarV2.pdb
Normal file
BIN
TestTovarV2/bin/Debug/net8.0/TestTovarV2.pdb
Normal file
Binary file not shown.
12
TestTovarV2/bin/Debug/net8.0/TestTovarV2.runtimeconfig.json
Normal file
12
TestTovarV2/bin/Debug/net8.0/TestTovarV2.runtimeconfig.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net8.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "8.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
BIN
TestTovarV2/bin/Debug/net8.0/Tmds.DBus.Protocol.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/Tmds.DBus.Protocol.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/TovarV2
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/TovarV2
Executable file
Binary file not shown.
1417
TestTovarV2/bin/Debug/net8.0/TovarV2.deps.json
Normal file
1417
TestTovarV2/bin/Debug/net8.0/TovarV2.deps.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
TestTovarV2/bin/Debug/net8.0/TovarV2.dll
Normal file
BIN
TestTovarV2/bin/Debug/net8.0/TovarV2.dll
Normal file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/TovarV2.pdb
Normal file
BIN
TestTovarV2/bin/Debug/net8.0/TovarV2.pdb
Normal file
Binary file not shown.
13
TestTovarV2/bin/Debug/net8.0/TovarV2.runtimeconfig.json
Normal file
13
TestTovarV2/bin/Debug/net8.0/TovarV2.runtimeconfig.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net8.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "8.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Runtime.InteropServices.BuiltInComInterop.IsSupported": true,
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/cs/Microsoft.CodeAnalysis.Scripting.resources.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/cs/Microsoft.CodeAnalysis.Scripting.resources.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/cs/Microsoft.CodeAnalysis.resources.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/cs/Microsoft.CodeAnalysis.resources.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/de/Microsoft.CodeAnalysis.Scripting.resources.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/de/Microsoft.CodeAnalysis.Scripting.resources.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/de/Microsoft.CodeAnalysis.resources.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/de/Microsoft.CodeAnalysis.resources.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/es/Microsoft.CodeAnalysis.Scripting.resources.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/es/Microsoft.CodeAnalysis.Scripting.resources.dll
Executable file
Binary file not shown.
BIN
TestTovarV2/bin/Debug/net8.0/es/Microsoft.CodeAnalysis.resources.dll
Executable file
BIN
TestTovarV2/bin/Debug/net8.0/es/Microsoft.CodeAnalysis.resources.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user