/// <inheritdoc /> public DatabaseBackedCharacterSessionRepository(CharacterDatabaseContext context, [NotNull] ILogger <DatabaseBackedCharacterSessionRepository> logger) { Context = context ?? throw new ArgumentNullException(nameof(context)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); GenericCrudService = new GeneralGenericCrudRepositoryProvider <int, CharacterSessionModel>(context.CharacterSessions, context); }
public static async Task Test_Controller_Produces_AlreadyHasActiveSession_When_Session_Has() { //arrange IServiceProvider serviceProvider = ControllerTestsHelpers.BuildServiceProvider <CharacterSessionController>("Test", 1); CharacterSessionController controller = serviceProvider.GetService <CharacterSessionController>(); ICharacterRepository characterRepo = serviceProvider.GetService <ICharacterRepository>(); ICharacterSessionRepository sessionRepo = serviceProvider.GetService <ICharacterSessionRepository>(); ICharacterLocationRepository characterLocationRepo = serviceProvider.GetService <ICharacterLocationRepository>(); IZoneServerRepository zoneRepository = serviceProvider.GetService <IZoneServerRepository>(); await characterRepo.TryCreateAsync(new CharacterEntryModel(1, "Testing")); await sessionRepo.TryCreateAsync(new CharacterSessionModel(1, 0)); //We can't create the claimed session through this interface because it's a stored procedure. //Raw SQL can't execute. So we must interact directly with the DbSet //await sessionRepo.TryClaimUnclaimedSession(1, 1); CharacterDatabaseContext context = serviceProvider.GetService <CharacterDatabaseContext>(); await context.ClaimedSession.AddAsync(new ClaimedSessionsModel(1)); await context.SaveChangesAsync(); //act CharacterSessionEnterResponse response = await controller.EnterSession(1, characterLocationRepo, zoneRepository); //assert Assert.False(response.isSuccessful, $"Characters that already have "); Assert.AreEqual(CharacterSessionEnterResponseCode.AccountAlreadyHasCharacterSession, response.ResultCode); }
/// <inheritdoc /> public DatabaseBackedCharacterRepository(CharacterDatabaseContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } Context = context; }
public static void Test_MockedDatabaseContext_Can_Build() { //arange ServiceCollection collection = new ServiceCollection(); IServiceProvider provider = collection.AddTestDatabaseContext<CharacterDatabaseContext>() .AddDefaultDataTestServices() .BuildServiceProvider(); //act CharacterDatabaseContext result = provider.GetService<CharacterDatabaseContext>(); //assert Assert.NotNull(result); }
public DatabaseBackedDefaultActionBarRepository([JetBrains.Annotations.NotNull] CharacterDatabaseContext context) { Context = context ?? throw new ArgumentNullException(nameof(context)); }
/// <inheritdoc /> public DatabaseBackedGroupEntryRepository([JetBrains.Annotations.NotNull] CharacterDatabaseContext context) { Context = context ?? throw new ArgumentNullException(nameof(context)); GenericBackedRepository = new GeneralGenericCrudRepositoryProvider <int, CharacterGroupEntryModel>(context.Groups, context); }
/// <inheritdoc /> public DatabaseBackedCharacterFriendRelationshipRepository([JetBrains.Annotations.NotNull] CharacterDatabaseContext context) { Context = context ?? throw new ArgumentNullException(nameof(context)); GenericRepository = new GeneralGenericCrudRepositoryProvider <int, CharacterFriendRelationshipModel>(context.CharacterFriendRequests, context); }
/// <inheritdoc /> public DatabaseBackedZoneServerRepository(CharacterDatabaseContext context) { Context = context ?? throw new ArgumentNullException(nameof(context)); }