public async Task GetUserProfileAsync_UserProfileGot_SuccessfulRecieved(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); PublicUserProfileModel model = new PublicUserProfileModel(); model.UserId = userId; try { await publicUserProfileService.CeatePublicUserProfileAsync(model); Assert.IsTrue(true); } catch { Assert.IsTrue(false); } }
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 async Task UpdateProfileHeightAsync_UpdateValue_ValueUpdated(int userId, string testValue) { Mock <IPublicUserProfileRepo> publicUserProfileRepo = new Mock <IPublicUserProfileRepo>(); Mock <IValidationService> validationService = new Mock <IValidationService>(); IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo.Object, validationService.Object); PublicUserProfileModel model = new PublicUserProfileModel(); model.UserId = userId; try { await publicUserProfileService.CeatePublicUserProfileAsync(model); model.Height = testValue; await publicUserProfileService.UpdateProfileHeightAsync(model); Assert.IsTrue(true); } catch { Assert.IsTrue(false); } }
public async Task UpdateProfileAgeAsync_UpdateValue_ValueUpdated(int userId, int age) { 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(); model.UserId = userId; try { await publicUserProfileService.CeatePublicUserProfileAsync(model); model.Age = age; await publicUserProfileService.UpdateProfileAgeAsync(model); Assert.IsTrue(true); } catch { Assert.IsTrue(false); } }
public async Task UpdateProfileDescriptionAsync_UpdateValue_ValueUpdated(int userId, string description) { 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(); model.UserId = userId; try { await publicUserProfileService.CeatePublicUserProfileAsync(model); model.Description = description; await publicUserProfileService.UpdateProfileDescriptionAsync(model); 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.Description == description) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } } catch { Assert.IsTrue(false); } }
public async Task SetUserOfflineAsync_SetOffline_UserSetOffline(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); PublicUserProfileModel model = new PublicUserProfileModel(); model.UserId = userId; try { await publicUserProfileService.CeatePublicUserProfileAsync(model); await publicUserProfileService.SetUserOnlineAsync(userId); await publicUserProfileService.SetUserOfflineAsync(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 == "Offline") { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } } catch { Assert.IsTrue(false); } }
public async Task createPublicUserProfileAsync_UserProfileCreated_SuccessfulCreation(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); PublicUserProfileModel model = new PublicUserProfileModel(); model.UserId = userId; try { await publicUserProfileService.CeatePublicUserProfileAsync(model); PublicUserProfileModel profile = await publicUserProfileRepo.GetPublicProfilebyUserId(userId); if (profile == null) { Assert.IsTrue(false); } if (profile.UserId == userId) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } catch { Assert.IsTrue(false); } }