Пример #1
0
        public void Return_Instance_Of_FlatTaxRate_When_Called()
        {
            //map classes
            _mapper = new Mapper(new MapperConfiguration(cfg =>
                                                         cfg.CreateMap <FlatTaxRate, Dto.DataAccess.FlatTaxRate>()
                                                         ));
            // instantiate data access class
            _taxDataAccess = new TaxDataAccess(_taxAdministrationContext.Object, _mapper);

            _mockFlatTaxRate = new Mock <DbSet <FlatTaxRate> >();
            _mockFlatTaxRate.As <IQueryable <FlatTaxRate> >().Setup(m => m.Provider).Returns(_queryableFlatTaxRate.Provider);
            _mockFlatTaxRate.As <IQueryable <FlatTaxRate> >().Setup(m => m.Expression).Returns(_queryableFlatTaxRate.Expression);
            _mockFlatTaxRate.As <IQueryable <FlatTaxRate> >().Setup(m => m.ElementType).Returns(_queryableFlatTaxRate.ElementType);
            _mockFlatTaxRate.As <IQueryable <FlatTaxRate> >().Setup(m => m.GetEnumerator()).Returns(_queryableFlatTaxRate.GetEnumerator);

            _taxAdministrationContext.Setup(m => m.FlatTaxRate).Returns(_mockFlatTaxRate.Object);

            Assert.IsInstanceOf <Dto.DataAccess.FlatTaxRate> (_taxDataAccess.GetFlatTaxRate());
        }