2021-06-05 14:47:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2021-05-30 15:29:30 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
2021-06-01 17:15:35 +00:00
|
|
|
|
using System.Threading;
|
2021-05-30 15:29:30 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using AutoFixture;
|
|
|
|
|
using AutoFixture.Xunit2;
|
2021-06-07 19:49:43 +00:00
|
|
|
|
using Microsoft.AspNetCore.Http.Extensions;
|
2021-05-30 17:39:04 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
2021-06-01 17:15:35 +00:00
|
|
|
|
using MongoDB.Bson;
|
2021-05-30 15:29:30 +00:00
|
|
|
|
using MongoDB.Driver;
|
2021-06-20 11:53:34 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2021-06-21 14:46:44 +00:00
|
|
|
|
using Retroactiune.Core.Entities;
|
2021-06-09 21:03:07 +00:00
|
|
|
|
using Retroactiune.DataTransferObjects;
|
2021-06-21 14:46:44 +00:00
|
|
|
|
using Retroactiune.Infrastructure;
|
2021-05-30 15:29:30 +00:00
|
|
|
|
using Retroactiune.IntegrationTests.Retroactiune.WebAPI.Fixtures;
|
|
|
|
|
using Xunit;
|
2021-06-20 11:53:34 +00:00
|
|
|
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
2021-05-30 15:29:30 +00:00
|
|
|
|
|
|
|
|
|
namespace Retroactiune.IntegrationTests.Retroactiune.WebAPI.Controllers
|
|
|
|
|
{
|
2021-06-15 20:08:15 +00:00
|
|
|
|
[Collection("IntegrationTests")]
|
2021-06-30 20:07:39 +00:00
|
|
|
|
public class TestFeedbackReceiversController : IClassFixture<WebApiTestingFactory>
|
2021-05-30 15:29:30 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly MongoDbFixture _mongoDb;
|
|
|
|
|
private readonly HttpClient _client;
|
|
|
|
|
|
2021-06-30 20:07:39 +00:00
|
|
|
|
public TestFeedbackReceiversController(WebApiTestingFactory factory)
|
2021-05-30 15:29:30 +00:00
|
|
|
|
{
|
|
|
|
|
_client = factory.CreateClient();
|
2021-06-11 20:17:03 +00:00
|
|
|
|
var dbSettings = factory.Services.GetService<IOptions<DatabaseSettings>>();
|
2021-05-30 17:39:04 +00:00
|
|
|
|
_mongoDb = new MongoDbFixture(dbSettings);
|
2021-05-30 15:29:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2021-06-05 14:47:22 +00:00
|
|
|
|
public async Task Test_Create_NoContent()
|
2021-05-30 15:29:30 +00:00
|
|
|
|
{
|
2021-06-15 20:08:15 +00:00
|
|
|
|
await _mongoDb.DropAsync();
|
2021-06-01 13:20:31 +00:00
|
|
|
|
var httpResponse = await _client.PostAsync("/api/v1/FeedbackReceivers/",
|
2021-05-30 15:29:30 +00:00
|
|
|
|
new StringContent("[]", Encoding.UTF8, "application/json"));
|
|
|
|
|
Assert.Equal(HttpStatusCode.BadRequest, httpResponse.StatusCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2021-06-05 14:47:22 +00:00
|
|
|
|
public async Task Test_Create_NoName()
|
2021-05-30 15:29:30 +00:00
|
|
|
|
{
|
|
|
|
|
// Arrange
|
2021-06-15 20:08:15 +00:00
|
|
|
|
await _mongoDb.DropAsync();
|
2021-05-30 15:29:30 +00:00
|
|
|
|
var fixture = new Fixture();
|
2021-06-05 13:03:12 +00:00
|
|
|
|
var item = fixture.Create<FeedbackReceiverInDto>();
|
2021-05-30 15:29:30 +00:00
|
|
|
|
item.Name = null;
|
|
|
|
|
|
2021-06-05 13:03:12 +00:00
|
|
|
|
var jsonContent = JsonSerializer.Serialize(new List<FeedbackReceiverInDto> {item});
|
2021-05-30 15:29:30 +00:00
|
|
|
|
|
|
|
|
|
// Test
|
2021-06-01 13:20:31 +00:00
|
|
|
|
var httpResponse = await _client.PostAsync("/api/v1/FeedbackReceivers/",
|
2021-05-30 15:29:30 +00:00
|
|
|
|
new StringContent(jsonContent, Encoding.UTF8, "application/json"));
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(HttpStatusCode.BadRequest, httpResponse.StatusCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2021-06-05 14:47:22 +00:00
|
|
|
|
public async Task Test_Create_NoDescription()
|
2021-05-30 15:29:30 +00:00
|
|
|
|
{
|
|
|
|
|
// Arrange
|
2021-06-15 20:08:15 +00:00
|
|
|
|
await _mongoDb.DropAsync();
|
2021-05-30 15:29:30 +00:00
|
|
|
|
var fixture = new Fixture();
|
2021-06-05 13:03:12 +00:00
|
|
|
|
var item = fixture.Create<FeedbackReceiverInDto>();
|
2021-05-30 15:29:30 +00:00
|
|
|
|
item.Description = null;
|
|
|
|
|
|
2021-06-05 13:03:12 +00:00
|
|
|
|
var jsonContent = JsonSerializer.Serialize(new List<FeedbackReceiverInDto> {item});
|
2021-05-30 15:29:30 +00:00
|
|
|
|
|
|
|
|
|
// Test
|
2021-06-01 13:20:31 +00:00
|
|
|
|
var httpResponse = await _client.PostAsync("/api/v1/FeedbackReceivers/",
|
2021-05-30 15:29:30 +00:00
|
|
|
|
new StringContent(jsonContent, Encoding.UTF8, "application/json"));
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(HttpStatusCode.BadRequest, httpResponse.StatusCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory, AutoData]
|
2021-06-05 14:47:22 +00:00
|
|
|
|
public async Task Test_Create_Ok(IEnumerable<FeedbackReceiverInDto> items)
|
2021-05-30 15:29:30 +00:00
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
await _mongoDb.DropAsync();
|
|
|
|
|
var feedbackReceiversDto = items.ToList();
|
|
|
|
|
var jsonContent = JsonSerializer.Serialize(feedbackReceiversDto);
|
|
|
|
|
|
|
|
|
|
// Test
|
2021-06-01 13:20:31 +00:00
|
|
|
|
var httpResponse = await _client.PostAsync("/api/v1/FeedbackReceivers/",
|
2021-05-30 15:29:30 +00:00
|
|
|
|
new StringContent(jsonContent, Encoding.UTF8, "application/json"));
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
httpResponse.EnsureSuccessStatusCode();
|
|
|
|
|
var filter = new FilterDefinitionBuilder<FeedbackReceiver>().Empty;
|
|
|
|
|
|
|
|
|
|
var createdDocs = await _mongoDb.FeedbackReceiverCollection.CountDocumentsAsync(filter);
|
|
|
|
|
Assert.Equal(feedbackReceiversDto.Count(), createdDocs);
|
|
|
|
|
}
|
2021-06-01 17:15:35 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
2021-06-05 14:47:22 +00:00
|
|
|
|
public async Task Test_Delete_ValidationFail()
|
2021-06-01 17:15:35 +00:00
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
await _mongoDb.DropAsync();
|
|
|
|
|
|
|
|
|
|
// Test
|
|
|
|
|
var httpResponse =
|
|
|
|
|
await _client.DeleteAsync("/api/v1/FeedbackReceivers/abc_not_guid", CancellationToken.None);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(HttpStatusCode.BadRequest, httpResponse.StatusCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory, AutoData]
|
2021-06-05 14:47:22 +00:00
|
|
|
|
public async Task Test_Delete_OK(IEnumerable<FeedbackReceiver> items)
|
2021-06-01 17:15:35 +00:00
|
|
|
|
{
|
|
|
|
|
// Arrange
|
2021-06-15 20:08:15 +00:00
|
|
|
|
await _mongoDb.DropAsync();
|
2021-06-01 17:15:35 +00:00
|
|
|
|
var guids = new List<string>();
|
|
|
|
|
byte index = 0;
|
2021-06-15 20:08:15 +00:00
|
|
|
|
var feedbackReceivers = items as FeedbackReceiver[] ?? items.ToArray();
|
|
|
|
|
foreach (var i in feedbackReceivers)
|
2021-06-01 17:15:35 +00:00
|
|
|
|
{
|
|
|
|
|
i.Id = new BsonObjectId(new ObjectId(new byte[] {1, 2, index, 4, 5, 6, 7, 8, 9, index, 11, 14}))
|
|
|
|
|
.ToString();
|
|
|
|
|
index += 1;
|
|
|
|
|
guids.Add(i.Id);
|
2021-06-15 20:08:15 +00:00
|
|
|
|
}
|
2021-06-20 13:53:43 +00:00
|
|
|
|
|
2021-06-15 20:08:15 +00:00
|
|
|
|
await _mongoDb.FeedbackReceiverCollection.InsertManyAsync(feedbackReceivers);
|
2021-06-01 17:15:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test
|
|
|
|
|
foreach (var guid in guids)
|
|
|
|
|
{
|
|
|
|
|
var httpResponse =
|
|
|
|
|
await _client.DeleteAsync($"/api/v1/FeedbackReceivers/{guid}", CancellationToken.None);
|
2021-06-05 14:47:22 +00:00
|
|
|
|
Assert.Equal(HttpStatusCode.NoContent, httpResponse.StatusCode);
|
2021-06-01 17:15:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
var docs = await _mongoDb.FeedbackReceiverCollection.CountDocumentsAsync(FilterDefinition<FeedbackReceiver>
|
|
|
|
|
.Empty);
|
|
|
|
|
Assert.Equal(0L, docs);
|
|
|
|
|
}
|
2021-06-20 13:53:43 +00:00
|
|
|
|
|
2021-06-20 11:53:34 +00:00
|
|
|
|
[Theory, AutoData]
|
|
|
|
|
public async Task Test_DeleteMany_OK(IEnumerable<FeedbackReceiver> items)
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
await _mongoDb.DropAsync();
|
|
|
|
|
var guids = new List<string>();
|
|
|
|
|
byte index = 0;
|
|
|
|
|
var feedbackReceivers = items as FeedbackReceiver[] ?? items.ToArray();
|
|
|
|
|
foreach (var i in feedbackReceivers)
|
|
|
|
|
{
|
|
|
|
|
i.Id = new BsonObjectId(new ObjectId(new byte[] {1, 2, index, 4, 5, 6, 7, 8, 9, index, 11, 14}))
|
|
|
|
|
.ToString();
|
|
|
|
|
index += 1;
|
|
|
|
|
guids.Add(i.Id);
|
|
|
|
|
}
|
2021-06-20 13:53:43 +00:00
|
|
|
|
|
2021-06-20 11:53:34 +00:00
|
|
|
|
await _mongoDb.FeedbackReceiverCollection.InsertManyAsync(feedbackReceivers);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test
|
2021-06-20 13:53:43 +00:00
|
|
|
|
var request = new HttpRequestMessage
|
|
|
|
|
{
|
2021-06-20 11:53:34 +00:00
|
|
|
|
Method = HttpMethod.Delete,
|
|
|
|
|
RequestUri = new Uri($"{_client.BaseAddress.AbsoluteUri}api/v1/FeedbackReceivers"),
|
2021-06-20 13:53:43 +00:00
|
|
|
|
// ReSharper disable once MethodHasAsyncOverload
|
2021-06-20 11:53:34 +00:00
|
|
|
|
Content = new StringContent(JsonConvert.SerializeObject(guids), Encoding.UTF8, "application/json")
|
|
|
|
|
};
|
|
|
|
|
var httpResponse = await _client.SendAsync(request);
|
|
|
|
|
Assert.Equal(HttpStatusCode.NoContent, httpResponse.StatusCode);
|
|
|
|
|
|
2021-06-20 13:53:43 +00:00
|
|
|
|
// Assert
|
2021-06-20 11:53:34 +00:00
|
|
|
|
var docs = await _mongoDb.FeedbackReceiverCollection.CountDocumentsAsync(FilterDefinition<FeedbackReceiver>
|
|
|
|
|
.Empty);
|
|
|
|
|
Assert.Equal(0L, docs);
|
|
|
|
|
}
|
2021-06-05 14:47:22 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Test_Get_Ok()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
await _mongoDb.DropAsync();
|
2021-06-07 20:03:44 +00:00
|
|
|
|
var feedbackReceiver = new FeedbackReceiver
|
2021-06-05 14:47:22 +00:00
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3",
|
2021-06-07 19:49:43 +00:00
|
|
|
|
Description = "something",
|
2021-06-07 20:03:44 +00:00
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
2021-06-05 14:47:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _mongoDb.FeedbackReceiverCollection.InsertManyAsync(new[] {feedbackReceiver});
|
|
|
|
|
|
|
|
|
|
// Test
|
|
|
|
|
var httpResponse =
|
|
|
|
|
await _client.GetAsync($"/api/v1/FeedbackReceivers/{feedbackReceiver.Id}", CancellationToken.None);
|
2021-06-07 20:03:44 +00:00
|
|
|
|
var item = JsonSerializer.Deserialize<FeedbackReceiver>(
|
|
|
|
|
await httpResponse.Content.ReadAsStringAsync());
|
2021-06-05 14:47:22 +00:00
|
|
|
|
|
|
|
|
|
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
|
2021-06-07 20:03:44 +00:00
|
|
|
|
Assert.Equal(feedbackReceiver, item);
|
2021-06-05 14:47:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Test_Get_NotFound()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
await _mongoDb.DropAsync();
|
|
|
|
|
|
|
|
|
|
// Test
|
|
|
|
|
var httpResponse = await _client.GetAsync("/api/v1/FeedbackReceivers/0102030405060708090a0b0e",
|
|
|
|
|
CancellationToken.None);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(HttpStatusCode.NotFound, httpResponse.StatusCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Test_Get_BadRequest()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
await _mongoDb.DropAsync();
|
|
|
|
|
|
|
|
|
|
// Test
|
|
|
|
|
var httpResponse = await _client.GetAsync("/api/v1/FeedbackReceivers/xxx", CancellationToken.None);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(HttpStatusCode.BadRequest, httpResponse.StatusCode);
|
|
|
|
|
}
|
2021-06-07 19:49:43 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Test_List_Ok()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
await _mongoDb.DropAsync();
|
|
|
|
|
var feedbackReceivers = new List<FeedbackReceiver>
|
|
|
|
|
{
|
|
|
|
|
new FeedbackReceiver
|
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3",
|
|
|
|
|
Description = "something",
|
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
|
|
|
|
},
|
|
|
|
|
new FeedbackReceiver
|
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3_Two",
|
|
|
|
|
Description = "something",
|
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
|
|
|
|
},
|
|
|
|
|
new FeedbackReceiver
|
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3_Three",
|
|
|
|
|
Description = "something",
|
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _mongoDb.FeedbackReceiverCollection.InsertManyAsync(feedbackReceivers);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test
|
|
|
|
|
var httpResponse = await _client.GetAsync("/api/v1/FeedbackReceivers/", CancellationToken.None);
|
|
|
|
|
var items = JsonSerializer.Deserialize<List<FeedbackReceiver>>(
|
|
|
|
|
await httpResponse.Content.ReadAsStringAsync());
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
|
|
|
|
|
for (var i = 0; i < feedbackReceivers.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
Assert.Equal(feedbackReceivers[i], items[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Test_List_Ok_Filter()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
await _mongoDb.DropAsync();
|
|
|
|
|
var feedbackReceivers = new List<FeedbackReceiver>
|
|
|
|
|
{
|
|
|
|
|
new FeedbackReceiver
|
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3",
|
|
|
|
|
Description = "something",
|
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
|
|
|
|
},
|
|
|
|
|
new FeedbackReceiver
|
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3_Two",
|
|
|
|
|
Description = "something",
|
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
|
|
|
|
},
|
|
|
|
|
new FeedbackReceiver
|
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3_Three",
|
|
|
|
|
Description = "something",
|
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _mongoDb.FeedbackReceiverCollection.InsertManyAsync(feedbackReceivers);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test
|
|
|
|
|
var qb = new QueryBuilder {{"filter", new[] {feedbackReceivers[0].Id, feedbackReceivers[1].Id}}};
|
|
|
|
|
var httpResponse =
|
|
|
|
|
await _client.GetAsync("/api/v1/FeedbackReceivers/" + qb,
|
|
|
|
|
CancellationToken.None);
|
|
|
|
|
var items = JsonSerializer.Deserialize<List<FeedbackReceiver>>(
|
|
|
|
|
await httpResponse.Content.ReadAsStringAsync());
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
|
|
|
|
|
Assert.Equal(2, items.Count);
|
|
|
|
|
for (var i = 0; i < 2; i++)
|
|
|
|
|
{
|
|
|
|
|
Assert.Equal(feedbackReceivers[i], items[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Test_List_Ok_LimitOffset()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
await _mongoDb.DropAsync();
|
|
|
|
|
var feedbackReceivers = new List<FeedbackReceiver>
|
|
|
|
|
{
|
|
|
|
|
new FeedbackReceiver
|
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3",
|
|
|
|
|
Description = "something",
|
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
|
|
|
|
},
|
|
|
|
|
new FeedbackReceiver
|
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3_Two",
|
|
|
|
|
Description = "something",
|
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
|
|
|
|
},
|
|
|
|
|
new FeedbackReceiver
|
|
|
|
|
{
|
|
|
|
|
Id = new BsonObjectId(new ObjectId(new byte[] {3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14})).ToString(),
|
|
|
|
|
Name = "N4m3_Three",
|
|
|
|
|
Description = "something",
|
|
|
|
|
CreatedAt = DateTime.UnixEpoch
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _mongoDb.FeedbackReceiverCollection.InsertManyAsync(feedbackReceivers);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test
|
|
|
|
|
var qb = new QueryBuilder {{"offset", "1"}, {"limit", "1"}};
|
|
|
|
|
var httpResponse = await _client.GetAsync("/api/v1/FeedbackReceivers/" + qb, CancellationToken.None);
|
|
|
|
|
var items = JsonSerializer.Deserialize<List<FeedbackReceiver>>(
|
|
|
|
|
await httpResponse.Content.ReadAsStringAsync());
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
|
|
|
|
|
Assert.Single(items);
|
|
|
|
|
Assert.Equal(feedbackReceivers[1], items[0]);
|
|
|
|
|
}
|
2021-05-30 15:29:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|