public void TestMethod_SignUpWithEmail_SuccessRegistration() { //Arrange var dbContext = InMemoryDatabaseFactory.Create(); AccountRegistrationService registrationService = new AccountRegistrationService(dbContext); EmailLoginInfo emailLoginInfo = new EmailLoginInfo { Email = "*****@*****.**", Password = "******" }; string name = "Muhammad"; //Act registrationService.RegisterAccountAsync(name, emailLoginInfo).Wait(); //Assert var account = dbContext.Accounts .Include(account1 => account1.EmailLoginInfo) .Include(account1 => account1.OrderStatusGroups) .First(); Assert.AreEqual(name, account.Name); Assert.AreEqual(emailLoginInfo.Email, account.EmailLoginInfo.Email); Assert.AreEqual(emailLoginInfo.Password, account.EmailLoginInfo.Password); Assert.IsTrue(account.OrderStatusGroups.Count > 0); }
public async Task TestMethod_SignUpWithTelegram_SuccessRegistration() { //Arrange AccountRegistrationService registrationService = new AccountRegistrationService(dbContext); TelegramLoginInfo telegramLoginInfo = new TelegramLoginInfo { TelegramId = Int32.MaxValue / 2 }; string name = "Muhammad"; //Act await registrationService.RegisterAccountAsync(name, telegramLoginInfo); //Assert var telegramLoginInfoDb = await dbContext.TelegramLoginInfo .Where(info => info.TelegramId == telegramLoginInfo.TelegramId) .Include(info => info.Account) .SingleAsync(); var account = telegramLoginInfo.Account; Assert.AreEqual(name, account.Name); Assert.AreEqual(telegramLoginInfo.TelegramId, account.TelegramLoginInfo.TelegramId); Assert.IsTrue(account.OrderStatusGroups.Count > 0); }
public async Task TestMethod_SignUpWithEmail_SuccessRegistration() { //Arrange AccountRegistrationService registrationService = new AccountRegistrationService(dbContext); EmailLoginInfo emailLoginInfo = new EmailLoginInfo { Email = "kashdvbkjsahdvb", Password = "******" }; string name = "Muhammad"; //Act await registrationService.RegisterAccountAsync(name, emailLoginInfo); //Assert var emailLoginDb = await dbContext.EmailLoginInfo .Include(info => info.Account) .ThenInclude(account1 => account1.OrderStatusGroups) .Where(loginInfo => loginInfo.Email == emailLoginInfo.Email) .SingleAsync(); var accountDb = emailLoginDb.Account; Assert.AreEqual(name, accountDb.Name); Assert.AreEqual(emailLoginInfo.Email, accountDb.EmailLoginInfo.Email); Assert.AreEqual(emailLoginInfo.Password, accountDb.EmailLoginInfo.Password); Assert.IsTrue(accountDb.OrderStatusGroups.Count > 0); }
public SignUpController(ApplicationContext context, EmailMessageSender emailSender, SimpleLogger logger, AccountRegistrationService registrationService, DomainNameService domainNameService) { this.context = context; this.emailSender = emailSender; this.logger = logger; this.registrationService = registrationService; this.domainNameService = domainNameService; }
public void TestMethod_SignUpWithNullTelegramInfo_RegistrationFailure() { //Arrange var dbContext = InMemoryDatabaseFactory.Create(); AccountRegistrationService registrationService = new AccountRegistrationService(dbContext); string name = "Muhammad"; //Act registrationService.RegisterAccountAsync(name, (TelegramLoginInfo)null).Wait(); }
public void RegistrationUser(IList <string> roles) { AccountRegistrationService.CreateAccount(UserName, Password, roles); if (roles.Contains("student")) { SaveStudent(); } if (roles.Contains("lector")) { SaveLecturer(); } }
public void TestMethod_SignUpWithNullName_RegistrationFailure() { //Arrange var dbContext = InMemoryDatabaseFactory.Create(); AccountRegistrationService registrationService = new AccountRegistrationService(dbContext); TelegramLoginInfo telegramLoginInfo = new TelegramLoginInfo { TelegramId = Int32.MaxValue / 2 }; //Act registrationService.RegisterAccountAsync(null, telegramLoginInfo).Wait(); }
public static void Initialize() { Console.WriteLine("Initialization"); IDbConnectionConfig dbConnectionConfig = new DbConnectionConfig(DatabaseName); //Создать БД dbContextFactory = new DbContextFactory(dbConnectionConfig); DbContext = dbContextFactory.Create(DatabaseName); //Ввести базовые данные var seeder = new DataSeeder(); seeder.Seed(DbContext); //Прервать текущие сессии DbContext.Accounts.FromSql(new RawSqlString("ALTER DATABASE {0} SET postgres WITH ROLLBACK IMMEDIATE"), DatabaseName); //Очиста аккаунта TruncateAccountsTable(); string connectionString = dbConnectionConfig.GetConnectionString(); //Создать сервисы NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connectionString); ISkinsDbReaderService skinsDbReaderService = new SkinsDbReaderService(DbContext); IDbWarshipsStatisticsReader dbWarshipsStatisticsReader = new DbWarshipsStatisticsReader(npgsqlConnection); IDbAccountWarshipReaderService dbAccountWarshipReaderService = new DbAccountWarshipReaderService(dbWarshipsStatisticsReader, skinsDbReaderService); AccountResourcesDbReader accountResourcesDbReader = new AccountResourcesDbReader(npgsqlConnection); AccountReaderService = new AccountDbReaderService(dbAccountWarshipReaderService, accountResourcesDbReader); NotShownRewardsReaderService = new NotShownRewardsReaderService(DbContext); DefaultAccountFactoryService = new DefaultAccountFactoryService(DbContext); var accountRegistrationService = new AccountRegistrationService(DefaultAccountFactoryService); var warshipsCharacteristicsService = new WarshipsCharacteristicsService(); AccountMapperService accountMapperService = new AccountMapperService(warshipsCharacteristicsService); AccountFacadeService = new AccountFacadeService(AccountReaderService, accountRegistrationService); var bundleVersionService = new BundleVersionService(); LobbyModelFacadeService = new LobbyModelFacadeService(AccountFacadeService, NotShownRewardsReaderService, accountMapperService, bundleVersionService); UsernameValidatorService usernameValidatorService = new UsernameValidatorService(); UsernameChangingService usernameChangingService = new UsernameChangingService(usernameValidatorService, DbContext); LobbyModelController = new LobbyModelController(LobbyModelFacadeService, usernameChangingService); WarshipImprovementCostChecker = new WarshipImprovementCostChecker(); WarshipImprovementFacadeService = new WarshipImprovementFacadeService(AccountReaderService, DbContext, WarshipImprovementCostChecker); }
public void TestMethod_SignUpWithTelegram_SuccessRegistration() { //Arrange var dbContext = InMemoryDatabaseFactory.Create(); AccountRegistrationService registrationService = new AccountRegistrationService(dbContext); TelegramLoginInfo telegramLoginInfo = new TelegramLoginInfo { TelegramId = Int32.MaxValue / 2 }; string name = "Muhammad"; //Act registrationService.RegisterAccountAsync(name, telegramLoginInfo).Wait(); //Assert var account = dbContext.Accounts .Include(account1 => account1.TelegramLoginInfo) .Include(account1 => account1.OrderStatusGroups) .First(); Assert.AreEqual(name, account.Name); Assert.AreEqual(telegramLoginInfo.TelegramId, account.TelegramLoginInfo.TelegramId); Assert.IsTrue(account.OrderStatusGroups.Count > 0); }
public SignInController(ApplicationContext context, AccountRegistrationService registrationService) { this.context = context; this.registrationService = registrationService; }