Exemplo n.º 1
0
 public MissionController(MissionRepository missionRepository, UserManager <AppUser> userManager, CategoryRespository categoryRespository, IHostingEnvironment environment, ApplicationDbContext context)
 {
     _context             = context;
     _environment         = environment;
     _categoryRespository = categoryRespository;
     _userManager         = userManager;
     _missonRepository    = missionRepository;
 }
 public UnitOfWork(AboveAllContext db)
 {
     _context     = db;
     Participants = new ParticipantRepository(db);
     Events       = new EventRepository(db);
     Category     = new CategoryRespository(db);
     Receipts     = new ReceiptRepository(db);
     Users        = new UserRepository(db);
 }
        public void GetAll_SuccessfulWithFullInformation()
        {
            //Using dataset to insert
            //    Moq.Language.Flow.IReturnsResult<DbSet<Category>> returnsResult = dbCategory.Setup(x => x.Add(It.IsAny<Category>())).Returns(category);
            Mock <DbSet <Category> > mockDbSetCategory = CreateCategoryDbSet();

            Mock <ApplicationDbContext> mockDbContext = new Mock <ApplicationDbContext>();

            mockDbContext.Setup(x => x.Category).Returns(mockDbSetCategory.Object);
            //  mockDbContext.Setup(x =>  x.Set<Category>()).Returns(mockDbSetCategory.Object);

            CategoryRespository categoryRespository = new CategoryRespository(mockDbContext.Object);

            var lstCategory = categoryRespository.GetAll();


            // Both must return the same value
            Assert.True(lstCategory.ToList().Count == 2);
        }
        public void Add_SuccessfulWithFullInformation()
        {
            //Using dataset to insert
            var dbCategory = new Mock <DbSet <Category> >();
            //    Moq.Language.Flow.IReturnsResult<DbSet<Category>> returnsResult = dbCategory.Setup(x => x.Add(It.IsAny<Category>())).Returns(category);
            Mock <ApplicationDbContext> mockDbContext = new Mock <ApplicationDbContext>( );

            mockDbContext.Setup(x => x.Set <Category>()).Returns(dbCategory.Object);
            CategoryRespository categoryRespository = new CategoryRespository(mockDbContext.Object);
            var category = new Category()
            {
                Id           = 1,
                DisplayOrder = 1,
                Name         = "Category 1",
                Description  = "Initialized db"
            };

            categoryRespository.Add(category);


            // Both must return the same value
            mockDbContext.Verify(x => x.Set <Category>());
            dbCategory.Verify(x => x.Add(It.Is <Category>(y => y == category)));
        }
 public CategoryController(CategoryRespository categoryRespository)
 {
     _categoryRespository = categoryRespository;
 }
        public IEnumerable <Category> CategoryDetails()
        {
            IEnumerable <Category> category = new CategoryRespository().GetCategory();

            return(category);
        }
        private void SetupBookingsModel(BookingsModel model)
        {
            CategoryRespository categoryRepository = new CategoryRespository(_sqlConnectionString);
            model.Categories = categoryRepository.GetList()
                .Select(p => new SelectListItem() { Text = p.Name, Value = p.Id.ToString() });
            IEnumerable<SelectListItem> tempList = new List<SelectListItem>();
            //{
            //   new SelectListItem()
            //   {
            //       Text = "TEST",
            //       Value = Guid.NewGuid().ToString()
            //   },
            //   new SelectListItem()
            //   {
            //       Text = "TEST2",
            //       Value = Guid.NewGuid().ToString()
            //   }
            //};
            model.LubeItems = tempList;
            model.Packages = tempList;
            model.Units = tempList;

            model.BookingItems = new List<BookingItemModel>();
        }