Exemplo n.º 1
0
        public void Can_assign_brand_product()
        {
            var gamesTestHelper = Container.Resolve <GamesTestHelper>();
            var productId       = gamesTestHelper.CreateGameProvider().Id;
            var brand           = BrandTestHelper.CreateBrand();

            brand.Licensee.Products.Add(new LicenseeProduct
            {
                ProductId = productId
            });

            BrandRepository.SaveChanges();

            BrandCommands.AssignBrandProducts(new AssignBrandProductsData
            {
                BrandId     = brand.Id,
                ProductsIds = new[] { productId }
            });

            brand = BrandQueries.GetBrand(brand.Id);

            var brandProduct = brand.Products.SingleOrDefault(x => x.ProductId == productId);

            Assert.That(brandProduct, Is.Not.Null);
        }
Exemplo n.º 2
0
        public void Cannot_activate_brand_over_licensee_brand_limit()
        {
            var licensee = BrandHelper.CreateLicensee();

            licensee.AllowedBrandCount = 1;
            var brand = BrandHelper.CreateBrand(licensee);

            BrandCommands.ActivateBrand(new ActivateBrandRequest {
                BrandId = brand.Id, Remarks = "remarks"
            });

            var newBrand = BrandHelper.CreateBrand(BrandRepository.Licensees.Single(x => x.Id == licensee.Id));

            BrandHelper.AssignCountry(newBrand.Id, Country.Code);
            BrandHelper.AssignCulture(newBrand.Id, Culture.Code);
            PaymentHelper.CreatePaymentLevel(newBrand.Id, Currency.Code);
            BrandHelper.CreateWallet(licensee.Id, newBrand.Id);

            Action action = () => BrandCommands.ActivateBrand(new ActivateBrandRequest {
                BrandId = newBrand.Id, Remarks = "remarks"
            });

            action.ShouldThrow <ValidationException>()
            .Where(x => x.Message.Contains("licenseeBrandLimitExceeded"));
        }
Exemplo n.º 3
0
        public override void BeforeEach()
        {
            base.BeforeEach();

            _brandCommands = _container.Resolve <BrandCommands>();
            _brandQueries  = _container.Resolve <BrandQueries>();
        }
Exemplo n.º 4
0
        public async Task CreateNewBrand_Should_Create_A_New_Brand_And_Return_The_Created_Brand_Id()
        {
            var fakeBrandList  = new List <Brand>();
            var repositoryMock = new Mock <Repository.IRepository>();

            repositoryMock.Setup(r => r.Add(It.IsAny <Brand>()))
            .Callback <Brand>((brand) => fakeBrandList.Add(brand));

            Repository.IRepository        repository = repositoryMock.Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            string name        = "brand";
            string url         = "url";
            string description = "description";
            Image  logo        = new Image {
                MimeType = "image/jpeg", Data = new byte[0]
            };

            var commands = new BrandCommands(repository, eventBus);
            var brandId  = await commands.CreateNewBrand(name, url, description, logo);

            var createdBrand = fakeBrandList.FirstOrDefault(b => b.Id == brandId);

            Assert.NotNull(createdBrand);
            Assert.Equal(name, createdBrand.Name);
            Assert.Equal(url, createdBrand.Url);
            Assert.Equal(description, createdBrand.Description);
            Assert.Equal(logo, createdBrand.Logo);
        }
Exemplo n.º 5
0
        public async Task UpdateBrandInfo_Should_Update_Brand_With_Specified_Values()
        {
            var brand = Brand.Create("brand to edit", "brand-to-edit");

            var repositoryMock = new Mock <Repository.IRepository>();

            repositoryMock.Setup(r => r.GetByKeyAsync <Brand>(It.IsAny <Guid>()))
            .Returns(Task.FromResult(brand));

            Repository.IRepository        repository = repositoryMock.Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid   brandId     = brand.Id;
            string name        = "brand";
            string url         = "url";
            string description = "description";
            Image  logo        = new Image {
                MimeType = "image/jpeg", Data = new byte[0]
            };

            var commands = new BrandCommands(repository, eventBus);
            await commands.UpdateBrandInfo(brandId, name, url, description, logo);

            Assert.Equal(name, brand.Name);
            Assert.Equal(url, brand.Url);
            Assert.Equal(description, brand.Description);
            Assert.Equal(logo, brand.Logo);
        }
Exemplo n.º 6
0
 public ReportTestHelper(
     BrandCommands brandCommands,
     BrandQueries brandQueries,
     IBrandRepository brandRepository,
     FakeBus bus,
     OfflineDepositCommands depositCommands,
     IGameServerIntegrationRepository gameServerIntegrationRepository,
     PaymentQueries paymentQueries,
     IPaymentRepository paymentRepository,
     IPermissionProvider permissionProvider,
     PlayerCommands playerCommands,
     PlayerQueries playerQueries,
     RoleService roleService,
     ISharedData sharedData,
     UserService userService,
     WalletCommands walletWalletCommands
     )
 {
     _brandCommands        = brandCommands;
     _brandQueries         = brandQueries;
     _brandRepository      = brandRepository;
     _bus                  = bus;
     _depositCommands      = depositCommands;
     _paymentQueries       = paymentQueries;
     _paymentRepository    = paymentRepository;
     _permissionProvider   = permissionProvider;
     _gsiRepository        = gameServerIntegrationRepository;
     _playerCommands       = playerCommands;
     _playerQueries        = playerQueries;
     _roleService          = roleService;
     _sharedData           = sharedData;
     _userService          = userService;
     _walletWalletCommands = walletWalletCommands;
 }
Exemplo n.º 7
0
 public override void BeforeEach()
 {
     base.BeforeEach();
     _reportRepository = Container.Resolve <IReportRepository>();
     _reportQueries    = Container.Resolve <ReportQueries>();
     _brandCommands    = Container.Resolve <BrandCommands>();
     _serviceBus       = Container.Resolve <IServiceBus>();
 }
Exemplo n.º 8
0
        public void Cannot_update_unknown_country()
        {
            Action action = () => BrandCommands.UpdateCountry(
                TestDataGenerator.GetRandomString(),
                TestDataGenerator.GetRandomString());

            action.ShouldThrow <RegoException>()
            .WithMessage("Country not found");
        }
Exemplo n.º 9
0
        public override void BeforeEach()
        {
            base.BeforeEach();

            _gameRepository  = Container.Resolve <FakeGameRepository>();
            _brandCommands   = Container.Resolve <BrandCommands>();
            _brandRepository = Container.Resolve <IBrandRepository>();
            FillGamesRepository();
        }
Exemplo n.º 10
0
 public CountryController(
     BrandQueries queries,
     BrandCommands commands,
     IAuthQueries authQueries,
     IAdminQueries adminQueries)
     : base(authQueries, adminQueries)
 {
     _queries  = queries;
     _commands = commands;
 }
Exemplo n.º 11
0
 public override void BeforeEach()
 {
     base.BeforeEach();
     _reportRepository = Container.Resolve <IReportRepository>();
     _reportQueries    = Container.Resolve <ReportQueries>();
     _brandCommands    = Container.Resolve <BrandCommands>();
     _brandRepository  = Container.Resolve <IBrandRepository>();
     _gameRepository   = Container.Resolve <IGameRepository>();
     _gamesTestHelper  = Container.Resolve <GamesTestHelper>();
 }
Exemplo n.º 12
0
 public WalletController(
     BrandCommands brandCommands,
     BrandQueries brandQueries,
     IGameQueries gameQueries,
     IAdminQueries adminQueries)
 {
     _brandCommands = brandCommands;
     _brandQueries  = brandQueries;
     _gameQueries   = gameQueries;
     _adminQueries  = adminQueries;
 }
Exemplo n.º 13
0
 public BrandController(
     BrandQueries brandQueries,
     BrandCommands brandCommands,
     IAuthQueries authQueries,
     IAdminQueries adminQueries)
     : base(authQueries, adminQueries)
 {
     _brandQueries  = brandQueries;
     _brandCommands = brandCommands;
     _adminQueries  = adminQueries;
 }
Exemplo n.º 14
0
        public void Cannot_edit_vip_level_with_invalid_brand()
        {
            // Arrange
            var brand = BrandTestHelper.CreateBrand();
            var addVipLevelCommand = CreateAddVipLevelCommand(brand);

            LogWithNewAdmin(Modules.VipLevelManager, Permissions.Update);

            // Act
            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.EditVipLevel(addVipLevelCommand));
        }
Exemplo n.º 15
0
        public async Task RestoreBrand_Should_Throw_ArgumentException_If_BrandId_Is_Empty()
        {
            Repository.IRepository        repository = new Mock <Repository.IRepository>().Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid brandId = Guid.Empty;

            var commands = new BrandCommands(repository, eventBus);
            var ex       = await Assert.ThrowsAsync <ArgumentException>(() => commands.RestoreBrand(brandId));

            Assert.Equal(nameof(brandId), ex.ParamName);
        }
Exemplo n.º 16
0
        public void Can_delete_country()
        {
            var code = TestDataGenerator.GetRandomString(2);
            var name = TestDataGenerator.GetRandomString();

            BrandCommands.CreateCountry(code, name);

            BrandCommands.DeleteCountry(code);

            var country = BrandRepository.Countries.SingleOrDefault(x => x.Code == code);

            Assert.That(country, Is.Null);
        }
Exemplo n.º 17
0
        public void Can_Activate_Brand()
        {
            var brand = BrandHelper.CreateBrand();

            BrandCommands.ActivateBrand(new ActivateBrandRequest
            {
                BrandId = brand.Id,
                Remarks = "remarks"
            });
            brand = BrandQueries.GetBrandOrNull(brand.Id);

            Assert.That(brand.Status, Is.EqualTo(BrandStatus.Active));
        }
Exemplo n.º 18
0
 public CultureController(
     BrandQueries queries,
     BrandCommands commands,
     LicenseeQueries licenseeQueries,
     ICultureCommands cultureCommands,
     IAuthQueries authQueries,
     IAdminQueries adminQueries)
     : base(authQueries, adminQueries)
 {
     _brandQueries    = queries;
     _brandCommands   = commands;
     _licenseeQueries = licenseeQueries;
     _cultureCommands = cultureCommands;
 }
Exemplo n.º 19
0
 public BrandProductController(
     IGameQueries gameQueries,
     BrandQueries brandQueries,
     BrandCommands brandCommands,
     IGameManagement gameCommands,
     IAuthQueries authQueries,
     IAdminQueries adminQueries)
     : base(authQueries, adminQueries)
 {
     _gameQueries   = gameQueries;
     _brandQueries  = brandQueries;
     _brandCommands = brandCommands;
     _gameCommands  = gameCommands;
     _adminQueries  = adminQueries;
 }
Exemplo n.º 20
0
 public VipManagerController(
     BrandQueries brandQueries,
     BrandCommands brandCommands,
     IGameQueries gameQueries,
     IPlayerQueries playerQueries,
     IAdminQueries adminQueries,
     PlayerCommands playerCommands)
 {
     _brandQueries   = brandQueries;
     _brandCommands  = brandCommands;
     _gameQueries    = gameQueries;
     _adminQueries   = adminQueries;
     _playerCommands = playerCommands;
     _playerQueries  = playerQueries;
 }
Exemplo n.º 21
0
        public async Task SetBrandSeoData_Should_Throw_ArgumentException_If_BrandId_Is_Empty()
        {
            Repository.IRepository        repository = new Mock <Repository.IRepository>().Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid    brandId = Guid.Empty;
            SeoData seo     = new SeoData {
                Title = "title", Description = "description"
            };

            var commands = new BrandCommands(repository, eventBus);
            var ex       = await Assert.ThrowsAsync <ArgumentException>(() => commands.SetBrandSeoData(brandId, seo));

            Assert.Equal(nameof(brandId), ex.ParamName);
        }
Exemplo n.º 22
0
        public void Can_update_country()
        {
            var code = TestDataGenerator.GetRandomString(2);
            var name = TestDataGenerator.GetRandomString();

            BrandCommands.CreateCountry(code, name);

            var newName = TestDataGenerator.GetRandomString();

            BrandCommands.UpdateCountry(code, newName);

            var country = BrandRepository.Countries.Single(x => x.Code == code);

            Assert.That(country.Name, Is.EqualTo(newName));
        }
Exemplo n.º 23
0
 public PaymentLevelCommands(
     IPaymentRepository repository,
     IPaymentQueries paymentQueries,
     IBrandRepository brandRepository,
     PlayerCommands playerCommands,
     IActorInfoProvider actorInfoProvider,
     IEventBus eventBus,
     IPaymentLevelQueries paymentLevelQueries, BrandCommands brandCommands)
 {
     _repository          = repository;
     _paymentQueries      = paymentQueries;
     _brandRepository     = brandRepository;
     _playerCommands      = playerCommands;
     _actorInfoProvider   = actorInfoProvider;
     _eventBus            = eventBus;
     _paymentLevelQueries = paymentLevelQueries;
     _brandCommands       = brandCommands;
 }
Exemplo n.º 24
0
        public async Task UpdateBrandInfo_Should_Throw_ArgumentException_If_BrandId_Is_Empty()
        {
            Repository.IRepository        repository = new Mock <Repository.IRepository>().Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid   brandId     = Guid.Empty;
            string name        = "brand";
            string url         = "url";
            string description = "description";
            Image  logo        = new Image {
                MimeType = "image/jpeg", Data = new byte[0]
            };

            var commands = new BrandCommands(repository, eventBus);
            var ex       = await Assert.ThrowsAsync <ArgumentException>(() => commands.UpdateBrandInfo(brandId, name, url, description, logo));

            Assert.Equal(nameof(brandId), ex.ParamName);
        }
Exemplo n.º 25
0
        public async Task DeleteBrand_Should_Mark_Brand_As_Deleted()
        {
            var brand = Brand.Create("brand to edit", "brand-to-edit");

            var repositoryMock = new Mock <Repository.IRepository>();

            repositoryMock.Setup(r => r.GetByKeyAsync <Brand>(It.IsAny <Guid>()))
            .Returns(Task.FromResult(brand));

            Repository.IRepository        repository = repositoryMock.Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid brandId = brand.Id;

            var commands = new BrandCommands(repository, eventBus);
            await commands.DeleteBrand(brandId);

            Assert.True(brand.Deleted);
        }
Exemplo n.º 26
0
        public override void BeforeEach()
        {
            base.BeforeEach();

            _brandCommands = Container.Resolve <BrandCommands>();

            foreach (var countryCode in TestDataGenerator.CountryCodes)
            {
                BrandRepository.Countries.Add(new Country {
                    Code = countryCode
                });
            }

            foreach (var cultureCode in TestDataGenerator.CultureCodes.Where(x => x != null))
            {
                BrandRepository.Cultures.Add(new Culture {
                    Code = cultureCode
                });
            }

            _fakeGameRepository = Container.Resolve <FakeGameRepository>();
            _fakeGameRepository.GameProviderConfigurations.Add(new GameProviderConfiguration
            {
                Id   = Guid.NewGuid(),
                Name = "name" + TestDataGenerator.GetRandomAlphabeticString(5)
            });

            _fakeGameRepository.GameProviders.Add(new GameProvider
            {
                Id   = Guid.NewGuid(),
                Name = TestDataGenerator.GetRandomAlphabeticString(6),
                GameProviderConfigurations = _fakeGameRepository.GameProviderConfigurations.ToList()
            });

            _fakeGameRepository.BetLimits.Add(new GameProviderBetLimit
            {
                GameProviderId = _fakeGameRepository.GameProviders.First().Id,
                Id             = Guid.NewGuid(),
                Code           = TestDataGenerator.GetRandomAlphabeticString(5)
            });

            _actorInfoProvider = Container.Resolve <IActorInfoProvider>();
        }
Exemplo n.º 27
0
        public void Can_assign_brand_country()
        {
            var brand = BrandTestHelper.CreateBrand();

            BrandCommands.AssignBrandCountry(new AssignBrandCountryRequest
            {
                Brand     = brand.Id,
                Countries = new [] { Country.Code }
            });

            brand = BrandQueries.GetBrand(brand.Id);

            Assert.That(brand.BrandCountries.Count, Is.EqualTo(1));

            var assignedCountry = brand.BrandCountries.First().Country;

            Assert.That(assignedCountry.Code, Is.EqualTo(Country.Code));
            Assert.That(assignedCountry.Name, Is.EqualTo(Country.Name));
        }
Exemplo n.º 28
0
        public void Cannot_Activate_Brand_Without_Country()
        {
            var licensee = BrandHelper.CreateLicensee();
            var brandId  = BrandHelper.CreateBrand(licensee, PlayerActivationMethod.Automatic);

            BrandHelper.AssignCurrency(brandId, Currency.Code);
            BrandHelper.AssignCulture(brandId, Culture.Code);
            PaymentHelper.CreateBank(brandId, Country.Code);
            PaymentHelper.CreateBankAccount(brandId, Currency.Code);
            PaymentHelper.CreatePaymentLevel(brandId, Currency.Code);
            BrandHelper.CreateWallet(licensee.Id, brandId);
            BrandHelper.CreateVipLevel(brandId);

            Action action = () => BrandCommands.ActivateBrand(new ActivateBrandRequest {
                BrandId = brandId, Remarks = "remarks"
            });

            action.ShouldThrow <ValidationException>()
            .Where(x => x.Message.Contains("noAssignedCountry"));
        }
Exemplo n.º 29
0
        public void Cannot_Activate_Brand_Without_Payment_Level()
        {
            var licensee = BrandHelper.CreateLicensee();
            var brandId  = BrandHelper.CreateBrand(licensee, PlayerActivationMethod.Automatic);

            BrandHelper.AssignCountry(brandId, Country.Code);
            BrandHelper.AssignCurrency(brandId, Currency.Code);
            BrandHelper.AssignCulture(brandId, Culture.Code);
            BrandHelper.CreateWallet(licensee.Id, brandId);
            BrandHelper.CreateVipLevel(brandId);
            BrandHelper.CreateRiskLevel(brandId);
            BrandHelper.AssignProducts(brandId, new [] { licensee.Products.First().ProductId });

            Action action = () => BrandCommands.ActivateBrand(new ActivateBrandRequest {
                BrandId = brandId, Remarks = "remarks"
            });

            action.ShouldThrow <ValidationException>()
            .Where(x => x.Message.Contains("noDefaultPaymentLevels"));
        }
Exemplo n.º 30
0
        public void Cannot_execute_BrandCommands_without_permissions()
        {
            /* Arrange */
            LogWithNewAdmin(Modules.VipLevelManager, Permissions.View);

            /* Act */
            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.AddVipLevel(new VipLevelViewModel()));
            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.EditVipLevel(new VipLevelViewModel()));

            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.ActivateVipLevel(new Guid(), "remarks"));
            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.DeactivateVipLevel(new Guid(), "remarks", null));

            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.CreateCountry(TestDataGenerator.GetRandomString(2), TestDataGenerator.GetRandomString(5)));
            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.UpdateCountry(TestDataGenerator.GetRandomString(2), TestDataGenerator.GetRandomString(5)));
            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.DeleteCountry(TestDataGenerator.GetRandomString(2)));

            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.ActivateCulture(TestDataGenerator.GetRandomString(2), "remark"));
            Assert.Throws <InsufficientPermissionsException>(() => BrandCommands.DeactivateCulture(TestDataGenerator.GetRandomString(2), "remark"));

            Assert.Throws <InsufficientPermissionsException>(() => BrandHelper.CreateBrand());
        }