public void TestAddPublisher()
        {
            ComicRepository cr         = new ComicRepository(context);
            Publisher       publisher1 = new Publisher("publisher1");
            Publisher       publisher2 = new Publisher("publisher2");
            var             result1    = cr.GetAllPublishers();

            result1.Should().HaveCount(0);
            cr.AddPublisher(publisher1);
            result1 = cr.GetAllPublishers();
            result1.Should().HaveCount(1);
            result1.First().Name.Should().Be("publisher1");
            cr.AddPublisher(publisher2);
            result1 = cr.GetAllPublishers();
            result1.Should().HaveCount(2);
            result1.ElementAt(1).Name.Should().Be("publisher2");
            context.Dispose();
        }
        public void TestAddSeries()
        {
            ComicRepository cr      = new ComicRepository(context);
            Series          series1 = new Series("series1");
            Series          series2 = new Series("series2");
            var             result1 = cr.GetAllSeries();

            result1.Should().HaveCount(0);
            cr.AddSeries(series1);
            result1 = cr.GetAllSeries();
            result1.Should().HaveCount(1);
            result1.First().Name.Should().Be("series1");
            cr.AddSeries(series2);
            result1 = cr.GetAllSeries();
            result1.Should().HaveCount(2);
            result1.First().Name.Should().Be("series1");
            result1.ElementAt(1).Name.Should().Be("series2");
            context.Dispose();
        }
        public void TestAddAuthor()
        {
            ComicRepository cr      = new ComicRepository(context);
            Author          author1 = new Author("author1");
            Author          author2 = new Author("author2");
            var             result1 = cr.GetAllAuthors();

            result1.Should().HaveCount(0);
            cr.AddAuthor(author1);
            result1 = cr.GetAllAuthors();
            result1.Should().HaveCount(1);
            result1.First().Name.Should().Be("author1");
            cr.AddAuthor(author2);
            result1 = cr.GetAllAuthors();
            result1.Should().HaveCount(2);
            result1.First().Name.Should().Be("author1");
            result1.ElementAt(1).Name.Should().Be("author2");
            context.Dispose();
        }
        public void TestAddComic()
        {
            Comic comic1 = new Comic("De legende van het Westen", new Series("Lucky Luke"), 73, new List <Author>()
            {
                new Author("Morris"), new Author("Nordmann Patrick")
            }, new Publisher("Dupuis"));
            Comic comic2 = new Comic("Oklahoma Jim", new Series("Lucky Luke"), 69, new List <Author>()
            {
                new Author("Léturgie Jean"), new Author("Morris"), new Author("Conrad Didier"), new Author("Pearce")
            }, new Publisher("Dupuis"));
            ComicRepository cr = new ComicRepository(context);

            cr.AddComic(comic1);
            cr.AddComic(comic2);
            var result = cr.GetComics();

            result.Should().HaveCount(2);
            result.First().Title.Should().Be("De legende van het Westen");
            result.First().Series.Name.Should().Be("Lucky Luke");
            result.First().SeriesNumber.Should().Be(73);
            result.First().Publisher.Name.Should().Be("Dupuis");
            result.First().Authors.Should().HaveCount(2);
            result.First().Authors.First().Name.Should().Be("Morris");
            result.First().Authors.ElementAt(1).Name.Should().Be("Nordmann Patrick");

            result.ElementAt(1).Title.Should().Be("Oklahoma Jim");
            result.ElementAt(1).Series.Name.Should().Be("Lucky Luke");
            result.ElementAt(1).SeriesNumber.Should().Be(69);
            result.ElementAt(1).Publisher.Name.Should().Be("Dupuis");
            result.ElementAt(1).Authors.Should().HaveCount(4);
            result.ElementAt(1).Authors.First().Name.Should().Be("Léturgie Jean");
            result.ElementAt(1).Authors.ElementAt(3).Name.Should().Be("Pearce");
            context.Dispose();
        }
Beispiel #5
0
        public IActionResult ResetGridState([FromBody] GridGetStateDto request)
        {
            var result            = new OperationResponse <bool>();
            var connectionFactory =
                new AppConfigConnectionFactory(_configuration.GetConnectionString("CosDB"), "System.Data.SqlClient");
            var context = new AdoNetContext(connectionFactory);

            try
            {
                result.Data = _gridHandler.ResetGridState(request.UserName, request.GridKey, context);
            }
            catch (Exception e)
            {
                result.State = ResponseState.Error;
                result.Messages.Add("Error resetting grid state");
                _logger.LogError(e, "Error resetting grid state");
            }
            finally
            {
                context.Dispose();
            }
            return(Json(result));
        }
Beispiel #6
0
        public void TestAddOrder()
        {
            Dictionary <Comic, int> orderComics = new Dictionary <Comic, int>();
            Comic comic1 = new Comic("Het verhaal van de ambetante test", new Series("Lucky Luke"), 73, new List <Author>()
            {
                new Author("Morris"), new Author("Nordmann Patrick")
            }, new Publisher("Dupuis"), 1);
            Comic comic2 = new Comic("Test deel 2", new Series("Lucky Luke"), 69, new List <Author>()
            {
                new Author("Léturgie Jean"), new Author("Morris"), new Author("Conrad Didier"), new Author("Pearce")
            }, new Publisher("Dupuis"), 5);

            orderComics.Add(comic1, 1);
            orderComics.Add(comic2, 1);
            Controller controller = new Controller(new UnitOfWork("Test"));

            controller.AddComic(comic1);
            controller.AddComic(comic2);
            Order order = new Order(orderComics);

            controller.AddOrder(order);
            context.Dispose();
        }
Beispiel #7
0
        public void TestAddDelivery()
        {
            Dictionary <Comic, int> orderComics = new Dictionary <Comic, int>();
            Comic comic1 = new Comic("De legende van le fred", new Series("Lucky Luke"), 73, new List <Author>()
            {
                new Author("Morris"), new Author("Nordmann Patrick")
            }, new Publisher("Dupuis"), 1);
            Comic comic2 = new Comic("Oklahoma jiha", new Series("Lucky Luke"), 69, new List <Author>()
            {
                new Author("Léturgie Jean"), new Author("Morris"), new Author("Conrad Didier"), new Author("Pearce")
            }, new Publisher("Dupuis"), 5);

            orderComics.Add(comic1, 1);
            orderComics.Add(comic2, 1);
            Controller controller = new Controller(new UnitOfWork("Test"));

            controller.AddComic(comic1);
            controller.AddComic(comic2);
            Delivery delivery = new Delivery(DateTime.Now.AddDays(10), orderComics);

            controller.AddDelivery(delivery);
            context.Dispose();
        }
 public void Dispose()
 {
     _ctx.Dispose();
 }