示例#1
0
 /// <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);
 }
示例#2
0
        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);
        }
示例#3
0
        /// <inheritdoc />
        public DatabaseBackedCharacterRepository(CharacterDatabaseContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            Context = context;
        }
示例#4
0
		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);
		}
示例#5
0
 public DatabaseBackedDefaultActionBarRepository([JetBrains.Annotations.NotNull] CharacterDatabaseContext context)
 {
     Context = context ?? throw new ArgumentNullException(nameof(context));
 }
示例#6
0
 /// <inheritdoc />
 public DatabaseBackedGroupEntryRepository([JetBrains.Annotations.NotNull] CharacterDatabaseContext context)
 {
     Context = context ?? throw new ArgumentNullException(nameof(context));
     GenericBackedRepository = new GeneralGenericCrudRepositoryProvider <int, CharacterGroupEntryModel>(context.Groups, context);
 }
示例#7
0
        /// <inheritdoc />
        public DatabaseBackedCharacterFriendRelationshipRepository([JetBrains.Annotations.NotNull] CharacterDatabaseContext context)
        {
            Context = context ?? throw new ArgumentNullException(nameof(context));

            GenericRepository = new GeneralGenericCrudRepositoryProvider <int, CharacterFriendRelationshipModel>(context.CharacterFriendRequests, context);
        }
示例#8
0
 /// <inheritdoc />
 public DatabaseBackedZoneServerRepository(CharacterDatabaseContext context)
 {
     Context = context ?? throw new ArgumentNullException(nameof(context));
 }