Beispiel #1
0
 public ServerImplementation()
 {
     repoAgent = new RepositoryDB <int, Agent>(new AgentRepository());
     repoExc   = new RepositoryDB <int, Excursie>(new ExcursieRepository());
     repoRezv  = new RepositoryDB <int, Rezervare>(new RezervareRepository());
     observers = new List <RezervareObserver>();
 }
        static void Main(string[] args)
        {
            RepositoryDB <int, Agent>     repoAgent = new RepositoryDB <int, Agent>(new AgentRepository());
            RepositoryDB <int, Excursie>  repoExc   = new RepositoryDB <int, Excursie>(new ExcursieRepository());
            RepositoryDB <int, Rezervare> repoRezv  = new RepositoryDB <int, Rezervare>(new RezervareRepository());
            AgentieService serviceImpl = new ServerImplementation();
            SerialServer   server      = new SerialServer("127.0.0.1", 55599, serviceImpl);

            server.Start();
        }
        public async Task ListBooksModelWithTopBooks()
        {
            // Arrange
            var mock = new Mock <IBookService>();

            mock.Setup(service => service.GetTopBooks(4)).ReturnsAsync(RepositoryDB.GetIndexBooks());
            var controller = new HomeController(mock.Object);

            // Проверим модель, которая передается в контроллер
            var partialViewResult = await controller.topBooks() as PartialViewResult;

            Assert.IsAssignableFrom <List <IndexBook> >(partialViewResult.Model);
        }
        public void PartialViewAReturnResultWithTopBooks()
        {
            // Arrange
            var mock = new Mock <IBookService>();

            mock.Setup(service => service.GetTopBooks(4)).ReturnsAsync(RepositoryDB.GetIndexBooks());
            var controller = new HomeController(mock.Object);

            // Act
            var result = controller.topBooks();


            // Возвращаемый тип
            Assert.IsType <Task <IActionResult> >(result);
        }
Beispiel #5
0
 private void connectRepositoryDB()
 {
     try
     {
         RepositoryDB.RegisterTypes(divMobiTypes);
         RepositoryDB.RegisterType(typeof(UserProxy));
         RepositoryDB.Activate();
         State |= ConnectionState.ConnectedToRepository;
     }
     catch// (Exception repositoryEx)
     {
         RepositoryDB = null;
         State       &= ~ConnectionState.RepositoryConnected;
     }
 }
        public async Task BooksModelCountsWithTopBooks(int count)
        {
            // Arrange
            var mock = new Mock <IBookService>();

            mock.Setup(service => service.GetTopBooks(count)).ReturnsAsync(RepositoryDB.GetIndexBooks(count));
            var controller = new HomeController(mock.Object);

            // Проверим модель, которая передается в контроллер
            var partialViewResult = await controller.topBooks(count) as PartialViewResult;

            var models = partialViewResult.Model as List <IndexBook>;


            Assert.Equal(models.Count, RepositoryDB.GetIndexBooks(count).Count);
        }
        public async void CheckCountElementsTransfetToNewBookPartial(int count)
        {
            // Arrange
            var bookServiceMock = new Mock <IBookService>();

            bookServiceMock.Setup(service => service.GetNewsBooks(count)).ReturnsAsync(RepositoryDB.GetIndexBooks(count));

            var controller = new HomeController(bookServiceMock.Object);

            // Получим представление
            var partialViewResult = await controller.newBooks(count) as PartialViewResult;

            // Получим модель, передаваемую в представление
            var models = partialViewResult.Model as IEnumerable <IndexBook>;

            Assert.Equal(models.Count(), RepositoryDB.GetIndexBooks(count).Count);
        }
        public async void CheckTransferTypesForNewBookPartialView()
        {
            // Arrange
            var bookServiceMock = new Mock <IBookService>();

            bookServiceMock.Setup(service => service.GetNewsBooks(4)).ReturnsAsync(RepositoryDB.GetIndexBooks(4));

            var controller = new HomeController(bookServiceMock.Object);

            // Получим представление
            var partialViewResult = await controller.newBooks(4) as PartialViewResult;

            // Получим модель, передаваемую в представление
            var model = partialViewResult.Model;

            // Assert
            Assert.IsAssignableFrom <IEnumerable <IndexBook> >(model);
        }
Beispiel #9
0
 public void disconnectFromRepository()
 {
     if (Synchronization != null)
     {
         Synchronization.Dispose();
         Synchronization = null;
     }
     if (RepositoryDB != null)
     {
         RepositoryDB.Dispose();
         RepositoryDB = null;
     }
     if (RepositoryDefinitions != null)
     {
         RepositoryDefinitions.Dispose();
         RepositoryDefinitions = null;
     }
     State &= ~ConnectionState.RepositoryConnected;
 }
        public async Task TypeModelWithLastCommentBookAndCounts(int countBooks)
        {
            // Arrange
            var mock = new Mock <IBookService>();

            mock.Setup(service => service.GetLastCommentaries(countBooks)).ReturnsAsync(RepositoryDB.GetBookViewModel(countBooks));
            var controller = new HomeController(mock.Object);


            // Получаем результат представления
            var partialViewResult = await controller.LastCommentsBook(countBooks) as PartialViewResult;

            var models = partialViewResult.Model as IEnumerable <BookViewModel>;


            Assert.IsAssignableFrom <IEnumerable <BookViewModel> >(models);


            Assert.Equal(models.Count(), RepositoryDB.GetIndexBooks(countBooks).Count);
        }
        public async void CheckTransferTypesForIndexData()
        {
            // Arrange
            var genresServiceMock = new Mock <IGenresService>();
            var userServiceMock   = new Mock <IUserService>();

            userServiceMock.Setup(service => service.GetTopUsers(5)).ReturnsAsync(RepositoryDB.GetTopUsers(5));
            userServiceMock.Setup(service => service.GetNewUsers(5)).ReturnsAsync(RepositoryDB.GetTopUsers(5));
            genresServiceMock.Setup(service => service.GetGenresSubCategories(4, 3)).ReturnsAsync(RepositoryDB.GetSubGenres(4, 3));

            // Act
            var controller = new HomeController(userServiceMock.Object, genresServiceMock.Object);

            // Проверим модель, которая передается в контроллер
            var partialViewResult = await controller.IndexData(4, 3, 5, 5) as PartialViewResult;

            var model = (IndexViewModel)partialViewResult.Model;

            // Assert

            Assert.IsAssignableFrom <IDictionary <CategoryGenre, System.Collections.Generic.List <GenreBook> > >(model.CategoryGenres);
            Assert.IsAssignableFrom <IEnumerable <TopUser> >(model.topUsers);
            Assert.IsAssignableFrom <IEnumerable <TopUser> >(model.NewUsers);
        }
Beispiel #12
0
 public void Create(Customer item)
 {
     RepositoryDB.Create(item);
 }
Beispiel #13
0
 public List <Customer> GetAll()
 {
     return(RepositoryDB.GetAll().ToList());
 }
Beispiel #14
0
 public Customer Update(int id, Customer updatedItem)
 {
     RepositoryDB.Update(updatedItem);
     return(updatedItem);
 }
Beispiel #15
0
 public Customer FindById(int id)
 {
     return(RepositoryDB.FindById(id));
 }
Beispiel #16
0
 public IQueryable <Customer> GetQuery()
 {
     return(RepositoryDB.GetAll());
 }
Beispiel #17
0
 public void Delete(Customer item)
 {
     RepositoryDB.Remove(item);
 }