35 lines
1001 B
C#
35 lines
1001 B
C#
using MongoDB.Bson;
|
|
using QuestionsApi.Services;
|
|
using Xunit;
|
|
|
|
namespace QuestionsApi.Tests;
|
|
|
|
public sealed class ContentPromotionTests
|
|
{
|
|
[Fact]
|
|
public void CollectMediaIdsDeduplicatesValidObjectIds()
|
|
{
|
|
var id = ObjectId.GenerateNewId();
|
|
var questions = new[]
|
|
{
|
|
new BsonDocument("Media", new BsonArray { id.ToString(), "not-an-object-id" }),
|
|
new BsonDocument("Media", new BsonArray { id.ToString() })
|
|
};
|
|
|
|
var result = ContentPromotionCommand.CollectMediaIds(questions);
|
|
|
|
Assert.Equal(new[] { id }, result);
|
|
}
|
|
|
|
[Fact]
|
|
public void ContentHashDoesNotDependOnInputOrder()
|
|
{
|
|
var first = new BsonDocument { ["ExternalId"] = "a", ["Stem"] = "one" };
|
|
var second = new BsonDocument { ["ExternalId"] = "b", ["Stem"] = "two" };
|
|
|
|
Assert.Equal(
|
|
ContentPromotionCommand.HashDocuments([first, second]),
|
|
ContentPromotionCommand.HashDocuments([second, first]));
|
|
}
|
|
}
|