forked from gothinkster/realworld-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#16 create article endpoint and unit tests
- Loading branch information
Showing
61 changed files
with
679 additions
and
66 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
Conduit/Conduit.Migrations/005_CreateArticlesCollection.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,28 @@ | ||
using NoSqlMigrator.Infrastructure; | ||
|
||
namespace Conduit.Migrations; | ||
|
||
[Migration(5)] | ||
public class CreateArticlesCollection : MigrateBase | ||
{ | ||
private readonly string? _collectionName; | ||
private readonly string? _scopeName; | ||
|
||
public CreateArticlesCollection() | ||
{ | ||
_collectionName = _config["Couchbase:ArticlesCollectionName"]; | ||
_scopeName = _config["Couchbase:ScopeName"]; | ||
} | ||
|
||
public override void Up() | ||
{ | ||
Create.Collection(_collectionName) | ||
.InScope(_scopeName); | ||
} | ||
|
||
public override void Down() | ||
{ | ||
Delete.Collection(_collectionName) | ||
.FromScope(_scopeName); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
Conduit/Conduit.Tests/Integration/Articles/Handlers/GetTagsHandlerTests.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
2 changes: 1 addition & 1 deletion
2
Conduit/Conduit.Tests/Integration/Follows/Handlers/FollowUserHandlerTests.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
2 changes: 1 addition & 1 deletion
2
Conduit/Conduit.Tests/Integration/Follows/Handlers/UnfollowUserHandlerTests.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
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
2 changes: 1 addition & 1 deletion
2
Conduit/Conduit.Tests/Integration/Users/Handlers/GetCurrentUserRequestHandlerTests.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
2 changes: 1 addition & 1 deletion
2
Conduit/Conduit.Tests/Integration/Users/Handlers/GetProfileHandlerTests.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
2 changes: 1 addition & 1 deletion
2
Conduit/Conduit.Tests/Integration/Users/Handlers/LoginRequestHandlerTests.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
2 changes: 1 addition & 1 deletion
2
Conduit/Conduit.Tests/Integration/Users/Handlers/RegistrationRequestHandlerTests.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
2 changes: 1 addition & 1 deletion
2
Conduit/Conduit.Tests/Integration/Users/Handlers/UpdateUserHandlerTests.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
2 changes: 1 addition & 1 deletion
2
...uit/Conduit.Tests/Integration/Users/Services/UserDataServiceTests/RegisterNewUserTests.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
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
35 changes: 35 additions & 0 deletions
35
Conduit/Conduit.Tests/TestHelpers/Dto/CreateArticleRequestHelper.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,35 @@ | ||
using Conduit.Web.Articles.Handlers; | ||
using Conduit.Web.Articles.ViewModels; | ||
|
||
namespace Conduit.Tests.TestHelpers.Dto; | ||
|
||
public static class CreateArticleRequestHelper | ||
{ | ||
public static CreateArticleRequest Create( | ||
string? body = null, | ||
string? description = null, | ||
string? title = null, | ||
List<string>? tags = null, | ||
string? username = null, | ||
bool makeTagsNull = false) | ||
{ | ||
var random = new Random(); | ||
|
||
body ??= random.String(1000); | ||
description ??= random.String(100); | ||
title ??= random.String(60); | ||
tags ??= new List<string> { "Couchbase", "cruising" }; | ||
username ??= Path.GetRandomFileName(); | ||
if (makeTagsNull) tags = null; | ||
|
||
var article = new CreateArticleSubmitModel | ||
{ | ||
Body = body, | ||
Description = description, | ||
Title = title, | ||
Tags = tags | ||
}; | ||
|
||
return new CreateArticleRequest(article, username); | ||
} | ||
} |
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,13 @@ | ||
namespace Conduit.Tests.TestHelpers; | ||
|
||
public static class RandomHelpers | ||
{ | ||
const string _defaultCharacterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
|
||
public static string String(this Random @this, int length, string? characterPool = null) | ||
{ | ||
var chars = characterPool ?? _defaultCharacterSet; | ||
return new string(Enumerable.Repeat(chars, length) | ||
.Select(s => s[@this.Next(s.Length)]).ToArray()); | ||
} | ||
} |
Oops, something went wrong.