public void GetCategories_ListNotNull_ReturnTheList()
        {
            var categories = new List <Category>()
            {
                new Category()
                {
                    CategoryId = 1
                },
                new Category()
                {
                    CategoryId = 2
                }
            }.AsQueryable();
            var mockSet = new Mock <DbSet <Category> >();

            mockSet.As <IQueryable <Category> >().Setup(m => m.Provider).Returns(categories.Provider);
            mockSet.As <IQueryable <Category> >().Setup(m => m.Expression).Returns(categories.Expression);
            mockSet.As <IQueryable <Category> >().Setup(m => m.ElementType).Returns(categories.ElementType);
            mockSet.As <IQueryable <Category> >().Setup(m => m.GetEnumerator()).Returns(categories.GetEnumerator());
            var contextMock = new Mock <Entities>();

            contextMock.Setup(p => p.Categories).Returns(mockSet.Object);


            var logic  = new CategoryLogic(contextMock.Object);
            var result = logic.GetCategories();

            result.Should().HaveCount(2);
            result.Should().AllBeOfType <Category>();
        }
 public AccountController(IUserRepository iUserRepo, IAuraRepository iAuraRepo, ICategoryRepository iCategoryRepo, IPostrepository iPostRepo)
 {
     _accountLogic  = new UserLogic(iUserRepo);
     _auraLogic     = new AuraLogic(iAuraRepo);
     _categoryLogic = new CategoryLogic(iCategoryRepo);
     _postLogic     = new PostLogic(iPostRepo);
 }
Exemple #3
0
        public void ListOneCategory()
        {
            CategoryLogic c = new CategoryLogic(this.categrepo.Object, this.comprepo.Object, this.sponsorrepo.Object);

            List <Category> newc = new List <Category>()
            {
                new Category {
                    CategoryId     = Guid.NewGuid().ToString(),
                    Name           = CategoryType.ClassicPhysique,
                    StartingWeight = 87,
                    MaximumWeight  = 111
                },

                new Category {
                    CategoryId     = Guid.NewGuid().ToString(),
                    Name           = CategoryType.MensPhisyque,
                    StartingWeight = 88,
                    MaximumWeight  = 112
                }
            };

            Category expectedout = new Category();

            expectedout = newc[0];

            categrepo.Setup(x => x.FindOne(newc[0].CategoryId)).Returns(newc[0]);
            var output = c.Find(newc[0].CategoryId);

            Assert.That(output.CategoryId, Is.EquivalentTo(expectedout.CategoryId));
        }
Exemple #4
0
        public void ListAllCategory()
        {
            CategoryLogic c = new CategoryLogic(this.categrepo.Object, this.comprepo.Object, this.sponsorrepo.Object);

            List <Category> newc = new List <Category>()
            {
                new Category {
                    CategoryId     = Guid.NewGuid().ToString(),
                    Name           = CategoryType.ClassicPhysique,
                    StartingWeight = 87,
                    MaximumWeight  = 111
                },

                new Category {
                    CategoryId     = Guid.NewGuid().ToString(),
                    Name           = CategoryType.MensPhisyque,
                    StartingWeight = 88,
                    MaximumWeight  = 112
                }
            };

            List <Category> expectedout = new List <Category>()
            {
                newc[0], newc[1]
            };

            categrepo.Setup(x => x.ListAll()).Returns(newc.AsQueryable());
            var output = c.List();

            Assert.That(output, Is.EquivalentTo(expectedout));
            Assert.That(output.Count, Is.EqualTo(expectedout.Count));
        }
        public async void UpdateAsync_GivenCategoryExists_ReturnsSuccess()
        {
            var categoryToUpdate = new CategoryDTO
            {
                Id   = 1,
                Name = "Category"
            };

            var categoryToUpdateWithChanges = new CategoryDTO
            {
                Id   = 1,
                Name = "Category123"
            };

            categoryRepositoryMock.Setup(c => c.FindAsync(categoryToUpdateWithChanges.Id)).ReturnsAsync(categoryToUpdate);
            categoryRepositoryMock.Setup(c => c.UpdateAsync(categoryToUpdateWithChanges)).ReturnsAsync(true);

            using (var logic = new CategoryLogic(categoryRepositoryMock.Object, projectRepositoryMock.Object))
            {
                var response = await logic.UpdateAsync(categoryToUpdateWithChanges);

                Assert.Equal(ResponseLogic.SUCCESS, response);
                categoryRepositoryMock.Verify(c => c.FindAsync(categoryToUpdateWithChanges.Id));
                categoryRepositoryMock.Verify(c => c.UpdateAsync(categoryToUpdateWithChanges));
            }
        }
        public async void GetAsync_GivenCategoriesExist_ReturnsEnumerableCategories()
        {
            var categoriesToReturn = new CategoryDTO[]
            {
                new CategoryDTO {
                    Id = 1, Name = "This is the first"
                },
                new CategoryDTO {
                    Id = 2, Name = "This is the second"
                },
                new CategoryDTO {
                    Id = 3, Name = "This is the third"
                }
            };

            categoryRepositoryMock.Setup(c => c.ReadAsync()).ReturnsAsync(categoriesToReturn);

            using (var logic = new CategoryLogic(categoryRepositoryMock.Object, projectRepositoryMock.Object))
            {
                var results = await logic.GetAsync();

                Assert.Equal(categoriesToReturn, results);
                categoryRepositoryMock.Verify(c => c.ReadAsync());
            }
        }
        public async void RemoveAsync_GivenCategoryExistsAndMoreThanOneProject_ReturnsSuccess()
        {
            var categoryToDelete = new CategoryDTO
            {
                Id   = 1,
                Name = "Category"
            };

            var projectsArray = new ProjectSummaryDTO[]
            {
                new ProjectSummaryDTO {
                    Title = "Project1", Category = categoryToDelete
                },
                new ProjectSummaryDTO {
                    Title = "Project2", Category = categoryToDelete
                }
            };

            categoryRepositoryMock.Setup(c => c.FindAsync(categoryToDelete.Id)).ReturnsAsync(categoryToDelete);
            projectRepositoryMock.Setup(p => p.ReadAsync()).ReturnsAsync(projectsArray);

            using (var logic = new CategoryLogic(categoryRepositoryMock.Object, projectRepositoryMock.Object))
            {
                var response = await logic.RemoveAsync(categoryToDelete);

                Assert.Equal(ResponseLogic.SUCCESS, response);
                categoryRepositoryMock.Verify(c => c.FindAsync(categoryToDelete.Id));
                categoryRepositoryMock.Verify(c => c.DeleteAsync(It.IsAny <int>()), Times.Never());
                projectRepositoryMock.Verify(p => p.ReadAsync());
            }
        }
        public async void UpdateAsync_GivenErrorUpdating_ReturnsERROR_UPDATING()
        {
            var categoryToUpdate = new CategoryDTO
            {
                Id   = 1,
                Name = "Category"
            };

            var categoryToUpdateWithChanges = new CategoryDTO
            {
                Id   = 1,
                Name = "Category123"
            };

            categoryRepositoryMock.Setup(c => c.FindAsync(categoryToUpdateWithChanges.Id)).ReturnsAsync(categoryToUpdate);
            categoryRepositoryMock.Setup(c => c.UpdateAsync(categoryToUpdateWithChanges)).ReturnsAsync(false);

            using (var logic = new CategoryLogic(categoryRepositoryMock.Object, projectRepositoryMock.Object))
            {
                var response = await logic.UpdateAsync(categoryToUpdateWithChanges);

                Assert.Equal(ResponseLogic.ERROR_UPDATING, response);
                categoryRepositoryMock.Verify(c => c.FindAsync(categoryToUpdateWithChanges.Id));
                categoryRepositoryMock.Verify(c => c.UpdateAsync(categoryToUpdateWithChanges));
            }
        }
Exemple #9
0
 public FormArticle(ArticleLogic logicA, UserLogic logicU, CategoryLogic logicC)
 {
     InitializeComponent();
     this.logicA = logicA;
     this.logicC = logicC;
     this.logicU = logicU;
 }
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
        private async void GetCoupons()
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
        {
            try
            {
                Config.ShowDialog();
                if (!CrossConnectivity.Current.IsConnected)
                {
                    await DisplayAlert("Alert", "Your device is not connected to internet. Please try again later.",
                                       "Ok");
                }
                else
                {
                    var response = await CategoryLogic.CouponList();

                    if (response.status == 200)
                    {
                        Config.HideDialog();
                        listCoupons.ItemsSource = response.data;
                    }
                    else
                    {
                        Config.HideDialog();
                        EmptyCoupons();
                        //await DisplayAlert("Alert", response.message, "Ok");
                    }
                }
            }
            catch
            {
                Config.HideDialog();
                EmptyCoupons();
                await DisplayAlert("Alert", Config.ApiErrorMessage, "Ok");
            }
        }
Exemple #11
0
        public ActionResult CategoryDelete(Category category)
        {
            var categoryService = new CategoryLogic();

            categoryService.DeleteCategory(category.CategoryId);
            return(RedirectToAction("Categories"));
        }
Exemple #12
0
        public CategoryDTO GetById(int id)
        {
            CategoryLogic logic  = new CategoryLogic();
            CategoryDTO   output = logic.MapCategoryToDtoUsingId(id);

            return(output);
        }
Exemple #13
0
        public ShoppingController()
        {
            this.cart_Service  = new CartLogic();
            this.item_Service  = new ItemLogic();
            this.CategoryLogic = new CategoryLogic();

            this.department_Service = new CategoryLogic();
        }
Exemple #14
0
        // GET: StoreManager/Create
        public ActionResult ProductCreate()
        {
            var categoryList = new CategoryLogic();

            ViewBag.CategoryId = categoryList.SetCategoryViewBag();

            return(View());
        }
Exemple #15
0
        public ActionResult <List <Category> > Get()
        {
            var categoryLogic = new CategoryLogic();
            var cats          = categoryLogic.GetCategorias();

            Console.WriteLine(cats);
            return(cats);
        }
 public AdminController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, LogLogic logLogic)
 {
     _questionLogic = questionLogic;
     _categoryLogic = categoryLogic;
     _reactionLogic = reactionLogic;
     _userLogic     = userLogic;
     _chatLogic     = chatLogic;
     _logLogic      = logLogic;
 }
 public VideoController(VideoLogic videoLogic, CategoryLogic categoryLogic, ReportLogic reportLogic, CommentLogic commentLogic, UserLogic userLogic, IHostingEnvironment environment)
 {
     _videoLogic = videoLogic;
     _categoryLogic = categoryLogic;
     _reportLogic = reportLogic;
     _commentLogic = commentLogic;
     _userLogic = userLogic;
     _environment = environment;
 }
Exemple #18
0
 public CareRecipientController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, AppointmentLogic appointmentLogic)
 {
     _questionLogic    = questionLogic;
     _categoryLogic    = categoryLogic;
     _reactionLogic    = reactionLogic;
     _userLogic        = userLogic;
     _chatLogic        = chatLogic;
     _appointmentLogic = appointmentLogic;
 }
Exemple #19
0
        public void TestCategoryTree()
        {
            var logic = new CategoryLogic();

            var tree = logic.GetCategoryTree();

            Assert.IsTrue(tree.Nodes[0].Entity.Name == "Laptops");
            Assert.IsTrue(tree.Nodes[0].SubNodes[0].Entity.Name == "Gaming");
        }
Exemple #20
0
 public ReviewController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, ReviewLogic reviewLogic)
 {
     _questionLogic = questionLogic;
     _categoryLogic = categoryLogic;
     _reactionLogic = reactionLogic;
     _userLogic     = userLogic;
     _chatLogic     = chatLogic;
     _reviewLogic   = reviewLogic;
 }
        public void GetCategory_InvalidCategoryId_ThrowsNotFound(long id)
        {
            var response    = new HttpResponseMessage(HttpStatusCode.NotFound);
            var contextMock = Mock.Of <Entities>();

            var logic = new CategoryLogic(contextMock);

            logic.Invoking(p => p.GetCategory(id)).ShouldThrow <HttpResponseException>().Where(p => p.Response == response);
        }
Exemple #22
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CategoryLogic db = new CategoryLogic();

            this.categories = db.GetAllCategories();
            foreach (Category category in categories)
            {
                cboxCategory.Items.Add(category.Name);
            }
        }
Exemple #23
0
 public ActionResult CategoryCreate(string title)
 {
     if (ModelState.IsValid)
     {
         var category = new CategoryLogic();
         category.CreateNewCategory(title);
         return(RedirectToAction("Categories"));
     }
     return(View());
 }
Exemple #24
0
 public void Initialize()
 {
     _mockPostRepo     = new MockPostRepository();
     _postLogic        = new PostLogic(_mockPostRepo);
     _mockAuraRepo     = new MockAuraRepository();
     _auraLogic        = new AuraLogic(_mockAuraRepo);
     _mockUserRepo     = new MockUserRepository();
     _userLogic        = new UserLogic(_mockUserRepo);
     _mockCategoryRepo = new MockCategoryRepository();
     _categoryLogic    = new CategoryLogic(_mockCategoryRepo);
 }
 static DependencyResolver()
 {
     AccountDao    = new AccountDao();
     AccountLogic  = new AccountLogic(AccountDao);
     CategoryDao   = new CategoryDao();
     CategoryLogic = new CategoryLogic(CategoryDao);
     SubjectDao    = new SubjectDao();
     SubjectLogic  = new SubjectLogic(SubjectDao);
     TestDao       = new TestDao();
     TestLogic     = new TestLogic(TestDao);
 }
 public IHttpActionResult GetCategoriesForTeacher(int teacherId)
 {
     try
     {
         return(Ok(CategoryLogic.GetCategoriesForTeacher(teacherId)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public void GetCategories_ListIsNull_ReturnNull()
        {
            var mockSet     = new Mock <DbSet <Category> >();
            var contextMock = new Mock <Entities>();

            contextMock.Setup(p => p.Categories).Returns(mockSet.Object);

            var logic  = new CategoryLogic(contextMock.Object);
            var result = logic.GetCategories();

            contextMock.Verify(entities => entities.Categories, Times.Once());
        }
 public async Task DeleteAsync()
 {
     try
     {
         await CategoryLogic.DeleteCategoryAsync(Id);
     }
     catch (Exception e)
     {
         Logger.LogError(e, e.Message);
         await ShowErrorMessageAsync();
     }
 }
        private void DeleteCategory(object sender, RoutedEventArgs e)
        {
            var element  = (FrameworkElement)sender;
            var category = element.DataContext as Category;

            if (category == null)
            {
                return;
            }

            CategoryLogic.DeleteCategory(category);
        }
        public IHttpActionResult Post(CategoryBTO categBto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            CategoryLogic categ = new CategoryLogic();
            var           model = categ.Create(categBto);

            return(CreatedAtRoute("DefaultApi", new { id = model.Id }, model));
        }
 public CategoriesController()
 {
     db = new CategoryBLL();
 }
 public StoreController()
 {
     catBLL = new CategoryBLL();
     prodBLL = new ProductBLL();
 }
 public StoreController(CategoryLogic stub, ProductLogic prostub)
 {
     catBLL = stub;
     prodBLL = prostub;
 }
 public CategoriesController(CategoryLogic stub)
 {
     db = stub;
 }
Exemple #35
0
        public ApiModule()
            : base("/api")
        {
            #region  ///  Help Page  ///
            Get["/help"] = x => View["help"];
            #endregion

            #region  ///  Category  ///

            #region  ///  /api/Categories/  ///
            Get["/categories"] = x =>
            {
                var logic = new CategoryLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Categories/1234  ///
            Get["/categories/{id:int}"] = x =>
            {
                var logic = new CategoryLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Customer  ///

            #region  ///  /api/Customers/  ///
            Get["/customers"] = x =>
            {
                var logic = new CustomerLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Customers/1234  ///
            Get["/customers/{id*}"] = x =>
            {
                var logic = new CustomerLogic();

                var result = logic.GetById((string)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Employee  ///

            #region  ///  /api/employees  ///
            Get["/employees"] = x =>
            {
                var logic = new EmployeeLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  ///  /api/employees/1234  ///
            Get["/employees/{id:int}"] = x =>
            {
                var logic = new EmployeeLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Order  ///

            #region  ///  /api/Orders/  ///
            Get["/orders"] = x =>
            {
                var logic = new OrderLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Orders/1234  ///
            Get["/orders/{id:int}"] = x =>
            {
                var logic = new OrderLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Product  ///

            #region  ///  /api/Products/  ///
            Get["/products"] = x =>
            {
                var logic = new ProductLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Products/1234  ///
            Get["/products/{id:int}"] = x =>
            {
                var logic = new ProductLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Region  ///

            #region  ///  /api/Regions/  ///
            Get["/regions"] = x =>
            {
                var logic = new RegionLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Regions/1234  ///
            Get["/regions/{id:int}"] = x =>
            {
                var logic = new RegionLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Shipper  ///

            #region  ///  /api/Shippers/  ///
            Get["/shippers"] = x =>
            {
                var logic = new ShipperLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Shippers/1234  ///
            Get["/shippers/{id:int}"] = x =>
            {
                var logic = new ShipperLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Supplier  ///

            #region  ///  /api/Suppliers/  ///
            Get["/suppliers"] = x =>
            {
                var logic = new SupplierLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Suppliers/1234  ///
            Get["/suppliers/{id:int}"] = x =>
            {
                var logic = new SupplierLogic();

                var result = logic.GetById((int)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion

            #region  ///  Territory  ///

            #region  ///  /api/Territories/  ///
            Get["/territories"] = x =>
            {
                var logic = new TerritoryLogic();

                var result = logic.GetAll();

                return Response.AsJson(result);
            };
            #endregion

            #region  /// /api/Territories/1234  ///
            Get["/territories/{id:string}"] = x =>
            {
                var logic = new TerritoryLogic();

                var result = logic.GetById((string)x.id);

                return Response.AsJson(result);
            };
            #endregion

            #endregion
        }