diff --git a/LiteDB.Shell/Properties/AssemblyInfo.cs b/LiteDB.Shell/Properties/AssemblyInfo.cs index 0aa91a7a5..c88a924ff 100644 --- a/LiteDB.Shell/Properties/AssemblyInfo.cs +++ b/LiteDB.Shell/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("01ce385b-31a7-4b1a-9487-23fe8acb3888")] -[assembly: AssemblyVersion("3.1.0.0")] -[assembly: AssemblyFileVersion("3.1.0.0")] +[assembly: AssemblyVersion("3.1.1.0")] +[assembly: AssemblyFileVersion("3.1.1.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/LiteDB.Tests/Database/ULongListTest.cs b/LiteDB.Tests/Database/ULongListTest.cs new file mode 100644 index 000000000..bea1374ec --- /dev/null +++ b/LiteDB.Tests/Database/ULongListTest.cs @@ -0,0 +1,48 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; + +namespace LiteDB.Tests +{ + public class Gang + { + public ObjectId Id { get; set; } + public string Name { get; set; } + public ulong LeaderId { get; set; } + public ulong GuildId { get; set; } + public List Members { get; set; } + public double Wealth { get; set; } = 0.0; + public DateTime Raid { get; set; } = DateTime.UtcNow.AddYears(-1); + } + + [TestClass] + public class ULongListTest + { + [TestMethod] + public void ULongList_Test() + { + using (var file = new TempFile()) + using (var db = new LiteDatabase(file.Filename)) + { + var col = db.GetCollection(); + + col.Insert(new Gang + { + GuildId = 1, + LeaderId = 2, + Members = new List { 5, 6, 7} + }); + + ulong userId = 5; + ulong guildId = 1; + + var e = col.Exists(x => x.GuildId == guildId && (x.LeaderId == userId)); + + //Assert.IsTrue(e); + + } + } + } +} \ No newline at end of file diff --git a/LiteDB.Tests/LiteDB.Tests.csproj b/LiteDB.Tests/LiteDB.Tests.csproj index 8e6b7da84..b6136f106 100644 --- a/LiteDB.Tests/LiteDB.Tests.csproj +++ b/LiteDB.Tests/LiteDB.Tests.csproj @@ -70,6 +70,7 @@ + diff --git a/LiteDB.Tests/Program.cs b/LiteDB.Tests/Program.cs new file mode 100644 index 000000000..9cf6ea76f --- /dev/null +++ b/LiteDB.Tests/Program.cs @@ -0,0 +1,123 @@ +using System; +using LiteDB; + +namespace LiteDbRepro +{ + class Program + { + static void Main(string[] args) + { + BsonMapper.Global.Entity() + .Id(x => x.Id, true) + .Index(x => x.UserInvokeId) + .Index(x => x.Timestamp); + + using (var database = new LiteDatabase("history.db")) + { + var audioLogEntries = database.GetCollection("audioLogEntries"); + audioLogEntries.EnsureIndex(x => x.AudioResource.ResourceTitle); + audioLogEntries.EnsureIndex(x => x.AudioResource.UniqueId, true); + + var ale = new AudioLogEntry(1, new AudioResource("a", "b", AudioType.MediaLink)) + { + UserInvokeId = 42, + Timestamp = DateTime.UtcNow, + PlayCount = 1, + }; + + // Throws here: + audioLogEntries.Insert(ale); + } + } + } + + public class AudioLogEntry + { + /// A unique id for each , given by the history system. + public int Id { get; set; } + /// The dbid of the teamspeak user, who played this song first. + public uint UserInvokeId { get; set; } + /// How often the song has been played. + public uint PlayCount { get; set; } + /// The last time this song has been played. + public DateTime Timestamp { get; set; } + + public AudioResource AudioResource { get; set; } + + public AudioLogEntry() + { + PlayCount = 0; + } + + public AudioLogEntry(int id, AudioResource resource) : this() + { + Id = id; + AudioResource = resource; + } + + public void SetName(string newName) + { + AudioResource = AudioResource.WithName(newName); + } + } + + public class AudioResource + { + /// The resource type. + public AudioType AudioType { get; set; } + /// An identifier to create the song. This id is uniqe among same resources. + public string ResourceId { get; set; } + /// The display title. + public string ResourceTitle { get; set; } + /// An identifier wich is unique among all and . + public string UniqueId => ResourceId + AudioType.ToString(); + + public AudioResource() { } + + public AudioResource(string resourceId, string resourceTitle, AudioType type) + { + ResourceId = resourceId; + ResourceTitle = resourceTitle; + AudioType = type; + } + + public AudioResource(AudioResource copyResource) + { + ResourceId = copyResource.ResourceId; + ResourceTitle = copyResource.ResourceTitle; + AudioType = copyResource.AudioType; + } + + public AudioResource WithName(string newName) => new AudioResource(ResourceId, newName, AudioType); + + public override bool Equals(object obj) + { + var other = obj as AudioResource; + if (other == null) + return false; + + return AudioType == other.AudioType + && ResourceId == other.ResourceId; + } + + public override int GetHashCode() + { + int hash = 0x7FFFF + (int)AudioType; + hash = (hash * 0x1FFFF) + ResourceId.GetHashCode(); + return hash; + } + + public override string ToString() + { + return $"{AudioType} ID:{ResourceId}"; + } + } + + public enum AudioType + { + MediaLink, + Youtube, + Soundcloud, + Twitch, + } +} diff --git a/LiteDB.Tests/Properties/AssemblyInfo.cs b/LiteDB.Tests/Properties/AssemblyInfo.cs index c76e66af3..8547a2cc3 100644 --- a/LiteDB.Tests/Properties/AssemblyInfo.cs +++ b/LiteDB.Tests/Properties/AssemblyInfo.cs @@ -13,5 +13,5 @@ [assembly: NeutralResourcesLanguage("en")] [assembly: ComVisible(false)] [assembly: Guid("de183e83-7df6-475c-8185-b0070d098821")] -[assembly: AssemblyVersion("3.1.0.0")] -[assembly: AssemblyFileVersion("3.1.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("3.1.1.0")] +[assembly: AssemblyFileVersion("3.1.1.0")] \ No newline at end of file diff --git a/LiteDB.nuspec b/LiteDB.nuspec index 01ca6e3a0..a658e5219 100644 --- a/LiteDB.nuspec +++ b/LiteDB.nuspec @@ -2,7 +2,7 @@ LiteDB - 3.1.0 + 3.1.1 LiteDB Mauricio David http://www.litedb.org diff --git a/LiteDB/Properties/AssemblyInfo.cs b/LiteDB/Properties/AssemblyInfo.cs index 88cb248c8..c58d1c1e6 100644 --- a/LiteDB/Properties/AssemblyInfo.cs +++ b/LiteDB/Properties/AssemblyInfo.cs @@ -13,6 +13,6 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("54989b5c-4bcf-4d58-b8ba-9b014a324f76")] -[assembly: AssemblyVersion("3.1.0.0")] -[assembly: AssemblyFileVersion("3.1.0.0")] +[assembly: AssemblyVersion("3.1.1.0")] +[assembly: AssemblyFileVersion("3.1.1.0")] [assembly: NeutralResourcesLanguage("en")] \ No newline at end of file