示例#1
0
                private static async Task <ActionResult> AddPackageOwner(JsonApiController jsonApiController, string packageId, string username)
                {
                    AddPackageOwnerViewModel testData = new AddPackageOwnerViewModel
                    {
                        Id       = packageId,
                        Username = username,
                        Message  = "message"
                    };

                    return(await jsonApiController.AddPackageOwner(testData));
                }
        private static JsonApiController CreateJsonApiController(
            Mock<IPackageService> packageService = null,
            Mock<IUserService> userService = null,
            Mock<IEntityRepository<PackageOwnerRequest>> repository = null,
            Mock<IMessageService> messageService = null,
            Mock<IPrincipal> currentUser = null)
        {
            packageService = packageService ?? new Mock<IPackageService>();
            userService = userService ?? new Mock<IUserService>();
            repository = repository ?? new Mock<IEntityRepository<PackageOwnerRequest>>();
            messageService = messageService ?? new Mock<IMessageService>();
            currentUser = currentUser ?? new Mock<IPrincipal>();

            var httpContext = new Mock<HttpContextBase>();
            httpContext.Setup(c => c.User).Returns(currentUser.Object);
            var controller = new JsonApiController(packageService.Object, userService.Object, repository.Object, messageService.Object);
            TestUtility.SetupHttpContextMockForUrlGeneration(httpContext, controller);
            return controller;
        }
示例#3
0
        public ApiGatewayControllersTests()
        {
            var redisDB = DefaultRedis.Instance;

            redisDB.DataFormater = new JsonFormater();
            redisDB.Host.AddWriteHost("redisTestServer", 6381);
            redisDB.Flushall();

            var statisticsServiceBeetleXRedis = new StatisticsServiceBeetleXRedis(redisDB);
            var sessionServiceBeetleXRedis    = new SessionServiceBeetleXRedis(redisDB);
            var sessionConfiguration          = new SessionConfiguration()
            {
                TTL = 1000
            };

            _jsonApiController       = new JsonApiController(sessionServiceBeetleXRedis, statisticsServiceBeetleXRedis, sessionConfiguration);
            _xmlApiController        = new XMLApiController(sessionServiceBeetleXRedis, statisticsServiceBeetleXRedis, sessionConfiguration);
            _statisticsApiController = new StatisticsApiController(statisticsServiceBeetleXRedis);
        }
示例#4
0
        private static JsonApiController CreateJsonApiController(
            Mock <IPackageService> packageService = null,
            Mock <IUserService> userService       = null,
            Mock <IEntityRepository <PackageOwnerRequest> > repository = null,
            Mock <IMessageService> messageService = null,
            Mock <IPrincipal> currentUser         = null)
        {
            packageService = packageService ?? new Mock <IPackageService>();
            userService    = userService ?? new Mock <IUserService>();
            repository     = repository ?? new Mock <IEntityRepository <PackageOwnerRequest> >();
            messageService = messageService ?? new Mock <IMessageService>();
            currentUser    = currentUser ?? new Mock <IPrincipal>();

            var httpContext = new Mock <HttpContextBase>();

            httpContext.Setup(c => c.User).Returns(currentUser.Object);
            var controller = new JsonApiController(packageService.Object, userService.Object, repository.Object, messageService.Object);

            TestUtility.SetupHttpContextMockForUrlGeneration(httpContext, controller);
            return(controller);
        }
示例#5
0
 private static async Task <ActionResult> RemovePackageOwner(JsonApiController jsonApiController, string packageId, string username)
 {
     return(await jsonApiController.RemovePackageOwner(packageId, username));
 }
示例#6
0
 private static async Task <ActionResult> AddPackageOwner(JsonApiController jsonApiController, string packageId, string username)
 {
     return(await jsonApiController.AddPackageOwner(packageId, username, "message"));
 }
示例#7
0
 private static Task <ActionResult> GetAddPackageOwnerConfirmation(JsonApiController jsonApiController, string packageId, string username)
 {
     return(Task.Run(() => jsonApiController.GetAddPackageOwnerConfirmation(packageId, username)));
 }