Skip to content

Commit

Permalink
Fix nuget to 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mbdavid committed Jun 8, 2017
1 parent fda371a commit 6770689
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 7 deletions.
4 changes: 2 additions & 2 deletions LiteDB.Shell/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

48 changes: 48 additions & 0 deletions LiteDB.Tests/Database/ULongListTest.cs
Original file line number Diff line number Diff line change
@@ -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<ulong> 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<Gang>();

col.Insert(new Gang
{
GuildId = 1,
LeaderId = 2,
Members = new List<ulong> { 5, 6, 7}
});

ulong userId = 5;
ulong guildId = 1;

var e = col.Exists(x => x.GuildId == guildId && (x.LeaderId == userId));

//Assert.IsTrue(e);

}
}
}
}
1 change: 1 addition & 0 deletions LiteDB.Tests/LiteDB.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<Compile Include="Concurrency\ProcessTest.cs" />
<Compile Include="Database\BigDatabaseTest.cs" />
<Compile Include="Database\AutoIndexDatabaseTest.cs" />
<Compile Include="Database\ULongListTest.cs" />
<Compile Include="Database\UpgradeScriptTest.cs" />
<Compile Include="Engine\BulkInsertTest.cs" />
<Compile Include="Mapper\CustomTypeTest.cs" />
Expand Down
123 changes: 123 additions & 0 deletions LiteDB.Tests/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using System;
using LiteDB;

namespace LiteDbRepro
{
class Program
{
static void Main(string[] args)
{
BsonMapper.Global.Entity<AudioLogEntry>()
.Id(x => x.Id, true)
.Index(x => x.UserInvokeId)
.Index(x => x.Timestamp);

using (var database = new LiteDatabase("history.db"))
{
var audioLogEntries = database.GetCollection<AudioLogEntry>("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
{
/// <summary>A unique id for each <see cref="ResourceFactories.AudioResource"/>, given by the history system.</summary>
public int Id { get; set; }
/// <summary>The dbid of the teamspeak user, who played this song first.</summary>
public uint UserInvokeId { get; set; }
/// <summary>How often the song has been played.</summary>
public uint PlayCount { get; set; }
/// <summary>The last time this song has been played.</summary>
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
{
/// <summary>The resource type.</summary>
public AudioType AudioType { get; set; }
/// <summary>An identifier to create the song. This id is uniqe among same <see cref="TS3AudioBot.AudioType"/> resources.</summary>
public string ResourceId { get; set; }
/// <summary>The display title.</summary>
public string ResourceTitle { get; set; }
/// <summary>An identifier wich is unique among all <see cref="AudioResource"/> and <see cref="TS3AudioBot.AudioType"/>.</summary>
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,
}
}
4 changes: 2 additions & 2 deletions LiteDB.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
[assembly: AssemblyVersion("3.1.1.0")]
[assembly: AssemblyFileVersion("3.1.1.0")]
2 changes: 1 addition & 1 deletion LiteDB.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>LiteDB</id>
<version>3.1.0</version>
<version>3.1.1</version>
<title>LiteDB</title>
<authors>Mauricio David</authors>
<projectUrl>http://www.litedb.org</projectUrl>
Expand Down
4 changes: 2 additions & 2 deletions LiteDB/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit 6770689

Please sign in to comment.