Example #1
0
        public void GetEditionsByIdValidCall()
        {
            var mockedEditionRepository = new Mock <IEditionRepository>();

            mockedEditionRepository.Setup(x => x.GetByID(It.IsAny <int>())).Returns(edition);

            IEditionService mockService = new EditionService(mockedEditionRepository.Object);
            Edition         expected    = edition;
            Edition         actual      = mockService.GetEditionById(1);

            Assert.AreEqual(expected, actual, "Expected to have the same values");
        }
Example #2
0
        public void EditionSetUp()
        {
            service = new EditionService();

            edition = new Edition()
            {
                PageNumber   = 100,
                Year         = 2019,
                BookType     = EBookType.EHardCover,
                Publisher    = "Humanitas",
                NoTotal      = 10,
                NoForLibrary = 2,
                NoForLoan    = 8,
            };
        }
Example #3
0
        public void GetAllEditionsValidCall()
        {
            var mockedEditionRepository = new Mock <IEditionRepository>();

            mockedEditionRepository.Setup(x => x.Get(
                                              It.IsAny <Expression <Func <Edition, bool> > >(),
                                              It.IsAny <Func <IQueryable <Edition>, IOrderedQueryable <Edition> > >(),
                                              It.IsAny <string>())).Returns(GetAllSampleEditions());

            IEditionService mockService = new EditionService(mockedEditionRepository.Object);

            IEnumerable <Edition> expected = GetAllSampleEditions();
            IEnumerable <Edition> actual   = mockService.GetAllEditions();

            Assert.True(EnumerableExtensions.HasSameElementsAs <Edition>(expected, actual));
        }
Example #4
0
        public void LeagueGenerationTest()
        {
            Amabra.Database.AmabraContext Context = null;
            EditionService Service = new EditionService(Context);
            Edition        edition = new Edition();

            edition.Tournement               = new Tournement();
            edition.Teams                    = new List <Team>();
            edition.Tournement.Type          = "league";
            edition.Tournement.numberOfTeams = 10;
            for (var i = 0; i < 10; i++)
            {
                edition.Teams.Add(new Team(i.ToString()));
            }
            Service.Generate(edition);
        }
Example #5
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            log4net.GlobalContext.Properties["LogFileName"] = @"C:\\Users\\ahermeneanu\\Desktop\\logfile.txt"; // log file path
            log4net.Config.XmlConfigurator.Configure();

            Log.Info("Entering application.");

            Edition edition = new Edition("Publisher", 200, 2010, EBookType.EPaperBack, 2, 10);

            EditionService service = new EditionService();

            if (service.AddNewEdition(edition))
            {
                Log.Info("Edition added succesfully!");
                Console.WriteLine("Edition addded succesfully");
            }
            else
            {
                Log.Error("Failed to insert Edition!");
                Console.WriteLine("Edition not valid!");
            }

            Log.Info("LEaving application.");
        }
 public EditionsController(AmabraContext context)
 {
     _context        = context;
     _editionService = new EditionService(_context);
 }