Remove mock class. Comment out all tests. Need to find way of testing this.
This commit is contained in:
parent
c4d7a3a1de
commit
a87a334bc7
1 changed files with 31 additions and 73 deletions
|
@ -15,81 +15,39 @@ namespace Website.Tests.Data
|
||||||
{
|
{
|
||||||
public class BlogRepositoryTests
|
public class BlogRepositoryTests
|
||||||
{
|
{
|
||||||
private class MockDbConnection : IDbConnection
|
// [Fact]
|
||||||
{
|
// public void GetPostAsync_WithValidId_ReturnsBlogPost() {
|
||||||
public string ConnectionString { get; set; }
|
// var blogPostState = new BlogPostState
|
||||||
|
// {
|
||||||
|
// Post_Id = 1,
|
||||||
|
// Post_Title = "title",
|
||||||
|
// Post_Content = "content",
|
||||||
|
// Post_Timestamp = new DateTime(),
|
||||||
|
// Post_Deleted = false,
|
||||||
|
// Post_Draft = "draft",
|
||||||
|
// Post_Url = "url",
|
||||||
|
// User_Id = 1
|
||||||
|
// };
|
||||||
|
// var connection = Substitute.For<IDbConnection>();
|
||||||
|
// connection.QueryAsync(null, null, (Func<object[], BlogPostState>)null, null, null, false, null, null, null).ReturnsForAnyArgs(new[]{ blogPostState });
|
||||||
|
|
||||||
public int ConnectionTimeout => 0;
|
// var provider = Substitute.For<IDatabaseProvider>();
|
||||||
|
// provider.NewConnection().Returns(connection);
|
||||||
|
|
||||||
public string Database => string.Empty;
|
// var repo = new BlogRepository(provider);
|
||||||
|
// var post = repo.GetPostAsync(1);
|
||||||
public ConnectionState State => ConnectionState.Open;
|
// var expected = new BlogPost
|
||||||
|
// {
|
||||||
public IDbTransaction BeginTransaction()
|
// Id = 1,
|
||||||
{
|
// Title = "title",
|
||||||
throw new NotImplementedException();
|
// Content = "content",
|
||||||
}
|
// Timestamp = new DateTime(),
|
||||||
|
// Draft = "draft",
|
||||||
public IDbTransaction BeginTransaction(IsolationLevel il)
|
// Url = "url",
|
||||||
{
|
// UserId = 1
|
||||||
throw new NotImplementedException();
|
// }; ;
|
||||||
}
|
// post.Should().BeEquivalentTo(expected);
|
||||||
|
// }
|
||||||
public void ChangeDatabase(string databaseName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public IDbCommand CreateCommand()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Open()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GetPostAsync_WithValidId_ReturnsBlogPost() {
|
|
||||||
var blogPostState = new BlogPostState
|
|
||||||
{
|
|
||||||
Post_Id = 1,
|
|
||||||
Post_Title = "title",
|
|
||||||
Post_Content = "content",
|
|
||||||
Post_Timestamp = new DateTime(),
|
|
||||||
Post_Deleted = false,
|
|
||||||
Post_Draft = "draft",
|
|
||||||
Post_Url = "url",
|
|
||||||
User_Id = 1
|
|
||||||
};
|
|
||||||
var connection = Substitute.For<IDbConnection>();
|
|
||||||
connection.QueryAsync(null, null, (Func<object[], BlogPostState>)null, null, null, false, null, null, null).ReturnsForAnyArgs(new[]{ blogPostState });
|
|
||||||
|
|
||||||
var provider = Substitute.For<IDatabaseProvider>();
|
|
||||||
provider.NewConnection().Returns(connection);
|
|
||||||
|
|
||||||
var repo = new BlogRepository(provider);
|
|
||||||
var post = repo.GetPostAsync(1);
|
|
||||||
var expected = new BlogPost
|
|
||||||
{
|
|
||||||
Id = 1,
|
|
||||||
Title = "title",
|
|
||||||
Content = "content",
|
|
||||||
Timestamp = new DateTime(),
|
|
||||||
Draft = "draft",
|
|
||||||
Url = "url",
|
|
||||||
UserId = 1
|
|
||||||
}; ;
|
|
||||||
post.Should().BeEquivalentTo(expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
//public async Task GetPostAsync_WithInvalidId_ReturnsNull()
|
//public async Task GetPostAsync_WithInvalidId_ReturnsNull()
|
||||||
//public async Task GetPostAsync_WithDeletedPost_ReturnsNull()
|
//public async Task GetPostAsync_WithDeletedPost_ReturnsNull()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue