From c5154811438897086da956f3989022c95523b878 Mon Sep 17 00:00:00 2001 From: flifloo Date: Wed, 18 May 2022 11:28:00 +0200 Subject: [PATCH] Move Tetris and TestTetris to one solution --- .gitignore | 2 +- TestTetris/.gitignore | 6 + TestTetris/GameTest.cs | 40 +++++ TestTetris/GridTest.cs | 169 ++++++++++++++++++ TestTetris/TestTetris.csproj | 21 +++ TestTetris/TetrominoeParserTest.cs | 27 +++ TestTetris/TetrominoeTest.cs | 107 +++++++++++ Tetris.sln | 20 +-- Tetris/.gitignore | 6 + App.xaml => Tetris/App.xaml | 0 App.xaml.cs => Tetris/App.xaml.cs | 0 AssemblyInfo.cs => Tetris/AssemblyInfo.cs | 0 {Models => Tetris/Models}/Game.cs | 0 {Models => Tetris/Models}/Grid.cs | 0 {Models => Tetris/Models}/Tetrominoe.cs | 0 {Models => Tetris/Models}/TetrominoeParser.cs | 0 {Resources => Tetris/Resources}/icon.ico | Bin {Resources => Tetris/Resources}/tetris.png | Bin .../Resources}/tetrominoes.json | 0 Tetris.csproj => Tetris/Tetris.csproj | 0 Tetris/Tetris.sln | 22 +++ Tetris/Tetris.sln.DotSettings.user | 13 ++ {Views => Tetris/Views}/GameWindow.xaml | 20 +-- {Views => Tetris/Views}/GameWindow.xaml.cs | 96 +++++----- {Views => Tetris/Views}/MainWindow.xaml | 0 {Views => Tetris/Views}/MainWindow.xaml.cs | 0 .../ViewsModels}/GameViewModel.cs | 0 .../ViewsModels}/ViewModel.cs | 0 28 files changed, 480 insertions(+), 69 deletions(-) create mode 100644 TestTetris/.gitignore create mode 100644 TestTetris/GameTest.cs create mode 100644 TestTetris/GridTest.cs create mode 100644 TestTetris/TestTetris.csproj create mode 100644 TestTetris/TetrominoeParserTest.cs create mode 100644 TestTetris/TetrominoeTest.cs create mode 100644 Tetris/.gitignore rename App.xaml => Tetris/App.xaml (100%) rename App.xaml.cs => Tetris/App.xaml.cs (100%) rename AssemblyInfo.cs => Tetris/AssemblyInfo.cs (100%) rename {Models => Tetris/Models}/Game.cs (100%) rename {Models => Tetris/Models}/Grid.cs (100%) rename {Models => Tetris/Models}/Tetrominoe.cs (100%) rename {Models => Tetris/Models}/TetrominoeParser.cs (100%) rename {Resources => Tetris/Resources}/icon.ico (100%) rename {Resources => Tetris/Resources}/tetris.png (100%) rename {Resources => Tetris/Resources}/tetrominoes.json (100%) rename Tetris.csproj => Tetris/Tetris.csproj (100%) create mode 100644 Tetris/Tetris.sln create mode 100644 Tetris/Tetris.sln.DotSettings.user rename {Views => Tetris/Views}/GameWindow.xaml (98%) rename {Views => Tetris/Views}/GameWindow.xaml.cs (96%) rename {Views => Tetris/Views}/MainWindow.xaml (100%) rename {Views => Tetris/Views}/MainWindow.xaml.cs (100%) rename {ViewsModels => Tetris/ViewsModels}/GameViewModel.cs (100%) rename {ViewsModels => Tetris/ViewsModels}/ViewModel.cs (100%) diff --git a/.gitignore b/.gitignore index 2ee7f15..3e2471e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/.idea/ +.idea/ bin/ obj/ /packages/ diff --git a/TestTetris/.gitignore b/TestTetris/.gitignore new file mode 100644 index 0000000..2ee7f15 --- /dev/null +++ b/TestTetris/.gitignore @@ -0,0 +1,6 @@ +/.idea/ +bin/ +obj/ +/packages/ +riderModule.iml +/_ReSharper.Caches/ \ No newline at end of file diff --git a/TestTetris/GameTest.cs b/TestTetris/GameTest.cs new file mode 100644 index 0000000..c00075d --- /dev/null +++ b/TestTetris/GameTest.cs @@ -0,0 +1,40 @@ +using System; +using System.Drawing; +using NUnit.Framework; +using Tetris.Models; + +namespace TestTetris; + +public class GameTest { + private Game g; + + [SetUp] + public void SetUp() { + g = new("test", new Grid(new Color[10,20])); + Console.Out.WriteLine("===={Grid w/ Tetrominoe}===="); + Console.Out.WriteLine(g.Grid.ToString(g.CurrentTetrominoe)); + Console.Out.WriteLine("============================"); + } + + [Test] + public void HitBottom() { + for (int i = 1; i < (g.Grid.MaxGrid.Y+1)-g.CurrentTetrominoe.Shape.GetLength(1)+1; i++) { + g.CurrentTetrominoe.GoDown(); + Console.Out.WriteLine(g.Grid.ToString(g.CurrentTetrominoe)); + } + + Assert.AreEqual(true, g.HitBottom()); + } + + [Test] + public void HitTop() { + Assert.False(g.HitTop()); + + for (int x = 0; x <= g.Grid.MaxGrid.X; x++) + g.Grid.CGrid[x,g.CurrentTetrominoe.Shape.GetLength(1)] = Color.Red; + + Console.Out.WriteLine(g.Grid.ToString(g.CurrentTetrominoe)); + + Assert.True(g.HitTop()); + } +} diff --git a/TestTetris/GridTest.cs b/TestTetris/GridTest.cs new file mode 100644 index 0000000..f494d0d --- /dev/null +++ b/TestTetris/GridTest.cs @@ -0,0 +1,169 @@ +using System; +using System.Drawing; +using NUnit.Framework; +using Tetris.Models; + +namespace TestTetris; + +public class GridTest { + private Color[,] ig; + private Grid g; + private Tetrominoe t; + private static readonly Random random = new Random(); + + [SetUp] + public void SetUp() { + ig = new Color[10, 20]; + g = new Grid(ig); + t = new Tetrominoe(g, new bool[,] { + {true, false, false}, + {true, true, true} + }, new Point(5, 0), 0, Color.Aqua); + Console.Out.WriteLine("===={Grid w/ Tetrominoe}===="); + Console.Out.WriteLine(g.ToString(t)); + Console.Out.WriteLine("============================"); + } + + [Test] + public void CanGoLeft() { + int startX = t.Coordinates.X; + int startY = t.Coordinates.Y; + Console.Out.WriteLine(t.Coordinates); + for (int i = 1; i <= startX - g.MinGrid.X; i++) { + t.GoLeft(); + Console.Out.WriteLine(g.ToString(t)); + Assert.AreEqual(new Point(startX-i, startY), t.Coordinates); + } + // Try over the left grid limit + Assert.AreEqual(new Point(g.MinGrid.X, startY), t.Coordinates); + t.GoLeft(); + Assert.AreEqual(new Point(g.MinGrid.X, startY), t.Coordinates); + } + + [Test] + public void CanGoRight() { + int startX = t.Coordinates.X; + int startY = t.Coordinates.Y; + Console.Out.WriteLine(t.Coordinates); + for (int i = 1; i < (g.MaxGrid.X+1)-startX-t.Shape.GetLength(0)+1; i++) { + t.GoRight(); + Console.Out.WriteLine(g.ToString(t)); + Assert.AreEqual(new Point(startX+i, startY), t.Coordinates); + } + // Try over the right grid limit + Assert.AreEqual(new Point((g.MaxGrid.X+1)-t.Shape.GetLength(0), startY), t.Coordinates); + t.GoRight(); + Assert.AreEqual(new Point((g.MaxGrid.X+1)-t.Shape.GetLength(0), startY), t.Coordinates); + } + + [Test] + public void CanGoDown() { + int startX = t.Coordinates.X; + int startY = t.Coordinates.Y; + for (int i = 1; i < (g.MaxGrid.Y+1)-t.Shape.GetLength(1)+1; i++) { + t.GoDown(); + Console.Out.WriteLine(g.ToString(t)); + Assert.AreEqual(new Point(startX, startY+i), t.Coordinates); + } + // Try over the grid depth limit + Assert.AreEqual(new Point(startX, (g.MaxGrid.Y+1)-t.Shape.GetLength(1)), t.Coordinates); + t.GoDown(); + Assert.AreEqual(new Point(startX, (g.MaxGrid.Y+1)-t.Shape.GetLength(1)), t.Coordinates); + } + + [Test] + public void CanRotate() { + bool[,] shape = new bool[,] { + {true, false, false}, + {true, true, true} + }; + int longestShapeBorder; + if (shape.GetLength(0) > shape.GetLength(1)) + longestShapeBorder = shape.GetLength(0); + else + longestShapeBorder = shape.GetLength(1); + + g = new Grid(new Color[longestShapeBorder, longestShapeBorder]); + t = new Tetrominoe(g, shape, new Point(0, 0), 0, Color.Aqua); + Console.Out.WriteLine(g.ToString(t)); + + t.RotateLeft(); + Console.Out.WriteLine(g.ToString(t)); + Assert.AreEqual(3, t.Orientation); + t.RotateLeft(); + Console.Out.WriteLine(g.ToString(t)); + Assert.AreEqual(2, t.Orientation); + t.RotateLeft(); + Console.Out.WriteLine(g.ToString(t)); + Assert.AreEqual(1, t.Orientation); + t.RotateLeft(); + Console.Out.WriteLine(g.ToString(t)); + Assert.AreEqual(0, t.Orientation); + } + + [Test] + public void CantGo() { + ig[4, 0] = Color.Red; + ig[4, 1] = Color.Red; + ig[4, 2] = Color.Red; + ig[4, 3] = Color.Red; + ig[5, 3] = Color.Red; + ig[6, 3] = Color.Red; + ig[7, 3] = Color.Red; + ig[7, 2] = Color.Red; + ig[7, 1] = Color.Red; + ig[7, 0] = Color.Red; + + Console.Out.WriteLine(g.ToString(t)); + int startX = t.Coordinates.X; + int startY = t.Coordinates.Y; + int startOrientation = t.Orientation; + t.GoDown(); + Assert.AreEqual(new Point(startX, startY), t.Coordinates); + t.GoLeft(); + Assert.AreEqual(new Point(startX, startY), t.Coordinates); + t.GoRight(); + Assert.AreEqual(new Point(startX, startY), t.Coordinates); + t.RotateLeft(); + Assert.AreEqual(startOrientation, t.Orientation); + t.RotateRight(); + Assert.AreEqual(startOrientation, t.Orientation); + } + + [Test] + public void LineFull() { + Console.Out.WriteLine(g.ToString()); + Assert.False(g.LineFull()); + + for (int x = 0; x < ig.GetLength(0); x++) + ig[x, ig.GetLength(1) - 1] = Color.Aqua; + + Console.Out.WriteLine("=========="); + Console.Out.WriteLine(g.ToString()); + Assert.True(g.LineFull()); + } + + [Test] + public void ClearLine() { + for (uint x = 0; x < ig.GetLength(0); x++) + for (uint y = 0; y < ig.GetLength(1); y++) { + ig[x, y] = Color.FromArgb(random.Next(256), random.Next(256), random.Next(256)); + } + + for (int x = 0; x < ig.GetLength(0); x++) + ig[x, ig.GetLength(1) - 1] = Color.Aqua; + + Color[,] olg_grid = (Color[,])ig.Clone(); + Console.Out.WriteLine(g.ToString()); + g.ClearLine(); + Console.Out.WriteLine("=========="); + Console.Out.WriteLine(g.ToString()); + for (uint x = 0; x < ig.GetLength(0); x++) + for (uint y = 1; y < ig.GetLength(1); y++) { + Assert.AreEqual(olg_grid[x, y-1], ig[x,y]); + } + + for (uint x = 0; x < ig.GetLength(0); x++) + Assert.AreEqual(Color.Empty, ig[x, 0]); + } +} diff --git a/TestTetris/TestTetris.csproj b/TestTetris/TestTetris.csproj new file mode 100644 index 0000000..e0497a2 --- /dev/null +++ b/TestTetris/TestTetris.csproj @@ -0,0 +1,21 @@ + + + + net6.0-windows + enable + + false + + + + + + + + + + + + + + diff --git a/TestTetris/TetrominoeParserTest.cs b/TestTetris/TetrominoeParserTest.cs new file mode 100644 index 0000000..302cb18 --- /dev/null +++ b/TestTetris/TetrominoeParserTest.cs @@ -0,0 +1,27 @@ +using System; +using System.Drawing; +using NUnit.Framework; +using Tetris.Models; + +namespace TestTetris; + +public class TetrominoeParserTest { + [Test] + public void TestAll() { + bool[,] shape; + Tetrominoe t; + foreach (String name in TetrominoeParser.List()) { + Console.Out.WriteLine("====={"+name+"}====="); + Grid g = new Grid(new Color[10, 20]); + t = new Tetrominoe(g, name); + Console.Out.WriteLine(t); + } + } + + [Test] + public void NotFound() { + Assert.Throws(delegate { + TetrominoeParser.GetShape("azertyuiop"); + }); + } +} diff --git a/TestTetris/TetrominoeTest.cs b/TestTetris/TetrominoeTest.cs new file mode 100644 index 0000000..6485f95 --- /dev/null +++ b/TestTetris/TetrominoeTest.cs @@ -0,0 +1,107 @@ +using System; +using System.Drawing; +using NUnit.Framework; +using Tetris.Models; +using Point = System.Drawing.Point; + +namespace TestTetris; + +public class TetrominoeTest { + private Tetrominoe t; + private Grid g; + + [SetUp] + public void SetUp() { + g = new Grid(new Color[10, 20]); + t = new Tetrominoe(g, new bool[,] { + {true, false, false}, + {true, true, true} + }, new Point(5, 10), 0, Color.Aqua); + Console.Out.WriteLine("===={Grid w/ Tetrominoe}===="); + Console.Out.WriteLine(g.ToString(t)); + Console.Out.WriteLine("============================"); + } + + [Test] + public void ShapeRotate() { + Assert.AreEqual(new bool[,] { + {true, false, false}, + {true, true, true} + }, t.Shape); + t.RotateRight(); + Console.Out.WriteLine(t); + Assert.AreEqual(new bool[,] { + {true, true}, + {true, false}, + {true, false} + }, t.Shape); + t.RotateRight(); + Console.Out.WriteLine(t); + Assert.AreEqual(new bool[,] { + {true, true, true}, + {false, false, true} + }, t.Shape); + t.RotateRight(); + Console.Out.WriteLine(t); + Assert.AreEqual(new bool[,] { + {false, true}, + {false, true}, + {true, true} + }, t.Shape); + t.RotateRight(); + Console.Out.WriteLine(t); + Assert.AreEqual(new bool[,] { + {true, false, false}, + {true, true, true} + }, t.Shape); + } + + [Test] + public void Orientation() { + t.Orientation = 0; + Assert.AreEqual(0, t.Orientation); + t.RotateLeft(); + Assert.AreEqual(3, t.Orientation); + t.RotateLeft(); + Assert.AreEqual(2, t.Orientation); + t.RotateLeft(); + Assert.AreEqual(1, t.Orientation); + t.RotateLeft(); + Assert.AreEqual(0, t.Orientation); + t.Orientation = 3; + t.RotateRight(); + Assert.AreEqual(0, t.Orientation); + t.RotateRight(); + Assert.AreEqual(1, t.Orientation); + t.RotateRight(); + Assert.AreEqual(2, t.Orientation); + t.RotateRight(); + Assert.AreEqual(3, t.Orientation); + t.RotateRight(); + Assert.AreEqual(0, t.Orientation); + } + + [Test] + public void GoRight() { + int startX = t.Coordinates.X; + int startY = t.Coordinates.Y; + t.GoRight(); + Assert.AreEqual(new Point(startX+1, startY), t.Coordinates); + } + + [Test] + public void GoLeft() { + int startX = t.Coordinates.X; + int startY = t.Coordinates.Y; + t.GoLeft(); + Assert.AreEqual(new Point(startX-1, startY), t.Coordinates); + } + + [Test] + public void GoDown() { + int startX = t.Coordinates.X; + int startY = t.Coordinates.Y; + t.GoDown(); + Assert.AreEqual(new Point(startX,startY+1), t.Coordinates); + } +} diff --git a/Tetris.sln b/Tetris.sln index 47ba5a3..549014b 100644 --- a/Tetris.sln +++ b/Tetris.sln @@ -1,8 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tetris", "Tetris.csproj", "{1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tetris", "Tetris\Tetris.csproj", "{F884CDE3-B3CD-46C4-9396-052B16729A66}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestTetris", "..\TestTetris\TestTetris.csproj", "{2924F978-4A50-4B23-BCEC-6AB822F236AE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestTetris", "TestTetris\TestTetris.csproj", "{D006D92B-5B5E-4CE0-A40E-C47669CC9E5F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -10,13 +10,13 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Release|Any CPU.Build.0 = Release|Any CPU - {2924F978-4A50-4B23-BCEC-6AB822F236AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2924F978-4A50-4B23-BCEC-6AB822F236AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2924F978-4A50-4B23-BCEC-6AB822F236AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2924F978-4A50-4B23-BCEC-6AB822F236AE}.Release|Any CPU.Build.0 = Release|Any CPU + {F884CDE3-B3CD-46C4-9396-052B16729A66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F884CDE3-B3CD-46C4-9396-052B16729A66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F884CDE3-B3CD-46C4-9396-052B16729A66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F884CDE3-B3CD-46C4-9396-052B16729A66}.Release|Any CPU.Build.0 = Release|Any CPU + {D006D92B-5B5E-4CE0-A40E-C47669CC9E5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D006D92B-5B5E-4CE0-A40E-C47669CC9E5F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D006D92B-5B5E-4CE0-A40E-C47669CC9E5F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D006D92B-5B5E-4CE0-A40E-C47669CC9E5F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Tetris/.gitignore b/Tetris/.gitignore new file mode 100644 index 0000000..2ee7f15 --- /dev/null +++ b/Tetris/.gitignore @@ -0,0 +1,6 @@ +/.idea/ +bin/ +obj/ +/packages/ +riderModule.iml +/_ReSharper.Caches/ \ No newline at end of file diff --git a/App.xaml b/Tetris/App.xaml similarity index 100% rename from App.xaml rename to Tetris/App.xaml diff --git a/App.xaml.cs b/Tetris/App.xaml.cs similarity index 100% rename from App.xaml.cs rename to Tetris/App.xaml.cs diff --git a/AssemblyInfo.cs b/Tetris/AssemblyInfo.cs similarity index 100% rename from AssemblyInfo.cs rename to Tetris/AssemblyInfo.cs diff --git a/Models/Game.cs b/Tetris/Models/Game.cs similarity index 100% rename from Models/Game.cs rename to Tetris/Models/Game.cs diff --git a/Models/Grid.cs b/Tetris/Models/Grid.cs similarity index 100% rename from Models/Grid.cs rename to Tetris/Models/Grid.cs diff --git a/Models/Tetrominoe.cs b/Tetris/Models/Tetrominoe.cs similarity index 100% rename from Models/Tetrominoe.cs rename to Tetris/Models/Tetrominoe.cs diff --git a/Models/TetrominoeParser.cs b/Tetris/Models/TetrominoeParser.cs similarity index 100% rename from Models/TetrominoeParser.cs rename to Tetris/Models/TetrominoeParser.cs diff --git a/Resources/icon.ico b/Tetris/Resources/icon.ico similarity index 100% rename from Resources/icon.ico rename to Tetris/Resources/icon.ico diff --git a/Resources/tetris.png b/Tetris/Resources/tetris.png similarity index 100% rename from Resources/tetris.png rename to Tetris/Resources/tetris.png diff --git a/Resources/tetrominoes.json b/Tetris/Resources/tetrominoes.json similarity index 100% rename from Resources/tetrominoes.json rename to Tetris/Resources/tetrominoes.json diff --git a/Tetris.csproj b/Tetris/Tetris.csproj similarity index 100% rename from Tetris.csproj rename to Tetris/Tetris.csproj diff --git a/Tetris/Tetris.sln b/Tetris/Tetris.sln new file mode 100644 index 0000000..47ba5a3 --- /dev/null +++ b/Tetris/Tetris.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tetris", "Tetris.csproj", "{1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestTetris", "..\TestTetris\TestTetris.csproj", "{2924F978-4A50-4B23-BCEC-6AB822F236AE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F3B4D12-6E23-49A6-BC9C-5E274CA63B57}.Release|Any CPU.Build.0 = Release|Any CPU + {2924F978-4A50-4B23-BCEC-6AB822F236AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2924F978-4A50-4B23-BCEC-6AB822F236AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2924F978-4A50-4B23-BCEC-6AB822F236AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2924F978-4A50-4B23-BCEC-6AB822F236AE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Tetris/Tetris.sln.DotSettings.user b/Tetris/Tetris.sln.DotSettings.user new file mode 100644 index 0000000..222a7a8 --- /dev/null +++ b/Tetris/Tetris.sln.DotSettings.user @@ -0,0 +1,13 @@ + + <SessionState ContinuousTestingMode="0" IsActive="True" Name="GridTest" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <TestAncestor> + <TestId>NUnit3x::2924F978-4A50-4B23-BCEC-6AB822F236AE::net6.0-windows7.0::TestTetris.GridTest</TestId> + <TestId>NUnit3x::2924F978-4A50-4B23-BCEC-6AB822F236AE::net6.0-windows7.0::TestTetris.TetrominoeTest</TestId> + <TestId>NUnit3x::2924F978-4A50-4B23-BCEC-6AB822F236AE::net6.0-windows7.0::TestTetris.TetrominoeParserTest.test</TestId> + <TestId>NUnit3x::2924F978-4A50-4B23-BCEC-6AB822F236AE::net6.0-windows7.0::TestTetris.TetrominoeParserTest</TestId> + <TestId>NUnit3x::2924F978-4A50-4B23-BCEC-6AB822F236AE::net6.0-windows7.0::TestTetris.GameTest.HitBottom</TestId> + <TestId>NUnit3x::2924F978-4A50-4B23-BCEC-6AB822F236AE::net6.0-windows7.0::TestTetris.GameTest.HitTop</TestId> + </TestAncestor> +</SessionState> + + \ No newline at end of file diff --git a/Views/GameWindow.xaml b/Tetris/Views/GameWindow.xaml similarity index 98% rename from Views/GameWindow.xaml rename to Tetris/Views/GameWindow.xaml index 4014365..135dfac 100644 --- a/Views/GameWindow.xaml +++ b/Tetris/Views/GameWindow.xaml @@ -1,11 +1,11 @@ - - - - + + + + \ No newline at end of file diff --git a/Views/GameWindow.xaml.cs b/Tetris/Views/GameWindow.xaml.cs similarity index 96% rename from Views/GameWindow.xaml.cs rename to Tetris/Views/GameWindow.xaml.cs index dda3d64..b6bb3c2 100644 --- a/Views/GameWindow.xaml.cs +++ b/Tetris/Views/GameWindow.xaml.cs @@ -1,49 +1,49 @@ -using System; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Input; -using Tetris.ViewsModels; - -namespace Tetris.Views; - -public partial class GameWindow : Window -{ - private static readonly GameViewModel GameViewModel = new(); - - public GameWindow() - { - AttachConsole(-1); - InitializeComponent(); - DataContext = GameViewModel; - } - - [DllImport("kernel32.dll")] - private static extern bool AttachConsole(int dwProcessId); - - private void UIElement_OnKeyDown(object sender, KeyEventArgs e) - { - // If key is space - if (e.Key == Key.Space) - { - GameViewModel.Game.CurrentTetrominoe?.RotateRight(); - } - - // If key is down - else if (e.Key == Key.Down) - { - GameViewModel.Game.CurrentTetrominoe?.GoDown(); - } - - // If key is left - else if (e.Key == Key.Left) - { - GameViewModel.Game.CurrentTetrominoe?.GoLeft(); - } - - // If key is right - else if (e.Key == Key.Right) - { - GameViewModel.Game.CurrentTetrominoe?.GoRight(); - } - } +using System; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Input; +using Tetris.ViewsModels; + +namespace Tetris.Views; + +public partial class GameWindow : Window +{ + private static readonly GameViewModel GameViewModel = new(); + + public GameWindow() + { + AttachConsole(-1); + InitializeComponent(); + DataContext = GameViewModel; + } + + [DllImport("kernel32.dll")] + private static extern bool AttachConsole(int dwProcessId); + + private void UIElement_OnKeyDown(object sender, KeyEventArgs e) + { + // If key is space + if (e.Key == Key.Space) + { + GameViewModel.Game.CurrentTetrominoe?.RotateRight(); + } + + // If key is down + else if (e.Key == Key.Down) + { + GameViewModel.Game.CurrentTetrominoe?.GoDown(); + } + + // If key is left + else if (e.Key == Key.Left) + { + GameViewModel.Game.CurrentTetrominoe?.GoLeft(); + } + + // If key is right + else if (e.Key == Key.Right) + { + GameViewModel.Game.CurrentTetrominoe?.GoRight(); + } + } } \ No newline at end of file diff --git a/Views/MainWindow.xaml b/Tetris/Views/MainWindow.xaml similarity index 100% rename from Views/MainWindow.xaml rename to Tetris/Views/MainWindow.xaml diff --git a/Views/MainWindow.xaml.cs b/Tetris/Views/MainWindow.xaml.cs similarity index 100% rename from Views/MainWindow.xaml.cs rename to Tetris/Views/MainWindow.xaml.cs diff --git a/ViewsModels/GameViewModel.cs b/Tetris/ViewsModels/GameViewModel.cs similarity index 100% rename from ViewsModels/GameViewModel.cs rename to Tetris/ViewsModels/GameViewModel.cs diff --git a/ViewsModels/ViewModel.cs b/Tetris/ViewsModels/ViewModel.cs similarity index 100% rename from ViewsModels/ViewModel.cs rename to Tetris/ViewsModels/ViewModel.cs