public async Task GetAllUsersRegisteredToday_Countaccounts() { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IFriendListRepo friendListRepo = new FriendListRepo(dataGateway, connectionString); IFriendRequestListRepo friendRequestListRepo = new FriendRequestListRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IFriendBlockListRepo friendBlockListRepo = new FriendBlockListRepo(dataGateway, connectionString); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); IListingRepository listingRepository = new ListingRepository(dataGateway, connectionString); ILoginTrackerRepo loginTrackerRepo = new LoginTrackerRepo(dataGateway, connectionString); IPageVisitTrackerRepo pageVisitTrackerRepo = new PageVisitTrackerRepo(dataGateway, connectionString); ISearchTrackerRepo searchTrackerRepo = new SearchTrackerRepo(dataGateway, connectionString); IUserAnalysisService userAnalysisService = new UserAnalysisService(friendListRepo, listingRepository, userAccountRepository, loginTrackerRepo, pageVisitTrackerRepo, friendRequestListRepo, searchTrackerRepo); int count = await userAnalysisService.GetAllUsersRegisteredToday(); if (count != 20) { Assert.IsTrue(false); } Assert.IsTrue(true); }
public async Task deleteMessage_MessageSentThenDeleted_MessageDeleted(int channelId, int userId, string message) { MessageModel model = new MessageModel(); model.ChannelId = channelId; model.UserId = userId; model.Message = message; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IMessagesRepo messagesRepo = new MessagesRepo(dataGateway, connectionString); IChannelsRepo channelsRepo = new ChannelsRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserChannelsRepo userChannelsRepo = new UserChannelsRepo(dataGateway, connectionString); IMessagingService messagingService = new MessagingService(messagesRepo, channelsRepo, userChannelsRepo, userAccountRepository); await messagingService.SendMessageAsync(model); await messagingService.DeleteMessageAsync(0); IEnumerable <MessageModel> models = await messagesRepo.GetAllMessagesByChannelIdAsync(channelId); if (models.Count() == 1) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public async Task GetUserProfileByAccountId_CorrectAccountId_ReturnsWebUserProfileModel(int profileId, string firstName, string surname, string dateOfBirth, int accountId) { // Arrange // Setting up each dependency of UserProfileService IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); var expectedResult = new WebUserProfileModel(); expectedResult.Id = profileId; expectedResult.FirstName = firstName; expectedResult.Surname = surname; expectedResult.DateOfBirth = DateTimeOffset.Parse(dateOfBirth); expectedResult.UserAccountId = accountId; // Finally, instantiate the actual class being tested and pass in the dependencies IUserProfileService userProfileService = new UserProfileService(userProfileRepository); // Arrange var actualResult = await userProfileService.GetUserProfileByAccountId(accountId); // Act Assert.IsTrue ( actualResult.Id == expectedResult.Id && actualResult.UserAccountId == expectedResult.UserAccountId ); }
public async Task TrackFriendNumber_FriendRequest_GivenDay() { //arrange IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IFriendListRepo friendListRepo = new FriendListRepo(dataGateway, connectionString); IFriendRequestListRepo friendRequestListRepo = new FriendRequestListRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IFriendBlockListRepo friendBlockListRepo = new FriendBlockListRepo(dataGateway, connectionString); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); IListingRepository listingRepository = new ListingRepository(dataGateway, connectionString); ILoginTrackerRepo loginTrackerRepo = new LoginTrackerRepo(dataGateway, connectionString); IPageVisitTrackerRepo pageVisitTrackerRepo = new PageVisitTrackerRepo(dataGateway, connectionString); ISearchTrackerRepo searchTrackerRepo = new SearchTrackerRepo(dataGateway, connectionString); IUserAnalysisService userAnalysisService = new UserAnalysisService(friendListRepo, listingRepository, userAccountRepository, loginTrackerRepo, pageVisitTrackerRepo, friendRequestListRepo, searchTrackerRepo); IUserReportsRepo userReportsRepo = new UserReportsRepo(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IUserInteractionService userInteractionService = new UserInteractionService(friendBlockListRepo, friendListRepo, friendRequestListRepo, userReportsRepo, validationService); await userInteractionService.CreateFriendRequestAsync(1, 2); int avarageFriends = await userAnalysisService.FriendRequest_GivenDay(DateTimeOffset.UtcNow); if (avarageFriends != 1) { Assert.IsTrue(false); } Assert.IsTrue(true); }
public async Task Init() { await TestCleaner.CleanDatabase(); var numTestRows = 20; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IResourceRepository resourceRepository = new ResourceRepository(dataGateway, connectionString); IAccessPolicyRepository accessPolicyRepository = new AccessPolicyRepository(dataGateway, connectionString); for (int i = 1; i <= numTestRows; ++i) { ResourceModel resourceModel = new ResourceModel(); resourceModel.Id = i; resourceModel.Name = "TestResource" + i; AccessPolicyModel accessPolicyModel = new AccessPolicyModel(); accessPolicyModel.Id = i; accessPolicyModel.Name = "TestAccessPolicy" + i; accessPolicyModel.ResourceId = i; accessPolicyModel.Priority = i % 4; await resourceRepository.CreateResource(resourceModel); await accessPolicyRepository.CreateAccessPolicy(accessPolicyModel); } }
public async Task GetChannelOwner_ChannelOwner_RetrievedChannelOwner(int ChannelId, int UserId, int OwnerId, string ChannelName, int NewUserId) { ChannelModel model = new ChannelModel(); model.OwnerId = OwnerId; model.Name = ChannelName; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IMessagesRepo messagesRepo = new MessagesRepo(dataGateway, connectionString); IChannelsRepo channelsRepo = new ChannelsRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserChannelsRepo userChannelsRepo = new UserChannelsRepo(dataGateway, connectionString); IMessagingService messagingService = new MessagingService(messagesRepo, channelsRepo, userChannelsRepo, userAccountRepository); await messagingService.CreateChannelAsync(model); try { int ownerId = await messagingService.GetChannelOwnerAsync(ChannelId); if (ownerId == 1) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } catch { Assert.IsTrue(false); } }
public void AddItemTest() { ConnectionStringData connectionString = new ConnectionStringData(); connectionString.Name = "MyName"; connectionStrings[connectionString.Name] = connectionString; }
public async Task Init() { await TestCleaner.CleanDatabase(); var numTestRows = 20; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); for (int i = 1; i <= numTestRows; ++i) { UserAccountModel userAccountModel = new UserAccountModel(); userAccountModel.Id = i; userAccountModel.Username = "******" + i; userAccountModel.Password = "******" + i; userAccountModel.Salt = "TestSalt" + i; userAccountModel.EmailAddress = "TestEmailAddress" + i; userAccountModel.AccountType = "TestAccountType" + i; userAccountModel.AccountStatus = "TestAccountStatus" + i; userAccountModel.CreationDate = DateTimeOffset.UtcNow; userAccountModel.UpdationDate = DateTimeOffset.UtcNow; await userAccountRepository.CreateAccount(userAccountModel); } }
public async Task ChangeEmail_UserEmailChanges_EmailChangeCompletes(int userId, string password, string email) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); ICryptographyService cryptographyService = new CryptographyService(userAccountRepository); IAuthenticationService authenticationService = new AuthenticationService(userAccountRepository); IAccountSettingsService userAccountSettingsManager = new AccountSettingsService(userAccountRepository, userAccountSettingsRepository, cryptographyService, authenticationService); bool result = await userAccountSettingsManager.ChangeEmailAsync(password, email, userId); if (!result) { Assert.IsTrue(false); } UserAccountModel model = await userAccountRepository.GetAccountById(userId); if (model.EmailAddress == email) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public async Task CleanUp() { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); var settings = await userAccountSettingsRepository.GetAllSettings(); foreach (var setting in settings) { await userAccountSettingsRepository.DeleteUserAccountSettingsByUserId(setting.UserId); } await DataAccessTestHelper.ReseedAsync("UserAccountSettings", 0, connectionString, dataGateway); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); var accounts = await userAccountRepository.GetAllAccounts(); foreach (var account in accounts) { await userAccountRepository.DeleteAccountById(account.Id); } await DataAccessTestHelper.ReseedAsync("UserAccount", 0, connectionString, dataGateway); }
public async Task AddCode_AccountIdDoesntExists_ReturnTrue(string code, string expirationTime, int accountId, string username, string password, string salt, string emailAddress, string accountType, string accountStatus, string creationDate, string updationDate) { // Arrange IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserAccountCodeRepository userAccountCodeRepository = new UserAccountCodeRepository(dataGateway, connectionString); var userAccountModel = new UserAccountModel(); userAccountModel.Id = accountId; userAccountModel.Username = username; userAccountModel.Password = password; userAccountModel.Salt = salt; userAccountModel.EmailAddress = emailAddress; userAccountModel.AccountType = accountType; userAccountModel.AccountStatus = accountStatus; userAccountModel.CreationDate = DateTimeOffset.Parse(creationDate); userAccountModel.UpdationDate = DateTimeOffset.Parse(updationDate); await userAccountRepository.CreateAccount(userAccountModel); var expectedResult = true; IUserAccountCodeService userAccountCodeService = new UserAccountCodeService(userAccountCodeRepository); // Act var actualResult = await userAccountCodeService.AddCode(code, DateTimeOffset.Parse(expirationTime), accountId); // Assert Assert.IsTrue(actualResult == expectedResult); }
public async Task GetUserAccountByUsername_CorrectUsername_ReturnsWebUserAccountModel(int accountId, string username, string emailAddress, string accountType, string accountStatus, string creationDate, string updationDate) { // Arrange // Setting up each dependency of UserAccountService and dependencies of dependencies IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); var expectedResult = new WebUserAccountModel(); expectedResult.Id = accountId; expectedResult.Username = username; expectedResult.EmailAddress = emailAddress; expectedResult.AccountType = accountType; expectedResult.AccountStatus = accountStatus; expectedResult.CreationDate = DateTimeOffset.Parse(creationDate); expectedResult.UpdationDate = DateTimeOffset.Parse(updationDate); // Finally, instantiate the actual class being tested and pass in the dependencies IUserAccountService userAccountService = new UserAccountService(userAccountRepository); // Arrange var actualResult = await userAccountService.GetUserAccountByUsername(username); // Act Assert.IsTrue( actualResult.Id == expectedResult.Id && actualResult.Username == expectedResult.Username ); }
public async Task ChangePasswordTest_UserPasswordChanges_PasswordChangeCompletes(int userId, string password, string newPassword) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); ICryptographyService cryptographyService = new CryptographyService(userAccountRepository); IAuthenticationService authenticationService = new AuthenticationService(userAccountRepository); IAccountSettingsService userAccountSettingsManager = new AccountSettingsService(userAccountRepository, userAccountSettingsRepository, cryptographyService, authenticationService); bool result = await userAccountSettingsManager.ChangePasswordAsync(password, newPassword, userId); if (!result) { Assert.IsTrue(false); } UserAccountModel model = await userAccountRepository.GetAccountById(userId); UserAccountRepository userAccountRepo = new UserAccountRepository(new SQLServerGateway(), new ConnectionStringData()); string encryptedNewPassword = await cryptographyService.EncryptPasswordAsync(newPassword, userId); if (model.Password == encryptedNewPassword) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public async Task ChangeFontStyleAsync_UserFontStyleChange_UsersFontStyleChanges(int userId, string fontStyle) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); ICryptographyService cryptographyService = new CryptographyService(userAccountRepository); IAuthenticationService authenticationService = new AuthenticationService(userAccountRepository); IAccountSettingsService userAccountSettingsManager = new AccountSettingsService(userAccountRepository, userAccountSettingsRepository, cryptographyService, authenticationService); bool result = await userAccountSettingsManager.ChangeFontStyleAsync(userId, fontStyle); if (!result) { Assert.IsTrue(false); } string newFontStyle = await userAccountSettingsRepository.GetFontStyleByID(userId); if (fontStyle == newFontStyle) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public async Task DeleteAccountByUserIDAsync_UserAccountIsDelted_UserAccountSuccessfulyDeletes(int userId, string password) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); ICryptographyService cryptographyService = new CryptographyService(userAccountRepository); IAuthenticationService authenticationService = new AuthenticationService(userAccountRepository); IAccountSettingsService userAccountSettingsManager = new AccountSettingsService(userAccountRepository, userAccountSettingsRepository, cryptographyService, authenticationService); bool result = await userAccountSettingsManager.DeleteAccountByUserIDAsync(userId, password); if (!result) { Assert.IsTrue(false); } UserAccountModel model = await userAccountRepository.GetAccountById(userId); if (model.AccountStatus == "Deleted") { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public async Task ChangeFontSize_UsersFontSizeIsChanged_FontSizeSuccessfullyChanges(int userId, int FontSize) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); ICryptographyService cryptographyService = new CryptographyService(userAccountRepository); IAuthenticationService authenticationService = new AuthenticationService(userAccountRepository); IAccountSettingsService userAccountSettingsManager = new AccountSettingsService(userAccountRepository, userAccountSettingsRepository, cryptographyService, authenticationService); bool result = await userAccountSettingsManager.ChangeFontSizeAsync(userId, FontSize); if (!result) { Assert.IsTrue(false); } await userAccountSettingsManager.ChangeFontSizeAsync(userId, FontSize); string newFontSize = await userAccountSettingsRepository.GetFontSizeByID(userId); if (FontSize.ToString() == newFontSize) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public async Task ChangeThemeColor_UsersThemeColorChanges_UsersThemeColorIsChangedSuccessfully(int userId, string ThemeColor) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); ICryptographyService cryptographyService = new CryptographyService(userAccountRepository); IAuthenticationService authenticationService = new AuthenticationService(userAccountRepository); IAccountSettingsService userAccountSettingsManager = new AccountSettingsService(userAccountRepository, userAccountSettingsRepository, cryptographyService, authenticationService); bool result = await userAccountSettingsManager.ChangeThemeColorAsync(userId, ThemeColor); if (!result) { Assert.IsTrue(false); } await userAccountSettingsManager.ChangeThemeColorAsync(userId, ThemeColor); string newThemeColor = await userAccountSettingsRepository.GetThemeColorByID(userId); if (ThemeColor == newThemeColor) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public async Task GetUserAccountCodeByAccountId_AccountIdExists_ReturnBusinessUserAccountCodeModel(int id, string code, string expirationTime, int accountId) { // Arrange IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountCodeRepository userAccountCodeRepository = new UserAccountCodeRepository(dataGateway, connectionString); var expectedResult = new BusinessUserAccountCodeModel(); expectedResult.Id = id; expectedResult.Code = code; expectedResult.ExpirationTime = DateTimeOffset.Parse(expirationTime); expectedResult.UserAccountId = accountId; IUserAccountCodeService userAccountCodeService = new UserAccountCodeService(userAccountCodeRepository); // Act var actualResult = await userAccountCodeService.GetUserAccountCodeByAccountId(accountId); // Assert Assert.IsTrue ( actualResult.Id == expectedResult.Id && actualResult.Code == expectedResult.Code && actualResult.ExpirationTime == expectedResult.ExpirationTime && actualResult.UserAccountId == expectedResult.UserAccountId ); }
public async Task CleanUp() { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); await TestCleaner.CleanDatabase(); }
public async Task ChangeProfilePictureAsync_EditPhoto_PhotoSuccessfullyEdited(int userId, string photo) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo, validationService); PublicUserProfileModel model = new PublicUserProfileModel(); try { model.UserId = userId; await publicUserProfileService.CeatePublicUserProfileAsync(model); model.Photo = photo; await publicUserProfileService.ChangeProfilePictureAsync(model); Assert.IsTrue(true); } catch { Assert.IsTrue(false); } }
public void AddAsObjectTest() { ConnectionStringData connectionString = new ConnectionStringData(); connectionString.Name = "MyName"; connectionStrings.Add((Object)connectionString); }
public async Task GetUserProfile_GetsProfile_ProfileGetSuccess(int userId, string description, string job, string goals, int age, string gender, string ethnicity, string sexualOrientation, string height, string visibility, string status, string photo, string intrests, string hobbies) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo, validationService); PublicUserProfileManager publicUserProfileManager = new PublicUserProfileManager(publicUserProfileService); PublicUserProfileModel model = new PublicUserProfileModel(); model.UserId = userId; try { await publicUserProfileManager.CeatePublicUserProfileAsync(model); model.Description = description; model.Jobs = job; model.Goals = goals; model.Age = age; model.Gender = gender; model.Ethnicity = ethnicity; model.SexualOrientation = sexualOrientation; model.Height = height; model.Status = status; model.Photo = photo; model.Intrests = intrests; model.Hobbies = hobbies; await publicUserProfileManager.EditPublicUserProfileAsync(model); PublicUserProfileModel profile = await publicUserProfileManager.GetUserProfileAsync(userId); if (profile == null) { Assert.IsTrue(false); } if (profile.Description == description && profile.Hobbies == hobbies && profile.Jobs == job && profile.Goals == goals && profile.Age == age && profile.Gender == gender && profile.Ethnicity == ethnicity && profile.SexualOrientation == sexualOrientation && profile.Height == height && profile.Visibility == visibility && profile.Intrests == intrests) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } catch { Assert.IsTrue(false); } }
/// <summary> /// <para> /// Initialize a new instance of the <see cref="ConnectionStringNode"/> class with a <see cref="ConnectionStringData"/>. /// </para> /// </summary> /// <param name="connectionStringData"> /// <para>The <see cref="ConnectionStringData"/> that this node represents.</para> /// </param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="connectionStringData"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para> /// </exception> public ConnectionStringNode(ConnectionStringData connectionStringData) : base() { if (connectionStringData == null) { throw new ArgumentNullException("connectionString"); } this.connectionStringData = connectionStringData; }
public void AddRemoveTest() { ConnectionStringData connectionString = new ConnectionStringData(); connectionString.Name = "MyName"; connectionStrings.Add(connectionString); Assert.AreEqual(1, connectionStrings.Count); connectionStrings.Remove(connectionString.Name); }
public void ItemTest() { ConnectionStringData connectionString = new ConnectionStringData(); connectionString.Name = "MyName"; connectionStrings.Add(connectionString); Assert.AreEqual(1, connectionStrings.Count); }
private static DatabaseSettings GenerateDataSettings() { DatabaseSettings settings = new DatabaseSettings(); settings.DefaultInstance = "Service_Dflt"; settings.DatabaseTypes.Add(new DatabaseTypeData("SqlServer", typeof(SqlDatabase).AssemblyQualifiedName)); settings.DatabaseTypes.Add(new DatabaseTypeData("Oracle", typeof(OracleDatabase).AssemblyQualifiedName)); ConnectionStringData data = new ConnectionStringData("OracleTest"); data.Parameters.Add(new ParameterData("server", "entlib")); data.Parameters.Add(new ParameterData("user id", "testuser")); data.Parameters.Add(new ParameterData("password", "testuser")); settings.ConnectionStrings.Add(data); data = new ConnectionStringData("NewDatabase"); data.Parameters.Add(new ParameterData("server", "localhost")); data.Parameters.Add(new ParameterData("database", "Northwind")); data.Parameters.Add(new ParameterData("Integrated Security", "true")); settings.ConnectionStrings.Add(data); data = new ConnectionStringData("DbWithSqlServerAuthn"); data.Parameters.Add(new ParameterData("server", "localhost")); data.Parameters.Add(new ParameterData("database", "Northwind")); data.Parameters.Add(new ParameterData("uid", "sa")); data.Parameters.Add(new ParameterData("pwd", "mypassword")); settings.ConnectionStrings.Add(data); data = new ConnectionStringData("Northwind"); data.Parameters.Add(new ParameterData("server", "localhost")); data.Parameters.Add(new ParameterData("database", "Northwind")); data.Parameters.Add(new ParameterData("Integrated Security", "true")); settings.ConnectionStrings.Add(data); data = new ConnectionStringData("EntLibQuickStarts"); data.Parameters.Add(new ParameterData("server", "localhost")); data.Parameters.Add(new ParameterData("database", "EntLibQuickStarts")); data.Parameters.Add(new ParameterData("Integrated Security", "true")); settings.ConnectionStrings.Add(data); data = new ConnectionStringData("NorthwindPersistFalse"); data.Parameters.Add(new ParameterData("server", "localhost")); data.Parameters.Add(new ParameterData("database", "Northwind")); data.Parameters.Add(new ParameterData("uid", "entlib")); data.Parameters.Add(new ParameterData("pwd", "sunrain")); data.Parameters.Add(new ParameterData("Persist Security Info", "false")); settings.ConnectionStrings.Add(data); settings.Instances.Add(new InstanceData("NewDatabase", "SqlServer", "NewDatabase")); settings.Instances.Add(new InstanceData("Service_Dflt", "SqlServer", "Northwind")); settings.Instances.Add(new InstanceData("EntLibQS", "SqlServer", "EntLibQuickStarts")); settings.Instances.Add(new InstanceData("DbWithSqlServerAuthn", "SqlServer", "DbWithSqlServerAuthn")); settings.Instances.Add(new InstanceData("NorthwindPersistFalse", "SqlServer", "NorthwindPersistFalse")); settings.Instances.Add(new InstanceData("OracleTest", "Oracle", "OracleTest")); return(settings); }
public async Task setUserOnline_SetOnline_UserSetOnline(int userId) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo, validationService); PublicUserProfileManager publicUserProfileManager = new PublicUserProfileManager(publicUserProfileService); PublicUserProfileModel model = new PublicUserProfileModel(); model.UserId = userId; try { await publicUserProfileManager.CeatePublicUserProfileAsync(model); await publicUserProfileManager.SetUserOnlineAsync(userId); IEnumerable <PublicUserProfileModel> models = await publicUserProfileRepo.GetAllPublicProfiles(); if (models == null) { Assert.IsTrue(false); } if (models.Count() == 0) { Assert.IsTrue(false); } foreach (var profile in models) { if (profile.Status == "Online") { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } } catch { Assert.IsTrue(false); } }
public void ClearTest() { ConnectionStringData connectionString = new ConnectionStringData(); connectionString.Name = "MyName"; connectionStrings.Add(connectionString); Assert.AreEqual(1, connectionStrings.Count); connectionStrings.Clear(); Assert.AreEqual(0, connectionStrings.Count); }
/// <devdoc> /// Creates a connection string by reading a connectionString node from configuration. /// </devdoc> public static string Build(ConnectionStringData connectionString) { StringBuilder connection = new StringBuilder(); foreach (ParameterData setting in connectionString.Parameters) { connection.AppendFormat("{0}={1};", setting.Name, setting.Value); } return(connection.ToString()); }
public async Task <string> GetFontSizeAsync([FromBody] string id) { Console.WriteLine("Fethcing Font Size" + id); IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); return(await userAccountSettingsRepository.GetFontSizeByID(Int32.Parse(id))); }
public async Task Init() { await TestCleaner.CleanDatabase(); var numTestRows = 20; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IScopeRepository scopeRepository = new ScopeRepository(dataGateway, connectionString); IResourceRepository resourceRepository = new ResourceRepository(dataGateway, connectionString); IClaimRepository claimRepository = new ClaimRepository(dataGateway, connectionString); IAccessPolicyRepository accessPolicyRepository = new AccessPolicyRepository(dataGateway, connectionString); IAccessPolicyPairingRepository accessPolicyPairingRepository = new AccessPolicyPairingRepository(dataGateway, connectionString); for (int i = 1; i <= numTestRows; ++i) { ResourceModel resourceModel = new ResourceModel(); resourceModel.Id = i; resourceModel.Name = "TestResource" + i; ScopeModel scopeModel = new ScopeModel(); scopeModel.Id = i; scopeModel.Type = "TestScope" + i; scopeModel.Description = "TestDescription" + i; ClaimModel claimModel = new ClaimModel(); claimModel.Id = i; claimModel.Type = "TestClaim" + i; claimModel.Value = "TestDescription" + i; claimModel.IsDefault = true; var resourceId = await resourceRepository.CreateResource(resourceModel); var claimId = await claimRepository.CreateClaim(claimModel); var scopeId = await scopeRepository.CreateScope(scopeModel); AccessPolicyModel accessPolicyModel = new AccessPolicyModel(); accessPolicyModel.Id = i; accessPolicyModel.Name = "TestAccessPolicy" + i; accessPolicyModel.ResourceId = resourceId; accessPolicyModel.Priority = i % 4; var accessPolicyId = await accessPolicyRepository.CreateAccessPolicy(accessPolicyModel); AccessPolicyPairingModel accessPolicyPairingModel = new AccessPolicyPairingModel(); accessPolicyPairingModel.Id = i; accessPolicyPairingModel.ScopeId = scopeId; accessPolicyPairingModel.ClaimId = claimId; accessPolicyPairingModel.AccessPolicyId = accessPolicyId; await accessPolicyPairingRepository.CreateAccessPolicyPairing(accessPolicyPairingModel); } }
public async Task CreateDefaultUserAccountSettings_DefaultUserIsCreated_DefaultUserIsSuccessfulyCreated(int UserId, int FontSize, string ThemeColor, string FontStyle) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); int i = 2; UserAccountModel userAccountModel = new UserAccountModel(); userAccountModel.Id = i; userAccountModel.Username = "******" + i; userAccountModel.Password = "" + i; userAccountModel.Salt = "" + i; userAccountModel.EmailAddress = "TestEmailAddress" + i; userAccountModel.AccountType = "TestAccountType" + i; userAccountModel.AccountStatus = "TestAccountStatus" + i; userAccountModel.CreationDate = DateTimeOffset.UtcNow; userAccountModel.UpdationDate = DateTimeOffset.UtcNow; await userAccountRepository.CreateAccount(userAccountModel); UserAccountSettingsModel userAccountSettingsModel = new UserAccountSettingsModel(); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); ICryptographyService cryptographyService = new CryptographyService(userAccountRepository); IAuthenticationService authenticationService = new AuthenticationService(userAccountRepository); IAccountSettingsService userAccountSettingsManager = new AccountSettingsService(userAccountRepository, userAccountSettingsRepository, cryptographyService, authenticationService); UserAccountSettingsModel model = new UserAccountSettingsModel(); userAccountSettingsModel.Id = 0; userAccountSettingsModel.UserId = UserId; userAccountSettingsModel.FontSize = FontSize; userAccountSettingsModel.FontStyle = FontStyle; userAccountSettingsModel.ThemeColor = ThemeColor; bool result = await userAccountSettingsManager.CreateDefaultUserAccountSettingsAsync(userAccountSettingsModel); if (!result) { Assert.IsTrue(false); } await userAccountSettingsManager.CreateDefaultUserAccountSettingsAsync(userAccountSettingsModel); model = await userAccountSettingsRepository.GetUserAccountSettingsByUserId(UserId); if (model.UserId == UserId && model.FontSize == 12 && model.FontStyle == "Defualt Font Style" && model.ThemeColor == "Default Theme Color") { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public override void SetUp() { base.SetUp(); DatabaseSettings databaseSettings = DatabaseSettingsBuilder.Create(Host); connectionStringData = databaseSettings.ConnectionStrings["Northwind"]; Assert.IsNotNull(connectionStringData); DatabaseSettingsNode databaseSettingsNode = new DatabaseSettingsNode(databaseSettings); IUIHierarchy hierarchy = CreateHierarchyAndAddToHierarchyService(databaseSettingsNode, CreateDefaultConfiguration()); ConfigurationNode[] nodes = hierarchy.FindNodesByType(typeof(ConnectionStringNode)); foreach (ConnectionStringNode node in nodes) { if (node.Name == "Northwind") { connectionStringNode = node; break; } } }
public void EnumeratorCurrentTest() { ConnectionStringData connectionString = new ConnectionStringData(); connectionString.Name = "MyName"; connectionStrings.Add(connectionString); ConnectionStringData connectionString2 = new ConnectionStringData(); connectionString2.Name = "MyName2"; connectionStrings.Add(connectionString2); int count = 0; foreach (ConnectionStringData cs in connectionStrings) { Assert.IsNotNull(cs); count++; foreach (ConnectionStringData cs2 in connectionStrings) { Assert.IsNotNull(cs2); count++; } } Assert.AreEqual(6, count); }
public void EnumeratorTest() { ConnectionStringData connectionString = new ConnectionStringData(); connectionString.Name = "MyName"; connectionStrings.Add(connectionString); IEnumerator enumerator = connectionStrings.GetEnumerator(); enumerator.Reset(); while (enumerator.MoveNext()) { Assert.IsNotNull(enumerator.Current); } }
public void Initialize() { XmlTextReader xmlReader = new XmlTextReader(new StringReader(xmlString)); XmlSerializer xmlSerializer = new XmlSerializer(typeof(ConnectionStringData)); connectionString = xmlSerializer.Deserialize(xmlReader) as ConnectionStringData; }