예제 #1
0
        public PlatformTypeServiceTest()
        {
            _uow = new Mock <IUnitOfWork>();
            var log = new Mock <ILog>();

            _mapper = MapperConfigUi.GetMapper().CreateMapper();
            _sut    = new PlatformTypeService(_uow.Object, _mapper, log.Object);

            _fakePlatformTypeId   = Guid.NewGuid();
            _fakePlatformTypeName = "PlatformType1";

            _fakePlatformType = new PlatformType
            {
                Id     = _fakePlatformTypeId,
                NameEn = _fakePlatformTypeName
            };

            _fakePlatformTypes = new List <PlatformType>()
            {
                _fakePlatformType,

                new PlatformType()
                {
                    Id = new Guid()
                }
            };
        }
예제 #2
0
        public GenreServiceTest()
        {
            _uow = new Mock <IUnitOfWork>();
            var log = new Mock <ILog>();

            _mapper = MapperConfigUi.GetMapper().CreateMapper();
            _sut    = new GenreService(_uow.Object, _mapper, log.Object);

            _fakeGenreName = "genre1";
            _fakeGenreId   = Guid.NewGuid();

            _fakeGenre = new Genre
            {
                Id     = _fakeGenreId,
                NameEn = _fakeGenreName
            };

            _fakeGenres = new List <Genre>()
            {
                _fakeGenre,

                new Genre()
                {
                    Id     = new Guid(),
                    NameEn = "genre2"
                }
            };
        }
예제 #3
0
        public PlatformTypeControllerTest()
        {
            _mapper = MapperConfigUi.GetMapper().CreateMapper();
            _platformTypeService = new Mock <IPlatformTypeService>();
            _sut = new PlatformTypeController(_platformTypeService.Object, _mapper, null);

            _fakePlatformTypeName = "test";
        }
예제 #4
0
        public GenreControllerTest()
        {
            _mapper       = MapperConfigUi.GetMapper().CreateMapper();
            _genreService = new Mock <IGenreService>();
            _sut          = new GenreController(_genreService.Object, _mapper, null);

            _fakeGenreName = "test";
        }
예제 #5
0
        public RoleControllerTests()
        {
            _mapper      = MapperConfigUi.GetMapper().CreateMapper();
            _roleService = new Mock <IRoleService>();
            _sut         = new RoleController(_roleService.Object, _mapper, null);

            _fakeRoleName = "test";
        }
예제 #6
0
        public PublisherControllerTest()
        {
            _mapper           = MapperConfigUi.GetMapper().CreateMapper();
            _publisherService = new Mock <IPublisherService>();
            _userService      = new Mock <IUserService>();
            _sut = new PublisherController(_publisherService.Object, _userService.Object, _mapper, null);

            _fakePublisherName = "test";
        }
예제 #7
0
 protected override void Load(ContainerBuilder builder)
 {
     builder.RegisterInstance(LogManager.GetLogger("LOGGER"));
     builder.Register(pf => new TrackRequestIp(pf.Resolve <ILog>())).AsActionFilterFor <Controller>();
     builder.Register(pf => new ExceptionFilter(pf.Resolve <ILog>())).AsExceptionFilterFor <Controller>();
     builder.RegisterType <FilterViewModelBuilder>().AsSelf().InstancePerLifetimeScope();
     builder.RegisterInstance(MapperConfigUi.GetMapper().CreateMapper());
     builder.RegisterType <Bank>().As <IPayment>().InstancePerLifetimeScope();
     builder.RegisterType <Visa>().As <IPayment>().InstancePerLifetimeScope();
     builder.RegisterType <Box>().As <IPayment>().InstancePerLifetimeScope();
     builder.RegisterType <PaymentStrategy>().As <IPaymentStrategy>().InstancePerLifetimeScope();
     builder.RegisterType <CustomAuthentication>().As <IAuthentication>().InstancePerLifetimeScope();
 }
예제 #8
0
        public CommentControllerTest()
        {
            _commentService = new Mock <ICommentService>();
            var gameService = new Mock <IGameService>();

            _mapper = MapperConfigUi.GetMapper().CreateMapper();
            _sut    = new CommentController(_commentService.Object, gameService.Object, _mapper, null);

            _fakeCommentId = Guid.NewGuid();
            _fakeGameId    = Guid.NewGuid();
            _fakeGameKey   = _fakeCommentId.ToString();

            _fakeComment = new List <CommentDTO>()
            {
                new CommentDTO()
            };
        }
예제 #9
0
        public CommentServiceTest()
        {
            _uow    = new Mock <IUnitOfWork>();
            _mapper = MapperConfigUi.GetMapper().CreateMapper();
            var log = new Mock <ILog>();

            _sut = new CommentService(_uow.Object, _mapper, log.Object);

            _gameKey       = Guid.NewGuid().ToString();
            _fakeCommentId = Guid.Empty;

            _fakeGame = new Game()
            {
                Id  = Guid.NewGuid(),
                Key = _gameKey
            };

            _fakeComment = new Comment()
            {
                Id   = _fakeCommentId,
                Game = _fakeGame,
                Name = "1",
                Body = "1"
            };

            _fakeComments = new List <Comment>
            {
                new Comment()
                {
                    Id   = Guid.NewGuid(),
                    Game = _fakeGame,
                    Name = "1",
                    Body = "1"
                },

                new Comment()
                {
                    Id   = Guid.NewGuid(),
                    Game = _fakeGame,
                    Name = "2",
                    Body = "2"
                }
            };
        }
예제 #10
0
        public UserServiceTests()
        {
            _uow = new Mock <IUnitOfWork>();
            var log = new Mock <ILog>();

            _mapper = MapperConfigUi.GetMapper().CreateMapper();
            _sut    = new UserService(_uow.Object, _mapper, log.Object);

            _fakeUserId   = Guid.NewGuid();
            _fakeUserName = "******";
            _fakeUser     = new User()
            {
                Id   = _fakeUserId,
                Name = _fakeUserName
            };
            _fakeUsers = new List <User>()
            {
                _fakeUser
            };
        }
예제 #11
0
        public OrderControllerTest()
        {
            _bankMock = new Bank();
            _boxMock  = new Box();
            _visaMock = new Visa();
            _stratagy = new List <IPayment> {
                _bankMock, _boxMock, _visaMock
            };

            _paymentStrategy = new PaymentStrategy(_stratagy);
            _mapper          = MapperConfigUi.GetMapper().CreateMapper();
            _ordersService   = new Mock <IOrdersService>();
            _gameService     = new Mock <IGameService>();
            _authentication  = new Mock <IAuthentication>();
            _sut             = new OrderController(
                _ordersService.Object,
                _gameService.Object,
                _mapper,
                _paymentStrategy,
                _authentication.Object);
        }
예제 #12
0
        public GameControllerTest()
        {
            _mapper                 = MapperConfigUi.GetMapper().CreateMapper();
            _gameService            = new Mock <IGameService>();
            _genreService           = new Mock <IGenreService>();
            _platformTypeService    = new Mock <IPlatformTypeService>();
            _publisherService       = new Mock <IPublisherService>();
            _filterViewModelBuilder = new FilterViewModelBuilder(
                _genreService.Object,
                _platformTypeService.Object,
                _mapper,
                _publisherService.Object);
            _sut = new GameController(
                _gameService.Object,
                _genreService.Object,
                _platformTypeService.Object,
                _mapper,
                _publisherService.Object,
                _filterViewModelBuilder,
                null);

            var fakeCommentId = Guid.NewGuid();

            _fakeGameId  = Guid.NewGuid();
            _fakeGameKey = fakeCommentId.ToString();

            _fakeGames = new List <GameDTO>
            {
                new GameDTO()
                {
                    Id  = Guid.NewGuid(),
                    Key = "1"
                },
                new GameDTO()
                {
                    Id  = Guid.NewGuid(),
                    Key = "2"
                }
            };
        }
예제 #13
0
        public OrdersServiceTest()
        {
            _uow = new Mock <IUnitOfWork>();
            var log = new Mock <ILog>();

            _mapper = MapperConfigUi.GetMapper().CreateMapper();
            _sut    = new OrdersService(_uow.Object, _mapper, log.Object);

            _fakeUserId = Guid.NewGuid();
            _fakeGameId = Guid.NewGuid();

            _fakeGame = new Game()
            {
                Id           = _fakeGameId,
                Key          = "123",
                UnitsInStock = 10
            };

            _fakeOrderDetails = new List <OrderDetail>()
            {
                new OrderDetail()
                {
                    GameId   = _fakeGameId,
                    Quantity = 1,
                    Game     = _fakeGame
                }
            };

            _fakeOrder = new Order()
            {
                UserId       = _fakeUserId,
                OrderDetails = _fakeOrderDetails
            };

            _fakeOrders = new List <Order>()
            {
                _fakeOrder
            };
        }
예제 #14
0
        public RoleServiceTest()
        {
            _uow = new Mock <IUnitOfWork>();
            var log = new Mock <ILog>();

            _mapper = MapperConfigUi.GetMapper().CreateMapper();
            _sut    = new RoleService(_uow.Object, _mapper, log.Object);

            _fakeRoleId   = Guid.NewGuid();
            _fakeRoleName = "RoleName";

            _fakeRole = new Role
            {
                Id   = _fakeRoleId,
                Name = _fakeRoleName
            };

            _fakeRoles = new List <Role>()
            {
                _fakeRole
            };
        }
예제 #15
0
        public GameServiceTest()
        {
            _uow = new Mock <IUnitOfWork>();
            var log = new Mock <ILog>();

            _mapper = MapperConfigUi.GetMapper().CreateMapper();
            _sut    = new GameService(_uow.Object, _mapper, log.Object);

            _fakeGameKey        = Guid.NewGuid().ToString();
            _fakeGameId         = Guid.NewGuid();
            _fakeGenreId        = Guid.NewGuid();
            _fakePlatformTypeId = Guid.NewGuid();

            _fakeGenre = new Genre
            {
                Id     = _fakeGenreId,
                NameEn = "genre1"
            };

            _fakePublisher = new Publisher()
            {
                Id   = Guid.NewGuid(),
                Name = "Publisher"
            };

            var fakeGenres = new List <Genre>()
            {
                _fakeGenre,

                new Genre()
                {
                    Id     = new Guid(),
                    NameEn = "genre1"
                }
            };

            _fakePlatformType = new PlatformType()
            {
                Id     = _fakePlatformTypeId,
                NameEn = "platformType1"
            };

            var fakePlatformTypes = new List <PlatformType>()
            {
                _fakePlatformType
            };

            _fakeGame = new Game()
            {
                Id            = _fakeGameId,
                Key           = _fakeGameKey,
                Genres        = fakeGenres,
                PlatformTypes = fakePlatformTypes,
                NameEn        = "game",
                Price         = 10,
                Publisher     = _fakePublisher,
                PublishDate   = DateTime.Today,
                Views         = 200
            };

            _fakeGames = new List <Game>
            {
                _fakeGame
            };

            _fakeGamesForFilter = new List <Game>
            {
                _fakeGame,

                new Game()
                {
                    Id            = Guid.NewGuid(),
                    Key           = Guid.NewGuid().ToString(),
                    NameEn        = "gamegame",
                    Genres        = fakeGenres,
                    PlatformTypes = fakePlatformTypes,
                    Price         = 15,
                    Publisher     = _fakePublisher,
                    PublishDate   = DateTime.Today.AddMonths(-1),
                    Views         = 10
                }
            };
        }