Пример #1
0
        public CompanyCarTest()
        {
            _companyCarRepository = new CompanyCarRepository();
            _categoryRepository   = new CategoryRepository();

            _companyCarController = new CompanyCarController(_companyCarRepository, _categoryRepository);
        }
Пример #2
0
        public void DeleteCompanyCarTest()
        {
            var carCategory = new Category()
            {
                Id = 1, Name = "Car"
            };
            var toyota = new CompanyCar()
            {
                Id = 1, Name = "Toyota", Category = carCategory, CategoryId = 1
            };

            var mockRepo = new Mock <ICompanyCarRepository>();

            mockRepo.Setup(a => a.GetById(It.IsAny <int>())).Returns(toyota);
            mockRepo.Setup(a => a.Remove(It.IsAny <int>())).Returns(true);
            var companyCarController = new CompanyCarController(mockRepo.Object, _categoryRepository);

            var result = companyCarController.Delete(1) as OkNegotiatedContentResult <CompanyCar>;

            Assert.IsNotNull(result.Content);
            Assert.AreEqual(1, result.Content.Id);
        }