From f37099e8bfa167bb0e6e7f704dec7ee41a6af513 Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 16:54:48 +0200 Subject: [PATCH 01/16] yml file za github actions --- .github/workflows/test_branch_push.yml | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/test_branch_push.yml diff --git a/.github/workflows/test_branch_push.yml b/.github/workflows/test_branch_push.yml new file mode 100644 index 0000000..3285519 --- /dev/null +++ b/.github/workflows/test_branch_push.yml @@ -0,0 +1,35 @@ +name: Build and run unit test on branch push + +on: + push: + branches: + - 45-nova-funkcionalnost-13 + pull_request: + branches: + - 45-nova-funkcionalnost-13 + workflow_dispatch: + +jobs: + buildTest: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.6 + + - name: Install MSBuild + uses: microsoft/setup-msbuild@v2 + + - name: Install NuGet + uses: nuget/setup-nuget@v2 + + - name: Restore dependencies + run: nuget restore Software\E_Libra\E_Libra.sln + + - name: Build solution + run: msbuild.exe Software\E_Libra\E_Libra.sln /p:platform="Any CPU" /p:configuration="Debug" + + - name: Build Unit Test project + run: dotnet build Software\E_Libra\UnitTesting\UnitTesting.csproj --configuration Debug + + - name: Run unit tests + run: dotnet test Software\E_Libra\UnitTesting\UnitTesting.csproj --no-build --verbosity normal \ No newline at end of file From a8e3cdc0f0389648f5274d4496c79599066f0010 Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 16:57:31 +0200 Subject: [PATCH 02/16] Testiranje github actions na push --- Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs index b0678ac..be59f23 100644 --- a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs +++ b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs @@ -5,6 +5,6 @@ using System.Threading.Tasks; namespace UnitTesting.Nove_funkcionalnosti.F13 { - internal class Class1 { + public class Class1 { } } From 40012ad5ca6112da2acbc9524a3f5b0f54ce4985 Mon Sep 17 00:00:00 2001 From: vlovric21 <126573506+vlovric21@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:59:03 +0200 Subject: [PATCH 03/16] Popravak krivog imena brancha --- .github/workflows/test_branch_push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_branch_push.yml b/.github/workflows/test_branch_push.yml index 3285519..499dead 100644 --- a/.github/workflows/test_branch_push.yml +++ b/.github/workflows/test_branch_push.yml @@ -3,10 +3,10 @@ name: Build and run unit test on branch push on: push: branches: - - 45-nova-funkcionalnost-13 + - 45-nova-funkcionalnost-f13 pull_request: branches: - - 45-nova-funkcionalnost-13 + - 45-nova-funkcionalnost-f13 workflow_dispatch: jobs: @@ -32,4 +32,4 @@ jobs: run: dotnet build Software\E_Libra\UnitTesting\UnitTesting.csproj --configuration Debug - name: Run unit tests - run: dotnet test Software\E_Libra\UnitTesting\UnitTesting.csproj --no-build --verbosity normal \ No newline at end of file + run: dotnet test Software\E_Libra\UnitTesting\UnitTesting.csproj --no-build --verbosity normal From 3d2d23dcd3bd8901ad7fbfbf5534574df62eafb4 Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 16:59:34 +0200 Subject: [PATCH 04/16] Jos jedna provjera --- .../E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs index be59f23..404bbd3 100644 --- a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs +++ b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; namespace UnitTesting.Nove_funkcionalnosti.F13 { - public class Class1 { + public class Class1 + { + //test } } From 56c6a5f8647670d285dab62dbcee2abdc49134a4 Mon Sep 17 00:00:00 2001 From: vlovric21 <126573506+vlovric21@users.noreply.github.com> Date: Fri, 14 Jun 2024 17:03:20 +0200 Subject: [PATCH 05/16] Rename yml filea --- .github/workflows/{test_branch_push.yml => build_test_f13.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{test_branch_push.yml => build_test_f13.yml} (100%) diff --git a/.github/workflows/test_branch_push.yml b/.github/workflows/build_test_f13.yml similarity index 100% rename from .github/workflows/test_branch_push.yml rename to .github/workflows/build_test_f13.yml From 66877bd343df4887b3e92b30d0c3a6b02686c36c Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 19:17:50 +0200 Subject: [PATCH 06/16] Napravljene front end promjene za search --- .../PresentationLayer/UcAddNewBook.xaml | 43 +++++++++++++------ .../PresentationLayer/UcAddNewBook.xaml.cs | 10 +++++ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml index 0b425a2..55dc817 100644 --- a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml +++ b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml @@ -50,18 +50,37 @@ - - - - - - - - - - + + + + + + + + + + + + + diff --git a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs index 2247c62..c871590 100644 --- a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs +++ b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs @@ -216,5 +216,15 @@ private void UcNewGenre_ButtonClicked(object sender, EventArgs e) { LoadGenres(); } + + private void txtSearchGenre_TextChanged(object sender, TextChangedEventArgs e) + { + + } + + private void txtSearchAuthor_TextChanged(object sender, TextChangedEventArgs e) + { + + } } } From 9c865ed998e6beabfa2f6f50b8373f85f8ae2dd1 Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 19:34:26 +0200 Subject: [PATCH 07/16] =?UTF-8?q?Napravljeno=20pretra=C5=BEivanje=20za=20a?= =?UTF-8?q?utora?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BussinessLogicLayer/services/AuthorService.cs | 5 +++++ .../Interfaces/IAuthorRepository.cs | 1 + .../Repositories/AuthorRepository.cs | 8 ++++++++ .../PresentationLayer/UcAddNewBook.xaml.cs | 15 +++++++++++++-- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Software/E_Libra/BussinessLogicLayer/services/AuthorService.cs b/Software/E_Libra/BussinessLogicLayer/services/AuthorService.cs index c8e1718..7032b58 100644 --- a/Software/E_Libra/BussinessLogicLayer/services/AuthorService.cs +++ b/Software/E_Libra/BussinessLogicLayer/services/AuthorService.cs @@ -50,5 +50,10 @@ public bool AddAuthor(Author author) return isSuccesful; } + + public List SearchAuthors(string search) + { + return authorRepository.SearchAuthor(search); + } } } diff --git a/Software/E_Libra/DataAccessLayer/Interfaces/IAuthorRepository.cs b/Software/E_Libra/DataAccessLayer/Interfaces/IAuthorRepository.cs index eee4d69..4330fd1 100644 --- a/Software/E_Libra/DataAccessLayer/Interfaces/IAuthorRepository.cs +++ b/Software/E_Libra/DataAccessLayer/Interfaces/IAuthorRepository.cs @@ -11,5 +11,6 @@ public interface IAuthorRepository : IDisposable { IQueryable GetAll(); int Add(Author entity, bool saveChanges = true); + List SearchAuthor(string search); } } diff --git a/Software/E_Libra/DataAccessLayer/Repositories/AuthorRepository.cs b/Software/E_Libra/DataAccessLayer/Repositories/AuthorRepository.cs index f7d4d89..21cee49 100644 --- a/Software/E_Libra/DataAccessLayer/Repositories/AuthorRepository.cs +++ b/Software/E_Libra/DataAccessLayer/Repositories/AuthorRepository.cs @@ -53,5 +53,13 @@ private int GetAuthorNextId() return lastId + 1; } + + public List SearchAuthor(string search) + { + var sql = from a in Entities + where a.name.Contains(search) || a.surname.Contains(search) + select a; + return sql.ToList(); + } } } diff --git a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs index c871590..1f78bc8 100644 --- a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs +++ b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs @@ -219,12 +219,23 @@ private void UcNewGenre_ButtonClicked(object sender, EventArgs e) private void txtSearchGenre_TextChanged(object sender, TextChangedEventArgs e) { - + } private void txtSearchAuthor_TextChanged(object sender, TextChangedEventArgs e) { - + string search = txtSearchAuthor.Text; + if (string.IsNullOrEmpty(search)) + { + LoadAuthors(); + } + else + { + using (AuthorService authorService = new AuthorService()) + { + cmbAuthor.ItemsSource = authorService.SearchAuthors(search); + } + } } } } From f4dbc9a856b1915c5927c90487e3ef918f3b6427 Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 19:38:47 +0200 Subject: [PATCH 08/16] =?UTF-8?q?Napravljeno=20pretra=C5=BEivanje=20=C5=BE?= =?UTF-8?q?anrova?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BussinessLogicLayer/services/GenreServices.cs | 5 +++++ .../DataAccessLayer/Interfaces/IGenreRepository.cs | 1 + .../DataAccessLayer/Repositories/GenreRepository.cs | 8 ++++++++ .../E_Libra/PresentationLayer/UcAddNewBook.xaml.cs | 13 ++++++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Software/E_Libra/BussinessLogicLayer/services/GenreServices.cs b/Software/E_Libra/BussinessLogicLayer/services/GenreServices.cs index 4b15744..4081bac 100644 --- a/Software/E_Libra/BussinessLogicLayer/services/GenreServices.cs +++ b/Software/E_Libra/BussinessLogicLayer/services/GenreServices.cs @@ -51,5 +51,10 @@ public bool Add(Genre entity) return isSuccesful; } + + public List SearchGenres(string search) + { + return genreRepository.SearchGenre(search); + } } } diff --git a/Software/E_Libra/DataAccessLayer/Interfaces/IGenreRepository.cs b/Software/E_Libra/DataAccessLayer/Interfaces/IGenreRepository.cs index 6fab5da..aece4f1 100644 --- a/Software/E_Libra/DataAccessLayer/Interfaces/IGenreRepository.cs +++ b/Software/E_Libra/DataAccessLayer/Interfaces/IGenreRepository.cs @@ -13,5 +13,6 @@ public interface IGenreRepository : IDisposable IQueryable GetAll(); int Add(Genre entity, bool saveChanges = true); IQueryable GetMostPopularGenres(int Library_id); + List SearchGenre(string search); } } diff --git a/Software/E_Libra/DataAccessLayer/Repositories/GenreRepository.cs b/Software/E_Libra/DataAccessLayer/Repositories/GenreRepository.cs index 45e4956..9a68efe 100644 --- a/Software/E_Libra/DataAccessLayer/Repositories/GenreRepository.cs +++ b/Software/E_Libra/DataAccessLayer/Repositories/GenreRepository.cs @@ -60,6 +60,14 @@ group genre.name by genre into genreGroup return query; } + public List SearchGenre(string search) + { + var sql = from g in Entities + where g.name.Contains(search) + select g; + return sql.ToList(); + } + } } diff --git a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs index 1f78bc8..44bbc3e 100644 --- a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs +++ b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs @@ -219,7 +219,18 @@ private void UcNewGenre_ButtonClicked(object sender, EventArgs e) private void txtSearchGenre_TextChanged(object sender, TextChangedEventArgs e) { - + string search = txtSearchGenre.Text; + if (string.IsNullOrEmpty(search)) + { + LoadGenres(); + } + else + { + using(GenreServices genreServices = new GenreServices()) + { + cmbGenre.ItemsSource = genreServices.SearchGenres(search); + } + } } private void txtSearchAuthor_TextChanged(object sender, TextChangedEventArgs e) From 348c198d9431a7be5bf5c093e83dc6e61d6fb30b Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 19:49:21 +0200 Subject: [PATCH 09/16] Postavljene testne klase i napravljen test za autora --- .../F13/AuthorService_Test.cs | 44 +++++++++++++++++++ .../Nove funkcionalnosti/F13/Class1.cs | 12 ----- .../F13/GenreServices_Test.cs | 18 ++++++++ 3 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/AuthorService_Test.cs delete mode 100644 Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs create mode 100644 Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/GenreServices_Test.cs diff --git a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/AuthorService_Test.cs b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/AuthorService_Test.cs new file mode 100644 index 0000000..b099592 --- /dev/null +++ b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/AuthorService_Test.cs @@ -0,0 +1,44 @@ +using BussinessLogicLayer.services; +using DataAccessLayer.Interfaces; +using EntitiesLayer; +using FakeItEasy; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace UnitTesting.Nove_funkcionalnosti.F13 { + public class AuthorService_Test + { + readonly IAuthorRepository repo; + readonly AuthorService service; + + public AuthorService_Test() + { + repo = A.Fake(); + service = new AuthorService(repo); + } + + //Viktor Lovrić + [Fact] + public void SearchAuthors_GivenStringIsPassed_ReturnsAuthors() + { + //Arrange + var authors = new List + { + new Author { idAuthor = 1, name = "Author1", surname = "Surname1", birth_date = DateTime.Now }, + new Author { idAuthor = 2, name = "Author2", surname = "Surname2", birth_date = DateTime.Now }, + }; + + A.CallTo(() => repo.SearchAuthor("Author")).Returns(authors); + + //Act + var result = service.SearchAuthors("Author"); + + //Assert + Assert.Equal(authors, result); + } + } +} diff --git a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs deleted file mode 100644 index 404bbd3..0000000 --- a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/Class1.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UnitTesting.Nove_funkcionalnosti.F13 { - public class Class1 - { - //test - } -} diff --git a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/GenreServices_Test.cs b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/GenreServices_Test.cs new file mode 100644 index 0000000..e692fdb --- /dev/null +++ b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/GenreServices_Test.cs @@ -0,0 +1,18 @@ +using BussinessLogicLayer.services; +using DataAccessLayer.Interfaces; +using EntitiesLayer; +using FakeItEasy; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace UnitTesting.Nove_funkcionalnosti.F13 +{ + public class GenreServices_Test + { + + } +} From 16d4f34c00cdbfb7c2ba63d1383f91d0d2abed70 Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 19:51:45 +0200 Subject: [PATCH 10/16] =?UTF-8?q?Napravljen=20test=20za=20=C5=BEanr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../F13/GenreServices_Test.cs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/GenreServices_Test.cs b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/GenreServices_Test.cs index e692fdb..8548cbc 100644 --- a/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/GenreServices_Test.cs +++ b/Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/GenreServices_Test.cs @@ -13,6 +13,33 @@ namespace UnitTesting.Nove_funkcionalnosti.F13 { public class GenreServices_Test { - + readonly IGenreRepository repo; + readonly GenreServices service; + + public GenreServices_Test() + { + repo = A.Fake(); + service = new GenreServices(repo); + } + + //Viktor Lovrić + [Fact] + public void SearchGenres_GivenStringIsPassed_ReturnsGenres() + { + //Arrange + var genres = new List + { + new Genre { name = "Genre1" }, + new Genre { name = "Genre2" } + }; + + A.CallTo(() => repo.SearchGenre("Genre")).Returns(genres); + + //Act + var result = service.SearchGenres("Genre"); + + //Assert + Assert.Equal(genres, result); + } } } From b851c2640811b3ec56e454156bd6f178b021bda8 Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 20:07:40 +0200 Subject: [PATCH 11/16] Postavljene testne klase za integracijsko testiranje --- .../F13/AuthorService_intTest.cs | 26 +++++++++++++++++++ .../Nove funkcionalnosti/F13/Class1.cs | 12 --------- .../F13/GenreServices_intTest.cs | 23 ++++++++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs delete mode 100644 Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/Class1.cs create mode 100644 Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs diff --git a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs new file mode 100644 index 0000000..ded293d --- /dev/null +++ b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; +using FluentAssertions; +using BussinessLogicLayer.services; + +namespace IntegrationTesting.Nove_funkcionalnosti.F13 +{ + [Collection("Database collection")] + public class AuthorService_intTest + { + readonly AuthorService service; + readonly DatabaseFixture fixture; + + public AuthorService_intTest(DatabaseFixture fixture) + { + this.fixture = fixture; + this.fixture.ResetDatabase(); + service = new AuthorService(); + } + + } +} diff --git a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/Class1.cs b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/Class1.cs deleted file mode 100644 index a8ea59e..0000000 --- a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/Class1.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IntegrationTesting.Nove_funkcionalnosti.F13 -{ - internal class Class1 - { - } -} diff --git a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs new file mode 100644 index 0000000..852ea41 --- /dev/null +++ b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs @@ -0,0 +1,23 @@ +using BussinessLogicLayer.services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IntegrationTesting.Nove_funkcionalnosti.F13 +{ + public class GenreServices_intTest + { + readonly GenreServices services; + readonly DatabaseFixture fixture; + + public GenreServices_intTest(DatabaseFixture fixture) + { + this.fixture = fixture; + this.fixture.ResetDatabase(); + services = new GenreServices(); + } + + } +} From 6009b91b554447b045d0eba7bfd40981d179c8d9 Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 20:15:11 +0200 Subject: [PATCH 12/16] Postavljene klase i napravljen test za AuthorService --- .../F13/AuthorService_intTest.cs | 24 +++++++++++++++++++ .../F13/GenreServices_intTest.cs | 3 +++ 2 files changed, 27 insertions(+) diff --git a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs index ded293d..6ce579a 100644 --- a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs +++ b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs @@ -6,6 +6,7 @@ using Xunit; using FluentAssertions; using BussinessLogicLayer.services; +using EntitiesLayer; namespace IntegrationTesting.Nove_funkcionalnosti.F13 { @@ -22,5 +23,28 @@ public AuthorService_intTest(DatabaseFixture fixture) service = new AuthorService(); } + + //Viktor Lovrić + [Fact] + public void SearchAuthors_GivenStringIsPassed_ReturnsAuthors() + { + //Arrange + string sql = + "INSERT [dbo].[Author] ([name], [surname], [birth_date]) VALUES (N'Author1', N'Surname1', '2021-06-01') " + + "INSERT [dbo].[Author] ([name], [surname], [birth_date]) VALUES (N'Author2', N'Surname2', '2021-06-01') " + + "INSERT [dbo].[Author] ([name], [surname], [birth_date]) VALUES (N'Drugaciji', N'Oddrugih', '2021-06-01') "; + Helper.ExecuteCustomSql(sql); + + var authors = new List + { + new Author { idAuthor = 1, name = "Drugaciji", surname = "Oddrugih", birth_date = DateTime.Parse("2021-06-01") } + }; + + //Act + var result = service.SearchAuthors("Drug"); + + //Assert + result.Should().BeEquivalentTo(authors); + } } } diff --git a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs index 852ea41..d4bd3d5 100644 --- a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs +++ b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs @@ -4,9 +4,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Xunit; namespace IntegrationTesting.Nove_funkcionalnosti.F13 { + [Collection("Database collection")] public class GenreServices_intTest { readonly GenreServices services; @@ -19,5 +21,6 @@ public GenreServices_intTest(DatabaseFixture fixture) services = new GenreServices(); } + } } From c4dcf860990ebd26371e1a4b2876ef10a9ae1c8d Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Fri, 14 Jun 2024 20:21:08 +0200 Subject: [PATCH 13/16] Napravljeni integracijski testovi --- .../F13/AuthorService_intTest.cs | 8 +++--- .../F13/GenreServices_intTest.cs | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs index 6ce579a..1951a1c 100644 --- a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs +++ b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs @@ -30,14 +30,14 @@ public void SearchAuthors_GivenStringIsPassed_ReturnsAuthors() { //Arrange string sql = - "INSERT [dbo].[Author] ([name], [surname], [birth_date]) VALUES (N'Author1', N'Surname1', '2021-06-01') " + - "INSERT [dbo].[Author] ([name], [surname], [birth_date]) VALUES (N'Author2', N'Surname2', '2021-06-01') " + - "INSERT [dbo].[Author] ([name], [surname], [birth_date]) VALUES (N'Drugaciji', N'Oddrugih', '2021-06-01') "; + "INSERT [dbo].[Author] ([idAuthor], [name], [surname], [birth_date]) VALUES (1, N'Author1', N'Surname1', '2021-06-01') " + + "INSERT [dbo].[Author] ([idAuthor], [name], [surname], [birth_date]) VALUES (2, N'Author2', N'Surname2', '2021-06-01') " + + "INSERT [dbo].[Author] ([idAuthor], [name], [surname], [birth_date]) VALUES (3, N'Drugaciji', N'Oddrugih', '2021-06-01') "; Helper.ExecuteCustomSql(sql); var authors = new List { - new Author { idAuthor = 1, name = "Drugaciji", surname = "Oddrugih", birth_date = DateTime.Parse("2021-06-01") } + new Author { idAuthor = 3, name = "Drugaciji", surname = "Oddrugih", birth_date = DateTime.Parse("2021-06-01") } }; //Act diff --git a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs index d4bd3d5..bd022f6 100644 --- a/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs +++ b/Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs @@ -1,4 +1,5 @@ using BussinessLogicLayer.services; +using FluentAssertions; using System; using System.Collections.Generic; using System.Linq; @@ -21,6 +22,30 @@ public GenreServices_intTest(DatabaseFixture fixture) services = new GenreServices(); } + //Viktor Lovrić + [Fact] + public void SearchGenres_GivenStringIsPassed_ReturnsGenres() + { + //Arrange + string sql = + "INSERT [dbo].[Genre] ([name]) VALUES (N'zanr1') " + + "INSERT [dbo].[Genre] ([name]) VALUES (N'zanr2') " + + "INSERT [dbo].[Genre] ([name]) VALUES (N'Drugaciji') "; + Helper.ExecuteCustomSql(sql); + + var genres = new List + { + new EntitiesLayer.Genre { id = 1, name = "zanr1" }, + new EntitiesLayer.Genre { id = 2, name = "zanr2" } + }; + + //Act + var result = services.SearchGenres("zanr"); + + //Assert + result.Should().BeEquivalentTo(genres); + } + } } From bfb3afb931d4e22040d6b5323a56f73b0617b2b2 Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Sat, 15 Jun 2024 11:53:38 +0200 Subject: [PATCH 14/16] Refaktoriranje prema PR review sugestiji --- .../PresentationLayer/UcAddNewBook.xaml.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs index 44bbc3e..84f1f80 100644 --- a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs +++ b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml.cs @@ -223,13 +223,11 @@ private void txtSearchGenre_TextChanged(object sender, TextChangedEventArgs e) if (string.IsNullOrEmpty(search)) { LoadGenres(); + return; } - else + using (GenreServices genreServices = new GenreServices()) { - using(GenreServices genreServices = new GenreServices()) - { - cmbGenre.ItemsSource = genreServices.SearchGenres(search); - } + cmbGenre.ItemsSource = genreServices.SearchGenres(search); } } @@ -239,13 +237,11 @@ private void txtSearchAuthor_TextChanged(object sender, TextChangedEventArgs e) if (string.IsNullOrEmpty(search)) { LoadAuthors(); + return; } - else + using (AuthorService authorService = new AuthorService()) { - using (AuthorService authorService = new AuthorService()) - { - cmbAuthor.ItemsSource = authorService.SearchAuthors(search); - } + cmbAuthor.ItemsSource = authorService.SearchAuthors(search); } } } From 4b70bdd85b20cd2c62e8631267a6003b41eecf9b Mon Sep 17 00:00:00 2001 From: vlovric21 Date: Sat, 15 Jun 2024 12:10:13 +0200 Subject: [PATCH 15/16] =?UTF-8?q?Pode=C5=A1en=20izgled=20textbox=20i=20com?= =?UTF-8?q?bobox=20elemenata=20kako=20bi=20bila=20jasnija=20funkcija=20sva?= =?UTF-8?q?kog=20elementa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PresentationLayer/UcAddNewBook.xaml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml index 55dc817..54f0972 100644 --- a/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml +++ b/Software/E_Libra/PresentationLayer/UcAddNewBook.xaml @@ -53,14 +53,11 @@ - - + - - - + - +