forked from TheAlgorithms/C-Sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvertedIndexTests.cs
36 lines (29 loc) · 1.1 KB
/
InvertedIndexTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections.Generic;
using FluentAssertions;
using NUnit.Framework;
namespace DataStructures.Tests;
public class InvertedIndexTests
{
[Test]
public void Or_GetSourcesWithAtLeastOneFromList_ReturnAllSources()
{
var index = new InvertedIndex();
var source1 = "one star is sparkling bright";
var source2 = "two stars are sparkling even brighter";
index.AddToIndex(nameof(source1), source1);
index.AddToIndex(nameof(source2), source2);
var or = index.Or(new List<string> { "star", "sparkling" });
or.Should().BeEquivalentTo(nameof(source1), nameof(source2));
}
[Test]
public void And_GetSourcesWithAllInsideList_ReturnFirstSource()
{
var index = new InvertedIndex();
var source1 = "one star is sparkling bright";
var source2 = "two stars are sparkling even brighter";
index.AddToIndex(nameof(source1), source1);
index.AddToIndex(nameof(source2), source2);
var and = index.And(new List<string> { "star", "sparkling" });
and.Should().BeEquivalentTo(nameof(source1));
}
}