Last active
June 26, 2016 09:36
-
-
Save nickchampion/28126e1c5942e5c5da3332868d96598e to your computer and use it in GitHub Desktop.
RavenDB Failing test serialisation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using NUnit.Framework; | |
using Raven.Abstractions.Cluster; | |
using Raven.Abstractions.Replication; | |
using Raven.Client; | |
using Raven.Client.Document; | |
using Raven.Client.UniqueConstraints; | |
using Raven.Tests.Helpers; | |
namespace Marketplace.Tests.Unit.RavenDb | |
{ | |
[TestFixture] | |
public class FailingRavenTests : RavenTestBase | |
{ | |
[Test] | |
public void LoadAndSaveUser() | |
{ | |
using (var store = GetStore()) | |
{ | |
using (var session = store.OpenSession("Test")) | |
{ | |
var user = session.Load<TestUser>("users/1"); | |
user.FirstName = "bob"; | |
session.SaveChanges(); | |
} | |
} | |
} | |
private IDocumentStore GetStore() | |
{ | |
var store = new DocumentStore | |
{ | |
Url = "", | |
ResourceManagerId = Guid.NewGuid(), | |
EnlistInDistributedTransactions = false, | |
Conventions = | |
{ | |
IndexAndTransformerReplicationMode = IndexAndTransformerReplicationMode.None, | |
FailoverBehavior = FailoverBehavior.FailImmediately, | |
ClusterBehavior = ClusterBehavior.None | |
} | |
}; | |
store.Initialize(); | |
return store; | |
} | |
} | |
public class TestUser | |
{ | |
public string Id { get; set; } | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
[UniqueConstraint(CaseInsensitive = true)] | |
public string Email { get; set; } | |
public string ExternalId { get; set; } | |
public string Password { get; set; } | |
public Guid? PasswordToken { get; set; } | |
public UserType UserType { get; set; } | |
public string MerchantId { get; set; } | |
public DateTimeOffset CreatedAt { get; set; } | |
public DateTimeOffset? LastLogin { get; set; } | |
public string CreatedByUserId { get; set; } | |
public string Source { get; set; } | |
public string Country2LetterISOCode { get; set; } | |
public string Timezone { get; set; } | |
public string Language { get; set; } | |
public string Gender { get; set; } | |
public string Avatar { get; set; } | |
public string SsoToken { get; set; } | |
public ApiToken ApiToken { get; set; } | |
public TelephoneNumber ContactNumber { get; set; } | |
public UserPreferences Preferences { get; set; } | |
public DateTime? DateOfBirth { get; set; } | |
public List<ThirdPartyConnection> ThirdPartyConnections { get; set; } | |
public List<string> Merchants { get; set; } | |
public List<string> Roles { get; set; } | |
public List<string> Countries { get; set; } | |
public TestUser() | |
{ | |
CreatedAt = DateTimeOffset.Now; | |
ThirdPartyConnections = new List<ThirdPartyConnection>(); | |
Preferences = new UserPreferences(); | |
Merchants = new List<string>(); | |
Roles = new List<string>(); | |
Countries = new List<string>(); | |
} | |
} | |
public class UserPreferences | |
{ | |
public int? DefaultShippingAddressId { get; set; } | |
public int? DefaultBillingAddressId { get; set; } | |
public string DefaultPaymentMethodId { get; set; } | |
} | |
public class ThirdPartyConnection | |
{ | |
public ThirdParty ThirdParty { get; set; } | |
public string Id { get; set; } | |
public string Token { get; set; } | |
} | |
public enum UserType | |
{ | |
Guest, | |
User | |
} | |
public enum ThirdParty | |
{ | |
} | |
public class TelephoneNumber | |
{ | |
public int? CountryCode { get; set; } | |
public string Number { get; set; } | |
public TelephoneNumber() | |
{ } | |
public TelephoneNumber(int countryCode, string number) | |
{ | |
CountryCode = countryCode; | |
Number = number; | |
} | |
} | |
public class ApiToken | |
{ | |
public DateTimeOffset CreatedAt { get; set; } | |
public string Token { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment