public IActionResult OnGet() { var repo = new ProfilesRepository(_context); ProfileDisplayList = repo.GetProfiles(); return(Page()); }
public void ShouldDeleteMessage() { var profile = new Profile { Id = Guid.NewGuid(), Login = "******", Avatar = Guid.NewGuid(), Password = "******", Name = "odmin", Surname = "odmin" }; const string chatName = "SendChat"; var usersRepository = new ProfilesRepository(Constants.Constants.ConnectionString); var result = usersRepository.CreateProfile(profile); _tempUsers.Add(result.Id); var chatRepository = new ChatsRepository(Constants.Constants.ConnectionString, usersRepository); var chatBefore = new Chat { ChatId = Guid.NewGuid(), ChatName = chatName, ChatMembers = new List <Guid>(new[] { profile.Id }) }; var chat = chatRepository.CreateChat(chatBefore); _chats.Add(chat.ChatId); var messageRepository = new MessagesRepository(Constants.Constants.ConnectionString); var message = new Message { MessageId = Guid.NewGuid(), ProfileId = profile.Id, ChatId = chat.ChatId, MessageText = "Hello, world!", Date = DateTime.Now, TimeToDestroy = 0, Attachment = Guid.Empty }; _messages.Add(message.MessageId); messageRepository.CreateMessage(message); messageRepository.DeleteMessage(message.MessageId); try { messageRepository.GetMessage(message.MessageId); } catch (Exception) { return; } }
public void ShouldDeleteProfile() { var profile = new Profile { Id = Guid.NewGuid(), Login = "******", Avatar = Guid.NewGuid(), Password = "******", Name = "odmin", Surname = "odmin" }; var repository = new ProfilesRepository(Constants.Constants.ConnectionString); repository.CreateProfile(profile); repository.DeleteProfile(profile.Id); try { repository.GetProfile(profile.Id); } catch (Exception) { } }
public void ShouldGetChat() { var profile = new Profile { Id = Guid.NewGuid(), Login = "******", Avatar = Guid.NewGuid(), Password = "******", Name = "odmin", Surname = "odmin" }; const string chatName = "GetChat"; var usersRepository = new ProfilesRepository(Constants.Constants.ConnectionString); var result = usersRepository.CreateProfile(profile); _tempUsers.Add(result.Id); var chatRepository = new ChatsRepository(Constants.Constants.ConnectionString, usersRepository); var chatBefore = new Chat { ChatId = Guid.NewGuid(), ChatName = chatName, ChatMembers = new List <Guid>(new[] { profile.Id }) }; var chat = chatRepository.CreateChat(chatBefore); _chats.Add(chat.ChatId); var resultChatById = chatRepository.GetChat(chat.ChatId); Assert.AreEqual(chat.ChatName, resultChatById.ChatName); }
public IActionResult OnGet() { var repo = new ProfilesRepository(_context); ProfileViewModel = repo.CreateProfile(); return(Page()); }
// // GET: /Profiles/ public ActionResult Index() { ViewData["AuthUserGuid"] = Request.ServerVariables.Get("AUTH_USER"); List <ProfileModel> list = ProfilesRepository.GetProfileList().AsProfileModelList(); return(View(list)); }
public void ShouldStartChatWithUser() { var profile = new Profile { Id = Guid.NewGuid(), Login = "******", Avatar = Guid.NewGuid(), Password = "******", Name = "odmin", Surname = "odmin" }; const string chatName = "UserChat"; var profileRepository = new ProfilesRepository(Constants.Constants.ConnectionString); var result = profileRepository.CreateProfile(profile); _tempUsers.Add(result.Id); var chatRepository = new ChatsRepository(Constants.Constants.ConnectionString, profileRepository); var chatBefore = new Chat { ChatId = Guid.NewGuid(), ChatName = chatName, ChatMembers = new List <Guid>(new[] { profile.Id }) }; var chat = chatRepository.CreateChat(chatBefore); _chats.Add(chat.ChatId); var userChats = profileRepository.GetProfileChats(profile.Id); Assert.AreEqual(chatName, chat.ChatName); Assert.AreEqual(profile.Id, chat.ChatMembers.Single()); var chats = userChats as IList <Chat> ?? userChats.ToList(); Assert.AreEqual(chat.ChatId, chats.Single().ChatId); Assert.AreEqual(chat.ChatName, chats.Single().ChatName); }
public ActionResult Detail(Guid id) { ViewData["AuthUserGuid"] = Request.ServerVariables.Get("AUTH_USER"); ProfileModel profile = ProfilesRepository.GetProfileById(id).AsProfileModel(); profile.RouteList = RoutesRepository.GetUsersRoutes(id).AsRouteModelList(); return(View(profile)); }
public void Verify_Get_ByKey_Should_ReturnTheCorrectProfile() { // Arrange Mock <IDbSet <Profile> > mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); // Act var profiles = repository.Get("KING-STEPHEN"); // Assert Assert.Equal("/TEST/KING-STEPHEN", profiles.ApiDetailUrl); }
public void Verify_Deactivate_Should_SetTheActivePropertyToFalseOnTheEntity() { // Arrange Mock<IDbSet<Profile>> mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var profiles = repository.Get(1); // Act repository.Deactivate(profiles); // Assert Assert.Equal(false, profiles.Active); }
public void Verify_Add_Should_AddTheEntityToTheContext() { // Arrange Mock<IDbSet<Profile>> mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(false, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var profiles = new Profile { Active = true, CustomKey = "SALVATORE-RAA", }; // Act repository.Add(profiles); // Assert mockSetProfiles.Verify(x => x.Add(profiles), Times.Once); }
public DimensionsService() { this.productsRepository = new ProductsRepository(); this.usersRepository = new UsersRepository(); this.profilesDimensionsRepository = new ProfilesDimensionsRepository(); this.dimensionsRepository = new DimensionsRepository(); this.profilesRepository = new ProfilesRepository(); this.usersDimensionsRepository = new UsersDimensionsRepository(); this.subscriptionsRepository = new SubscriptionsRepository(); this.utilities = new Utilities(); }
public void Clean() { foreach (var login in _tempUsers) { var user = new ProfilesRepository(Constants.Constants.ConnectionString); foreach (var chat in _chats) { new ChatsRepository(Constants.Constants.ConnectionString, user).DeleteChat(chat); } user.DeleteProfile(login); } }
public void Verify_Deactivate_Should_SetTheActivePropertyToFalseOnTheEntity() { // Arrange Mock <IDbSet <Profile> > mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var profiles = repository.Get(1); // Act repository.Deactivate(profiles); // Assert Assert.Equal(false, profiles.Active); }
public void Verify_Remove_Should_RemoveTheEntityFromTheContext() { // Arrange Mock <IDbSet <Profile> > mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var profiles = repository.Get(1); // Act repository.Remove(profiles); // Assert mockSetProfiles.Verify(x => x.Remove((Profile)profiles), Times.Once); }
public void Verify_Update_Should_SetTheEntityStateToModified() { // Arrange Mock <IDbSet <Profile> > mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var profiles = repository.Get(1); profiles.ApiDetailUrl = "/TEST"; // Act repository.Update(profiles); // Assert mockContext.Verify(x => x.SetModified(It.IsAny <object>()), Times.Once); }
public async Task ShouldReturnEmptyProfileList() { var repo = new ProfilesRepository(_localStorageServiceMock.Object, _migratorMock.Object); _migratorMock .Setup(x => x.StartMigration(null)) .ReturnsAsync(new ProfileStorageContainer()) .Verifiable(); var profiles = await repo.GetProfiles(); profiles.Should().BeEmpty(); _migratorMock.Verify(); }
public void Verify_Add_Should_AddTheEntityToTheContext() { // Arrange Mock <IDbSet <Profile> > mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(false, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var profiles = new Profile { Active = true, CustomKey = "SALVATORE-RAA", }; // Act repository.Add(profiles); // Assert mockSetProfiles.Verify(x => x.Add(profiles), Times.Once); }
public void Verify_List_Should_ReturnAListOfProfilesWithData() { // Arrange Mock <IDbSet <Profile> > mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); // Act var profiles = repository.List.ToArray(); // Assert Assert.Equal(2, profiles.Length); Assert.Equal(1, profiles[0].Id); Assert.Equal("/TEST/KING-STEPHEN", profiles[0].ApiDetailUrl); Assert.Equal(2, profiles[1].Id); Assert.Equal("/TEST/NIVEN-LARRY", profiles[1].ApiDetailUrl); }
public void Verify_Search_WithSelectStatement_Should_ReturnAListOfDynamicObjects() { // Arrange Mock <IDbSet <Profile> > mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles, true); var repository = new ProfilesRepository(mockContext.Object); var searchModel = new Mock <IProfileSearchModel>(); // Act var profiles = repository.Search(searchModel.Object, i => new { i.Id, MyApiDetailUrl = i.ApiDetailUrl }).ToArray(); // Assert Assert.Equal(1, profiles.Length); Assert.Equal(2, profiles[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", profiles[0].MyApiDetailUrl); // Stephen King was filtered out because he was Inactive }
public async Task ShouldReturnProfiles() { Guid defaultProfileId = Guid.NewGuid(); _localStorageServiceMock .Setup(x => x.GetItemAsync <ProfileStorageContainer>("Profiles")) .ReturnsAsync(new ProfileStorageContainer { Profiles = new List <Profile> { new Profile { Id = defaultProfileId, ProfileName = "default", FaceApiConfig = new Domain.Profiles.CognitiveServiceConfig { BaseUrl = "http", ServiceName = "FaceApi", Token = "t1" } } } }) .Verifiable(); var repo = new ProfilesRepository(_localStorageServiceMock.Object, _migratorMock.Object); var profiles = await repo.GetProfiles(); profiles.Should() .SatisfyRespectively( first => { first.Id.Should().Be(defaultProfileId); first.ProfileName.Should().Be("default"); first.FaceApiConfig.Should().NotBeNull(); first.FaceApiConfig !.BaseUrl.Should().Be("http"); first.FaceApiConfig.ServiceName.Should().Be("FaceApi"); first.FaceApiConfig.Token.Should().Be("t1"); }); _migratorMock.Verify(x => x.StartMigration(It.IsAny <ProfileStorageContainer>()), Times.Never); _localStorageServiceMock.Verify(); }
public void Verify_Search_WithPaging_Should_ReturnAListOfProfilesWithDataMatchingSearchParameters() { // Arrange Mock <IDbSet <Profile> > mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var searchModel = new ProfileSearchModel { Paging = new Paging { Skip = 1, Take = 1 } }; // Act var profiles = repository.Search(searchModel /*.Object*/).ToArray(); // Assert Assert.Equal(1, profiles.Length); Assert.Equal(2, profiles[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", profiles[0].ApiDetailUrl); // Stephen King was filtered out because he was Skipped }
public void ShouldDeleteChat() { var profile = new Profile { Id = Guid.NewGuid(), Login = "******", Avatar = Guid.NewGuid(), Password = "******", Name = "odmin", Surname = "odmin" }; const string chatName = "DeleteChat"; var usersRepository = new ProfilesRepository(Constants.Constants.ConnectionString); var resProfile = usersRepository.CreateProfile(profile); _tempUsers.Add(resProfile.Id); var chatRepository = new ChatsRepository(Constants.Constants.ConnectionString, usersRepository); var chatBefore = new Chat { ChatId = Guid.NewGuid(), ChatName = chatName, ChatMembers = new List <Guid>(new[] { profile.Id }) }; var chat = chatRepository.CreateChat(chatBefore); _chats.Add(chat.ChatId); chatRepository.DeleteChat(chat.ChatId); try { chatRepository.GetChat(chat.ChatId); } catch (Exception) { } }
public void Verify_Search_WithModifiedSince_Should_ReturnAListOfProfilesWithDataMatchingSearchParameters() { // Arrange Mock <IDbSet <Profile> > mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles, true); var repository = new ProfilesRepository(mockContext.Object); var createDate = new System.DateTime(2015, 05, 28, 10, 45, 00).AddDays(1).AddMinutes(-1); //var searchModel = new Mock<IProfileSearchModel>(); //searchModel.Setup(m => m.ModifiedSince).Returns(() => createDate); var searchModel = new ProfileSearchModel { ModifiedSince = createDate }; // Act var profiles = repository.Search(searchModel /*.Object*/).ToArray(); // Assert Assert.Equal(1, profiles.Length); Assert.Equal(2, profiles[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", profiles[0].ApiDetailUrl); // Stephen King was filtered out because he was created before the modified since date }
public void ShouldCreateUser() { var profile = new Profile { Id = Guid.NewGuid(), Login = "******", Avatar = Guid.NewGuid(), Password = "******", Name = "odmin", Surname = "odmin" }; var repository = new ProfilesRepository(Constants.Constants.ConnectionString); var result = repository.CreateProfile(profile); _tempUsers.Add(result.Id); Assert.AreEqual(profile.Login, result.Login); Assert.AreEqual(profile.Avatar, result.Avatar); Assert.AreEqual(profile.Password, result.Password); Assert.AreEqual(profile.Name, result.Name); Assert.AreEqual(profile.Surname, result.Surname); }
public IActionResult OnPost() { try { if (ModelState.IsValid) { var repo = new ProfilesRepository(_context); bool saved = repo.SaveProfile(ProfileViewModel); if (saved) { return(RedirectToPage("Index")); } } // Handling model state errors is beyond the scope of the demo, so just throwing an ApplicationException when the ModelState is invalid // and rethrowing it in the catch block. throw new ApplicationException("Invalid model"); } catch (ApplicationException ex) { Debug.Write(ex.Message); throw; } }
public void Verify_List_Should_ReturnAListOfProfilesWithData() { // Arrange Mock<IDbSet<Profile>> mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); // Act var profiles = repository.List.ToArray(); // Assert Assert.Equal(2, profiles.Length); Assert.Equal(1, profiles[0].Id); Assert.Equal("/TEST/KING-STEPHEN", profiles[0].ApiDetailUrl); Assert.Equal(2, profiles[1].Id); Assert.Equal("/TEST/NIVEN-LARRY", profiles[1].ApiDetailUrl); }
public void Verify_Remove_Should_RemoveTheEntityFromTheContext() { // Arrange Mock<IDbSet<Profile>> mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var profiles = repository.Get(1); // Act repository.Remove(profiles); // Assert mockSetProfiles.Verify(x => x.Remove((Profile)profiles), Times.Once); }
public ProfilesService(ProfilesRepository repo) { _repo = repo; }
public void Verify_Search_WithModifiedSince_Should_ReturnAListOfProfilesWithDataMatchingSearchParameters() { // Arrange Mock<IDbSet<Profile>> mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles, true); var repository = new ProfilesRepository(mockContext.Object); var createDate = new System.DateTime(2015, 05, 28, 10, 45, 00).AddDays(1).AddMinutes(-1); //var searchModel = new Mock<IProfileSearchModel>(); //searchModel.Setup(m => m.ModifiedSince).Returns(() => createDate); var searchModel = new ProfileSearchModel { ModifiedSince = createDate }; // Act var profiles = repository.Search(searchModel/*.Object*/).ToArray(); // Assert Assert.Equal(1, profiles.Length); Assert.Equal(2, profiles[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", profiles[0].ApiDetailUrl); // Stephen King was filtered out because he was created before the modified since date }
public void Verify_Search_WithPaging_Should_ReturnAListOfProfilesWithDataMatchingSearchParameters() { // Arrange Mock<IDbSet<Profile>> mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var searchModel = new ProfileSearchModel { Paging = new Paging { Skip = 1, Take = 1 } }; // Act var profiles = repository.Search(searchModel/*.Object*/).ToArray(); // Assert Assert.Equal(1, profiles.Length); Assert.Equal(2, profiles[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", profiles[0].ApiDetailUrl); // Stephen King was filtered out because he was Skipped }
public ProfilesService(ProfilesRepository profilesRepository) { _profilesRepository = profilesRepository; }
public ProfilesService(ProfilesRepository repo, KeepsRepository kRepo, VaultsRepository vRepo) { _repo = repo; _kRepo = kRepo; _vRepo = vRepo; }
public void Setup() { target = new ProfilesRepository(); }
public void Verify_Search_WithSelectStatement_Should_ReturnAListOfDynamicObjects() { // Arrange Mock<IDbSet<Profile>> mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles, true); var repository = new ProfilesRepository(mockContext.Object); var searchModel = new Mock<IProfileSearchModel>(); // Act var profiles = repository.Search(searchModel.Object, i => new { i.Id, MyApiDetailUrl = i.ApiDetailUrl }).ToArray(); // Assert Assert.Equal(1, profiles.Length); Assert.Equal(2, profiles[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", profiles[0].MyApiDetailUrl); // Stephen King was filtered out because he was Inactive }
public void ShouldAddDeleteMember() { var odminProfile = new Profile { Id = Guid.NewGuid(), Login = "******", Avatar = Guid.NewGuid(), Password = "******", Name = "odmin", Surname = "odmin" }; var userProfile = new Profile { Id = Guid.NewGuid(), Login = "******", Avatar = Guid.NewGuid(), Password = "******", Name = "user", Surname = "user" }; const string chatName = "AddChat"; var profilesRepository = new ProfilesRepository(Constants.Constants.ConnectionString); var resodminProfile = profilesRepository.CreateProfile(odminProfile); var resUserProfile = profilesRepository.CreateProfile(userProfile); _tempUsers.Add(resodminProfile.Id); _tempUsers.Add(resUserProfile.Id); var chatRepository = new ChatsRepository(Constants.Constants.ConnectionString, profilesRepository); var chatBefore = new Chat { ChatId = Guid.NewGuid(), ChatName = chatName, ChatMembers = new List <Guid>(new[] { odminProfile.Id }) }; var chat = chatRepository.CreateChat(chatBefore); _chats.Add(chat.ChatId); chatRepository.AddChatMember(resUserProfile.Id, chat.ChatId); var userChats = profilesRepository.GetProfileChats(resUserProfile.Id).ToList(); Assert.AreEqual(chat.ChatId, userChats[0].ChatId); Assert.AreEqual(chat.ChatName, userChats[0].ChatName); chatRepository.DeleteChatMember(resUserProfile.Id, chat.ChatId); userChats = profilesRepository.GetProfileChats(resUserProfile.Id).ToList(); try { Assert.AreEqual(chat.ChatId, userChats[0].ChatId); Assert.AreEqual(chat.ChatName, userChats[0].ChatName); } catch (ArgumentOutOfRangeException) { } }
public void ShouldGetProfileChats() { var profile = new Profile { Id = Guid.NewGuid(), Login = "******", Avatar = Guid.NewGuid(), Password = "******", Name = "odmin", Surname = "odmin" }; const string chatName1 = "ProfileChat#1"; const string chatName2 = "ProfileChat#2"; const string chatName3 = "ProfileChat#3"; const string chatName4 = "ProfileChat#4"; var profilesRepository = new ProfilesRepository(Constants.Constants.ConnectionString); var resProfile = profilesRepository.CreateProfile(profile); _tempUsers.Add(resProfile.Id); var chatRepository = new ChatsRepository(Constants.Constants.ConnectionString, profilesRepository); var chat1Before = new Chat { ChatId = Guid.NewGuid(), ChatName = chatName1, ChatMembers = new List <Guid>(new[] { profile.Id }) }; var chat2Before = new Chat { ChatId = Guid.NewGuid(), ChatName = chatName2, ChatMembers = new List <Guid>(new[] { profile.Id }) }; var chat3Before = new Chat { ChatId = Guid.NewGuid(), ChatName = chatName3, ChatMembers = new List <Guid>(new[] { profile.Id }) }; var chat4Before = new Chat { ChatId = Guid.NewGuid(), ChatName = chatName4, ChatMembers = new List <Guid>(new[] { profile.Id }) }; var chat1 = chatRepository.CreateChat(chat1Before); var chat2 = chatRepository.CreateChat(chat2Before); var chat3 = chatRepository.CreateChat(chat3Before); var chat4 = chatRepository.CreateChat(chat4Before); _chats.Add(chat1.ChatId); _chats.Add(chat2.ChatId); _chats.Add(chat3.ChatId); _chats.Add(chat4.ChatId); var profileChats = profilesRepository.GetProfileChats(profile.Id).ToList(); var ch = profileChats.Find(x => x.ChatId == chat1.ChatId); Assert.AreEqual(chat1.ChatId, ch.ChatId); Assert.AreEqual(chatName1, ch.ChatName); ch = profileChats.Find(x => x.ChatId == chat2.ChatId); Assert.AreEqual(chat2.ChatId, ch.ChatId); Assert.AreEqual(chatName2, ch.ChatName); ch = profileChats.Find(x => x.ChatId == chat3.ChatId); Assert.AreEqual(chat3.ChatId, ch.ChatId); Assert.AreEqual(chatName3, ch.ChatName); ch = profileChats.Find(x => x.ChatId == chat4.ChatId); Assert.AreEqual(chat4.ChatId, ch.ChatId); Assert.AreEqual(chatName4, ch.ChatName); }
public void Verify_Update_Should_SetTheEntityStateToModified() { // Arrange Mock<IDbSet<Profile>> mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); var profiles = repository.Get(1); profiles.ApiDetailUrl = "/TEST"; // Act repository.Update(profiles); // Assert mockContext.Verify(x => x.SetModified(It.IsAny<object>()), Times.Once); }
public void Verify_Get_ByID_Should_ReturnTheCorrectProfile() { // Arrange Mock<IDbSet<Profile>> mockSetProfiles; var mockContext = ProfilesMockingSetup.DoMockingSetupForContext(true, out mockSetProfiles); var repository = new ProfilesRepository(mockContext.Object); // Act var profiles = repository.Get(1); // Assert Assert.Equal("/TEST/KING-STEPHEN", profiles.ApiDetailUrl); }