-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from foivz/45-nova-funkcionalnost-f13
F13 nova funkcionalnost pretrazivanje pri dodavanju knjige
- Loading branch information
Showing
15 changed files
with
340 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Build and run unit test on branch push | ||
|
||
on: | ||
push: | ||
branches: | ||
- 45-nova-funkcionalnost-f13 | ||
pull_request: | ||
branches: | ||
- 45-nova-funkcionalnost-f13 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/AuthorService_intTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using FluentAssertions; | ||
using BussinessLogicLayer.services; | ||
using EntitiesLayer; | ||
|
||
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(); | ||
} | ||
|
||
|
||
//Viktor Lovrić | ||
[Fact] | ||
public void SearchAuthors_GivenStringIsPassed_ReturnsAuthors() | ||
{ | ||
//Arrange | ||
string sql = | ||
"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<Author> | ||
{ | ||
new Author { idAuthor = 3, name = "Drugaciji", surname = "Oddrugih", birth_date = DateTime.Parse("2021-06-01") } | ||
}; | ||
|
||
//Act | ||
var result = service.SearchAuthors("Drug"); | ||
|
||
//Assert | ||
result.Should().BeEquivalentTo(authors); | ||
} | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/Class1.cs
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
Software/E_Libra/IntegrationTesting/Nove funkcionalnosti/F13/GenreServices_intTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using BussinessLogicLayer.services; | ||
using FluentAssertions; | ||
using System; | ||
using System.Collections.Generic; | ||
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; | ||
readonly DatabaseFixture fixture; | ||
|
||
public GenreServices_intTest(DatabaseFixture fixture) | ||
{ | ||
this.fixture = fixture; | ||
this.fixture.ResetDatabase(); | ||
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<EntitiesLayer.Genre> | ||
{ | ||
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); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Software/E_Libra/UnitTesting/Nove funkcionalnosti/F13/AuthorService_Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IAuthorRepository>(); | ||
service = new AuthorService(repo); | ||
} | ||
|
||
//Viktor Lovrić | ||
[Fact] | ||
public void SearchAuthors_GivenStringIsPassed_ReturnsAuthors() | ||
{ | ||
//Arrange | ||
var authors = new List<Author> | ||
{ | ||
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.