Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2891,6 +2891,28 @@ public async Task SearchAsync_WhenCommentsDoesNotExists_ShouldReturnNothing(stri
Assert.Null(comments.Entities);
}

/// <summary>
/// Search async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
// Arrange
var query = new SearchQuery<Comment>
{
Skip = 0,
Take = 10
};

_commentsRepositoryMock
.Setup(r => r.SearchAsync(query))
.ThrowsAsync(new Exception("Database error"));

// Assert
await Assert.ThrowsAsync<Exception>(() => _commentsService.SearchAsync(query));
}

#endregion

#region SearchBySequenceAsync function
Expand Down Expand Up @@ -2950,6 +2972,21 @@ public async Task SearchBySequenceAsync_WhenEntitiesExistAndSequenceIsNullIsNull
Assert.Null(result.Entities);
}

/// <summary>
/// Search by sequence async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchBySequenceAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
var data = SetupCommentFixture().CreateMany(3).AsQueryable();
var query = new SearchQuery<Comment> { Skip = 0, Take = 5 };

_commentsRepositoryMock.Setup(r => r.SearchBySequenceAsync(query, data)).ThrowsAsync(new Exception("DB fail"));

await Assert.ThrowsAsync<Exception>(() => _commentsService.SearchBySequenceAsync(query, data));
}

#endregion

#region GenerateQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2976,6 +2976,28 @@ public async Task SearchAsync_WhenMessagesDoesNotExists_ShouldReturnNothing(stri
Assert.Null(comments.Entities);
}

/// <summary>
/// Search async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
// Arrange
var query = new SearchQuery<Message>
{
Skip = 0,
Take = 10
};

_messagesRepositoryMock
.Setup(r => r.SearchAsync(query))
.ThrowsAsync(new Exception("Database error"));

// Assert
await Assert.ThrowsAsync<Exception>(() => _messagesService.SearchAsync(query));
}

#endregion

#region SearchBySequenceAsync function
Expand Down Expand Up @@ -3035,6 +3057,21 @@ public async Task SearchBySequenceAsync_WhenEntitiesExistAndSequenceIsNullIsNull
Assert.Null(result.Entities);
}

/// <summary>
/// Search by sequence async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchBySequenceAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
var data = SetupMessageFixture().CreateMany(3).AsQueryable();
var query = new SearchQuery<Message> { Skip = 0, Take = 5 };

_messagesRepositoryMock.Setup(r => r.SearchBySequenceAsync(query, data)).ThrowsAsync(new Exception("DB fail"));

await Assert.ThrowsAsync<Exception>(() => _messagesService.SearchBySequenceAsync(query, data));
}

#endregion

#region GenerateQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3446,6 +3446,28 @@ public async Task SearchAsync_WhenPostsTagsRelationsDoesNotExists_ShouldReturnNo
Assert.Null(postsTagsRelations.Entities);
}

/// <summary>
/// Search async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
// Arrange
var query = new SearchQuery<PostsTagsRelations>
{
Skip = 0,
Take = 10
};

_postsTagsRelationsRepositoryMock
.Setup(r => r.SearchAsync(query))
.ThrowsAsync(new Exception("Database error"));

// Assert
await Assert.ThrowsAsync<Exception>(() => _postsTagsRelationsService.SearchAsync(query));
}

#endregion

#region SearchBySequenceAsync function
Expand Down Expand Up @@ -3505,6 +3527,21 @@ public async Task SearchBySequenceAsync_WhenEntitiesExistAndSequenceIsNullIsNull
Assert.Null(result.Entities);
}

/// <summary>
/// Search by sequence async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchBySequenceAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
var data = SetupPostsTagsRelationsFixture().CreateMany(3).AsQueryable();
var query = new SearchQuery<PostsTagsRelations> { Skip = 0, Take = 5 };

_postsTagsRelationsRepositoryMock.Setup(r => r.SearchBySequenceAsync(query, data)).ThrowsAsync(new Exception("DB fail"));

await Assert.ThrowsAsync<Exception>(() => _postsTagsRelationsService.SearchBySequenceAsync(query, data));
}

#endregion

#region GenerateQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,28 @@ public async Task SearchAsync_WhenPostsDoesNotExists_ShouldReturnNothing(string
Assert.Null(posts.Entities);
}

/// <summary>
/// Search async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
// Arrange
var query = new SearchQuery<Post>
{
Skip = 0,
Take = 10
};

_postsRepositoryMock
.Setup(r => r.SearchAsync(query))
.ThrowsAsync(new Exception("Database error"));

// Assert
await Assert.ThrowsAsync<Exception>(() => _postsService.SearchAsync(query));
}

#endregion

#region SearchBySequenceAsync function
Expand Down Expand Up @@ -3007,6 +3029,21 @@ public async Task SearchBySequenceAsync_WhenEntitiesExistAndSequenceIsNullIsNull
Assert.Null(result.Entities);
}

/// <summary>
/// Search by sequence async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchBySequenceAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
var data = SetupPostFixture().CreateMany(3).AsQueryable();
var query = new SearchQuery<Post> { Skip = 0, Take = 5 };

_postsRepositoryMock.Setup(r => r.SearchBySequenceAsync(query, data)).ThrowsAsync(new Exception("DB fail"));

await Assert.ThrowsAsync<Exception>(() => _postsService.SearchBySequenceAsync(query, data));
}

#endregion

#region GenerateQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2797,6 +2797,28 @@ public async Task SearchAsync_WhenProfilesDoesNotExists_ShouldReturnNothing(stri
Assert.Null(posts.Entities);
}

/// <summary>
/// Search async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
// Arrange
var query = new SearchQuery<ProfileModel>
{
Skip = 0,
Take = 10
};

_profileRepositoryMock
.Setup(r => r.SearchAsync(query))
.ThrowsAsync(new Exception("Database error"));

// Assert
await Assert.ThrowsAsync<Exception>(() => _profileService.SearchAsync(query));
}

#endregion

#region SearchBySequenceAsync function
Expand Down Expand Up @@ -2856,6 +2878,21 @@ public async Task SearchBySequenceAsync_WhenEntitiesExistAndSequenceIsNullIsNull
Assert.Null(result.Entities);
}

/// <summary>
/// Search by sequence async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchBySequenceAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
var data = SetupProfileFixture().CreateMany(3).AsQueryable();
var query = new SearchQuery<ProfileModel> { Skip = 0, Take = 5 };

_profileRepositoryMock.Setup(r => r.SearchBySequenceAsync(query, data)).ThrowsAsync(new Exception("DB fail"));

await Assert.ThrowsAsync<Exception>(() => _profileService.SearchBySequenceAsync(query, data));
}

#endregion

#region GenerateQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2797,7 +2797,6 @@ public async Task SearchAsync_WhenTagsExists_ShouldReturnTags(string search, int
.CreateMany(random.Next(100))
.ToList();


var query = new SearchQuery<Tag>
{
Skip = start,
Expand Down Expand Up @@ -2931,6 +2930,28 @@ public async Task SearchAsync_WhenTagsDoesNotExists_ShouldReturnNothing(string s
Assert.Null(tags.Entities);
}

/// <summary>
/// Search async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
// Arrange
var query = new SearchQuery<Tag>
{
Skip = 0,
Take = 10
};

_tagsRepositoryMock
.Setup(r => r.SearchAsync(query))
.ThrowsAsync(new Exception("Database error"));

// Assert
await Assert.ThrowsAsync<Exception>(() => _tagsService.SearchAsync(query));
}

#endregion

#region SearchBySequenceAsync function
Expand Down Expand Up @@ -2990,6 +3011,21 @@ public async Task SearchBySequenceAsync_WhenEntitiesExistAndSequenceIsNullIsNull
Assert.Null(result.Entities);
}

/// <summary>
/// Search by sequence async.
/// When repository throws exception should throw exception.
/// </summary>
[Fact]
public async Task SearchBySequenceAsync_WhenRepositoryThrowsException_ShouldThrowException()
{
var data = SetupTagFixture().CreateMany(3).AsQueryable();
var query = new SearchQuery<Tag> { Skip = 0, Take = 5 };

_tagsRepositoryMock.Setup(r => r.SearchBySequenceAsync(query, data)).ThrowsAsync(new Exception("DB fail"));

await Assert.ThrowsAsync<Exception>(() => _tagsService.SearchBySequenceAsync(query, data));
}

#endregion

#region GenerateQuery
Expand Down
Loading