public ProductControllerTest()
 {
     //MockBehavior seçeneklerinden mockun geçtiði yerlerde kullanýmýnýn zorunlu olup olmayacaðýna karar verilir
     _mockRepo  = new Mock <IRepository <Product> >(MockBehavior.Default);
     controller = new ProductsController(_mockRepo.Object);
     products   = MockModels.GetProducts();
 }
        public async Task ValidModel_Create_ShouldSucceed()
        {
            var tax      = MockModels.GetTaxRequest();
            var testGuid = Guid.NewGuid();

            _taxesRepository
            .Setup(e => e.Add(It.IsAny <TaxEntity>()))
            .Returns(Task.FromResult(testGuid));

            Assert.AreEqual(testGuid, await _taxesService.Create(tax));
        }
        public void InvalidDate_GetTaxByDate_ShouldThrow()
        {
            var municipality = MockModels.GetMunicipalityEntity();

            _municipalitiesRepository
            .Setup(e => e.GetByIdWithRelated(Guid.Empty))
            .Returns(Task.FromResult(municipality));

            var expectedTax = municipality.Taxes.Last();

            Assert.ThrowsAsync <NotFoundException>(() => _municipalitiesService.GetTaxByDate(Guid.Empty, new DateTime(2020, 1, 30)));
        }
        public async Task ValidDate_GetTaxByDate_ShouldReturnDailyTax()
        {
            var municipality = MockModels.GetMunicipalityEntity();

            _municipalitiesRepository
            .Setup(e => e.GetByIdWithRelated(Guid.Empty))
            .Returns(Task.FromResult(municipality));

            var expectedTax = municipality.Taxes.Last();

            var actualTaxValue = await _municipalitiesService.GetTaxByDate(Guid.Empty, new DateTime(2016, 1, 30));

            Assert.AreEqual(expectedTax.Value, actualTaxValue);
        }
 public ProductApiControllerTest()
 {
     mockRepo      = new Mock <IRepository <Product> >();
     apiController = new ProductsApiController(mockRepo.Object);
     products      = MockModels.GetProducts();
 }