public ActionResult GetBookmarks() { IBookmark service = new BookmarkService(); List <Bookmark> result = service.GetBookmarkList().ToList(); return(Json(result, JsonRequestBehavior.AllowGet)); }
//[TestMethod] public void Should_Add_Bookmarks() { //ACT var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["developmentserver"].ConnectionString; SqlConnection conn = new SqlConnection(connectionString); var id = 1; BookmarkService service = new BookmarkService(); //service.AddBookmarks(id, "Google", "https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=y4SBWpiHKqry8AeBvIqoAQ", 5, DateTime.Today); //Arrange SqlCommand insertCommand = new SqlCommand("Select id from Bookmarks where id =" + id + "", conn); conn.Open(); var reader1 = insertCommand.ExecuteReader(); var retrievedId = 0; while (reader1.Read()) { retrievedId = Convert.ToInt32(reader1[0]); } //Assert Assert.AreEqual(id, retrievedId); }
public void CreateOrUpdateBookmark() { BookmarkService.CreateOrUpdateDeviceBookmark(oldTitle, new Bookmark() { Title = _Title, Url = _Url }); }
public CreateBookmarkFolder(BookmarkService bookmarkService, BookmarkManager bookmarkManager, ImageReferenceElement imageReference) { _bookmarkManager = bookmarkManager; _imageReference = imageReference; _bookmarkService = bookmarkService; InitializeComponent(); }
private async void btn_save_Click(object sender, RoutedEventArgs e) { string url = this.tb_url.Text.Trim(); if (string.IsNullOrWhiteSpace(url)) { MessageBox.Show("URL不能为空", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); tb_url.Focus(); tb_url.SelectAll(); return; } try { progressBar.Visibility = Visibility.Visible; btn_save.IsEnabled = false; BookmarkModel model = this.DataContext as BookmarkModel; BookmarkView bookmarkView = await BookmarkService.Update(ObjectMapper.Map <BookmarkModel, Bookmark>(model)); this.DoBookmarkGridViewModel.DoBookmarkViewModel = ObjectMapper.Map <BookmarkView, BookmarkViewModel>(bookmarkView); progressBar.Visibility = Visibility.Hidden; this.DialogResult = true; btn_save.IsEnabled = true; } catch (Exception ex) { progressBar.Visibility = Visibility.Hidden; btn_save.IsEnabled = true; MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK, MessageBoxImage.Error); tb_url.Focus(); tb_url.SelectAll(); } }
protected override async Task DoExecute() { Debug.WriteLine("正在删除数据"); BookmarkViewModel current = this.ViewModel.CurrentSelected; Bookmark bookmark = ObjectMapper.Map <BookmarkViewModel, Bookmark>(current); await BookmarkService.Delete(bookmark); }
//[TestMethod] public void Should_Insert_User_into_DB() { //ACT var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["developmentserver"].ConnectionString; SqlConnection conn = new SqlConnection(connectionString); var id = 5; BookmarkService service = new BookmarkService(); service.AddUser("Brijesh", "*****@*****.**"); //Arrange SqlCommand insertCommand = new SqlCommand("Select id from BookMarkUsers where id =" + id + "", conn); conn.Open(); var reader1 = insertCommand.ExecuteReader(); var retrievedId = 0; while (reader1.Read()) { retrievedId = Convert.ToInt32(reader1[0]); } //Assert Assert.AreEqual(id, retrievedId); }
public FormAddBookmarkWithNewFolder(ImageReferenceElement imageReference, BookmarkService bookmarkService, BookmarkManager bookmarkManager) { _imageReference = imageReference; _bookmarkService = bookmarkService; _bookmarkManager = bookmarkManager; rootBookmarkFolder = _bookmarkManager.RootFolder; InitializeComponent(); }
private void ShowBookmark_Load(object sender, EventArgs e) { BookmarkService service = new BookmarkService(); lblHello.Text += service.GetUser(Id); gridBookmarks.DataSource = service.LoadBookmarks(Id); //gridBookmarks.DataBind(); }
public FormAddBookmark(BookmarkManager bookmarkManager, BookmarkService bookmarkService, ApplicationSettingsService applicationSettingsService) { InitializeComponent(); _bookmarkManager = bookmarkManager; _bookmarkService = bookmarkService; _applicationSettingsService = applicationSettingsService; }
public FormBookmarks(BookmarkService bookmarkService, BookmarkManager bookmarkManager, ApplicationSettingsService applicationSettingsService) { _bookmarkService = bookmarkService; _bookmarkManager = bookmarkManager; _applicationSettingsService = applicationSettingsService; _overlayFormManager = new OverlayFormManager(); InitializeComponent(); }
public void TestGetById() { mockBookmarkRepository.Setup(x => x.GetById(It.IsAny <string>())).Returns(bookmark); var bookmarkService = new BookmarkService(mockBookmarkRepository.Object); Bookmark bookmarkActual = bookmarkService.GetById("5d0a17701a0a4200017de6c7"); Assert.AreEqual(bookmarkActual, bookmark); }
public void TestDeleteBookmark() { mockBookmarkRepository.Setup(x => x.DeleteBookmark(It.IsAny <string>(), It.IsAny <string>())).Returns(true); var bookmarkService = new BookmarkService(mockBookmarkRepository.Object); bool deleteBookmark = bookmarkService.DeleteBookmark("5d0a17701a0a4200017de6c7", "5d0a17701a0a4200017d07c5"); Assert.IsTrue(deleteBookmark); }
public void TestAddBookmark() { mockBookmarkRepository.Setup(x => x.Add(It.IsAny <Bookmark>())).Returns(bookmark); var bookmarkService = new BookmarkService(mockBookmarkRepository.Object); Bookmark bookmarkReturn = bookmarkService.AddBookmark(bookmark); Assert.AreEqual(bookmarkReturn, bookmarkReturn); }
//[TestMethod] public void Should_Login_User() { var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["developmentserver"].ConnectionString; SqlConnection conn = new SqlConnection(connectionString); BookmarkService service = new BookmarkService(); var result = service.CheckLogin("*****@*****.**", "NR7AN0YA"); Assert.IsNotNull(result); }
public void SetBookmark(string name, string avatar) { IBookmark service = new BookmarkService(); Bookmark newBookmark = new Bookmark() { Name = name, Avatar = avatar }; service.SetBookmark(newBookmark); }
public FormSettings(BookmarkService bookmarkService, ApplicationSettingsService applicationSettingsService, ImageCacheService imageCacheService) { applicationSettingsService.LoadSettings(); _originalSettings = applicationSettingsService.Settings; _bookmarkService = bookmarkService; _applicationSettingsService = applicationSettingsService; _imageCacheService = imageCacheService; _selectedCacheSize = _imageCacheService.CacheSize; InitializeComponent(); }
public async Task DeleteAsync_InexistentId_ShouldReturnResultResponseWithError() { var bookmarkService = new BookmarkService(_repositoryMock.Object); var resultBookmarkDeleted = await _bookmarkService.DeleteAsync(_bookmarkTestsFixture.GetInexistentBoomarkId()); resultBookmarkDeleted.Success.Should().BeFalse(); resultBookmarkDeleted.ValidationErrors.FirstOrDefault().Message.Should().Be("The bookmark wasn't found"); _repositoryMock.Verify(rm => rm.DeleteAsync(It.IsAny <Bookmark>()), Times.Never); }
public void TestGetUserBookmarks() { IEnumerable <Bookmark> ienumableGetAllBookmark = bookmarks; mockBookmarkRepository.Setup(x => x.GetAll(It.IsAny <string>())).Returns(ienumableGetAllBookmark); var bookmarkService = new BookmarkService(mockBookmarkRepository.Object); IEnumerable <Bookmark> ienumableReturn = bookmarkService.GetUserBookmarks("5d0a17701a0a4200017de6c7"); Bookmark bookmarkActual = ienumableGetAllBookmark.FirstOrDefault(); Assert.AreEqual(bookmarkActual.Id, "5d1da79eb7ee1f00013b2e70"); }
public void remove_bookmarks_by_id() { var DbService = new BookmarkDbService(mockContext.Object); var mockLogicService = new Mock <BookmarkService>(); var service = new BookmarkService(mapper, DbService); //Act service.RemoveById("123"); //Assert mockSet.Verify(m => m.Remove(It.IsAny <BookmarkDB>()), Times.Once()); }
private void buttonGeneruj_Click(object sender, EventArgs e) { if (_list.Count == 0 || _klient == null) { MessageBox.Show("Musisz najpierw wskazać klienta i dodać przedmioty do listy"); return; } BookmarkService bookmark = new BookmarkService(); var nrFaktury = _dal.FakturaDodaj(_list, _klient.Id); bookmark.GenerateDoc(_klient, _list); }
public async Task get_bookmark_by_userId_async() { var DbService = new BookmarkDbService(mockContext.Object); var mockLogicService = new Mock <BookmarkService>(); var service = new BookmarkService(mapper, DbService); //Act var x = await service.GetByUserIdAsync("1"); //Assert Assert.AreEqual(1, x.Count()); }
public async Task ReadBookmarkTest() { _factory.CreateBookmark().Save(); var service = new BookmarkService(_context); var bookmark = await service.Get(_factory.Bookmark.BookmarkId); Assert.NotNull(bookmark); Assert.AreEqual(_factory.Bookmark.Title, bookmark.Title); Assert.AreEqual(_factory.Bookmark.ImageUrl, bookmark.ImageUrl); Assert.AreEqual(_factory.Bookmark.Url, bookmark.Url); }
public async Task CreateBookmarkTest() { var bookmark = _factory.CreateBookmark().Bookmark; Assert.AreEqual(Guid.Empty, bookmark.BookmarkId); var service = new BookmarkService(_context); var createdBookmark = await service.Create(bookmark); Assert.NotNull(createdBookmark); Assert.AreNotEqual(Guid.Empty, createdBookmark.BookmarkId); }
public async Task get_bookmark_by_id_async() { var DbService = new BookmarkDbService(mockContext.Object); var mockLogicService = new Mock <BookmarkService>(); var service = new BookmarkService(mapper, DbService); //Act var x = await service.GetByIdAsync("123"); //Assert Assert.AreEqual(x.Id, "123"); }
public async Task TestAddBookmark_WithTestData_ShouldReturnBookmark() { var context = PMGDbContextInMemoryFactory.CreateDbContext(); var bookmarkService = new BookmarkService(context); await bookmarkService.AddBookmarkAsync(Bookmark); var expectedData = Bookmark.Id; var actualData = context.Bookmarks.SingleOrDefault(x => x.Id == Bookmark.Id).Id; Assert.Equal(expectedData, actualData); }
public void remove_all_bookmarks() { var DbService = new BookmarkDbService(mockContext.Object); var mockLogicService = new Mock <BookmarkService>(); var service = new BookmarkService(mapper, DbService); //Act service.RemoveAll(); //Assert mockSet.Verify(m => m.RemoveRange(It.IsAny <IEnumerable <BookmarkDB> >()), Times.Once()); }
public void get_bookmarks_by_userId() { var DbService = new BookmarkDbService(mockContext.Object); var mockLogicService = new Mock <BookmarkService>(); var service = new BookmarkService(mapper, DbService); //Act var x = service.GetByUserId("1").First(); //Assert Assert.AreEqual(x.UserId, "1"); }
public void Should_Load_Bookmarks() { //ACT var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["developmentserver"].ConnectionString; SqlConnection conn = new SqlConnection(connectionString); var id = 5; BookmarkService service = new BookmarkService(); var result = service.LoadBookmarks(id); Assert.IsNotNull(result); }
public void get_all_bookmarks() { var DbService = new BookmarkDbService(mockContext.Object); var mockLogicService = new Mock <BookmarkService>(); var service = new BookmarkService(mapper, DbService); //Act var x = service.GetAll(); //Assert Assert.AreEqual(x.Count(), bookmarks.Select(p => p).ToList().Count()); }
public BookmarksController() { //Todo: Use DI container for resolving dependencies :) _bookmarkRepository = new BookmarkRepository(new RavenSessionFactory()); _bookmarkService = new BookmarkService(_bookmarkRepository); }