-
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.
Showing
45 changed files
with
175 additions
and
47 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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
Empty file.
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,7 @@ | ||
namespace Application.BookOperations.Commands.CreateCommand | ||
{ | ||
public class CreateBookCommandTests | ||
{ | ||
|
||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...Api.UnitTests/Application/BookOperations/Commands/CreateCommand/CreateBookCommandTests.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,38 @@ | ||
using System; | ||
using AutoMapper; | ||
using FluentAssertions; | ||
using TestSetup; | ||
using WebApi.Application.BookOperations.Commands.CreateBook; | ||
using WebApi.DBOperations; | ||
using WebApi.Entities; | ||
using Xunit; | ||
|
||
namespace Application.BookOperations.Commands.CreateCommand{ | ||
public class CreateBookCommandTests:IClassFixture<CommonTestFixture> | ||
{ | ||
|
||
private readonly BookStoreDbContext _context; | ||
private readonly IMapper _mapper; | ||
|
||
public CreateBookCommandTests(CommonTestFixture fixture) | ||
{ | ||
_context = fixture.Context; | ||
_mapper = fixture.Mapper; | ||
} | ||
[Fact] | ||
public void WhenAlreadExistBooktitleIsGiven_InvalidOperationException_ShouldBeReturn(){ | ||
|
||
CreateBookCommand command = new CreateBookCommand(_context, _mapper); | ||
var book= new Book { Title = "WhenAlreadExistBooktitleIsGiven_InvalidOperationException_ShouldBeReturn", GendreId = 1, PageCount = 200, PublishDate = new DateTime(2000, 10, 10) }; | ||
_context.Books.Add(book); | ||
_context.SaveChanges(); | ||
command.Model = new CreateBookModel{Title=book.Title}; | ||
|
||
FluentActions.Invoking(()=>command.Handle()) | ||
.Should().Throw<InvalidOperationException>().And.Message.Should().Be("Kitap zaten mevcut"); | ||
|
||
|
||
command.Handle(); | ||
} | ||
} | ||
} |
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,16 @@ | ||
using System; | ||
using WebApi.DBOperations; | ||
using WebApi.Entities; | ||
|
||
namespace TestSetup{ | ||
public static class Books{ | ||
|
||
public static void AddBooks(this BookStoreDbContext context){ | ||
context.Books.AddRange( | ||
new Book { Title = "Learn Startup", GendreId = 1, PageCount = 200, PublishDate = new DateTime(2000, 10, 10) }, | ||
new Book { Title = "Herland", GendreId = 2, PageCount = 250, PublishDate = new DateTime(2010, 5, 20) }, | ||
new Book { Title = "Dune", GendreId = 2, PageCount = 2540, PublishDate = new DateTime(2020, 5, 20) }); | ||
|
||
} | ||
} | ||
} |
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,21 @@ | ||
using AutoMapper; | ||
using Microsoft.EntityFrameworkCore; | ||
using WebApi.Common; | ||
using WebApi.DBOperations; | ||
|
||
namespace TestSetup{ | ||
public class CommonTestFixture{ | ||
public BookStoreDbContext Context{get;set;} | ||
public IMapper Mapper {get;set;} | ||
public CommonTestFixture() | ||
{ | ||
var options= new DbContextOptionsBuilder<BookStoreDbContext>().UseInMemoryDatabase(databaseName:"BookStoreTestDB").Options; | ||
Context =new BookStoreDbContext(options); | ||
Context.Database.EnsureCreated(); | ||
Context.AddBooks(); | ||
Context.AddGenres(); | ||
|
||
Mapper = new MapperConfiguration(cfg=>{cfg.AddProfile<MappingProfile>();}).CreateMapper(); | ||
} | ||
} | ||
} |
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,19 @@ | ||
using System; | ||
using WebApi.DBOperations; | ||
using WebApi.Entities; | ||
|
||
namespace TestSetup{ | ||
public static class Genres{ | ||
|
||
public static void AddGenres(this BookStoreDbContext context){ | ||
context.Genres.AddRange( | ||
new Genre { Name = "PersonalGrowth" }, | ||
new Genre { Name = "ScienceFiction" }, | ||
new Genre { Name = "Noval" }); | ||
context.Authors.AddRange( | ||
new Author { FirstName="Orhan", LastName="Pamuk", BirthDate=DateTime.Parse("07/07/1952") } | ||
); | ||
|
||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Tests/WebApi.UnitTests/bin/Debug/net5.0/CoverletSourceRootsMapping
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Tests/WebApi.UnitTests/bin/Debug/net5.0/WebApi.UnitTests.dll
Binary file not shown.
Binary file modified
BIN
-36 Bytes
(100%)
Tests/WebApi.UnitTests/bin/Debug/net5.0/WebApi.UnitTests.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Binary file modified
BIN
+0 Bytes
(100%)
Tests/WebApi.UnitTests/obj/Debug/net5.0/WebApi.UnitTests.assets.cache
Binary file not shown.
Binary file modified
BIN
+2.65 KB
(120%)
Tests/WebApi.UnitTests/obj/Debug/net5.0/WebApi.UnitTests.csproj.AssemblyReference.cache
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Tests/WebApi.UnitTests/obj/Debug/net5.0/WebApi.UnitTests.dll
Binary file not shown.
Binary file modified
BIN
-36 Bytes
(100%)
Tests/WebApi.UnitTests/obj/Debug/net5.0/WebApi.UnitTests.pdb
Binary file not shown.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using WebApi.Entities; | ||
|
||
namespace WebApi.DBOperations | ||
{ | ||
public interface IBookStoreDbContext | ||
{ | ||
public DbSet<Book> Books { get; set; } | ||
public DbSet<Genre> Genres { get; set; } | ||
|
||
int SaveChanges(); | ||
} | ||
} |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
Binary file modified
BIN
-140 KB
(0.0077%)
WebApi/obj/Debug/net5.0/WebApi.csproj.AssemblyReference.cache
Binary file not shown.
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 |
---|---|---|
@@ -1 +1 @@ | ||
3e8319b82519f1310e527c1bfd17d65fc8e54410 | ||
63ee7d3da1cf722091e12be40d42cc4cfe83bcbd |
Binary file not shown.
Binary file not shown.
Binary file not shown.