Beispiel #1
0
        public void CountryEnumerableToCountryDTOList()
        {
            //Arrange

            var country = new Country("Spain", "es-ES");

            country.GenerateNewIdentity();

            IEnumerable <Country> countries = new List <Country>()
            {
                country
            };

            //Act
            ITypeAdapter adapter = TypeAdapterFactory.CreateAdapter();
            var          dtos    = adapter.Adapt <IEnumerable <Country>, List <CountryDTO> >(countries);

            //Assert
            Assert.NotNull(dtos);
            Assert.True(dtos.Any());
            Assert.True(dtos.Count == 1);

            var dto = dtos[0];

            Assert.Equal(country.Id, dto.Id);
            Assert.Equal(country.CountryName, dto.CountryName);
            Assert.Equal(country.CountryISOCode, dto.CountryISOCode);
        }
Beispiel #2
0
        public void AdaptEnumerableBankActivityToListBankActivityDTO()
        {
            //Arrange
            BankAccountActivity activity = new BankAccountActivity();

            activity.GenerateNewIdentity();
            activity.Date   = DateTime.Now;
            activity.Amount = 1000;
            activity.ActivityDescription = "transfer...";

            IEnumerable <BankAccountActivity> activities = new List <BankAccountActivity>()
            {
                activity
            };

            //Act
            ITypeAdapter adapter       = TypeAdapterFactory.CreateAdapter();
            var          activitiesDTO = adapter.Adapt <IEnumerable <BankAccountActivity>, List <BankActivityDTO> >(activities);

            //Assert
            Assert.NotNull(activitiesDTO);
            Assert.True(activitiesDTO.Count() == 1);

            Assert.Equal(activity.Date, activitiesDTO[0].Date);
            Assert.Equal(activity.Amount, activitiesDTO[0].Amount);
            Assert.Equal(activity.ActivityDescription, activitiesDTO[0].ActivityDescription);
        }
        public void EnumerableSoftwareToListSoftwareDTOAdapter()
        {
            //Arrange
            var software = new Software("the title", "The description", "AB001");

            software.ChangeUnitPrice(10);
            software.IncrementStock(10);
            software.GenerateNewIdentity();

            var softwares = new List <Software>()
            {
                software
            };


            //Act
            ITypeAdapter adapter      = TypeAdapterFactory.CreateAdapter();
            var          softwaresDTO = adapter.Adapt <IEnumerable <Software>, List <SoftwareDTO> >(softwares);

            //Assert
            Assert.Equal(softwares[0].Id, softwaresDTO[0].Id);
            Assert.Equal(softwares[0].Title, softwaresDTO[0].Title);
            Assert.Equal(softwares[0].Description, softwaresDTO[0].Description);
            Assert.Equal(softwares[0].AmountInStock, softwaresDTO[0].AmountInStock);
            Assert.Equal(softwares[0].UnitPrice, softwaresDTO[0].UnitPrice);
            Assert.Equal(softwares[0].LicenseCode, softwaresDTO[0].LicenseCode);
        }
        private readonly ITextbookRepository _textbookRepo;         //= ServiceLocator.Current.GetInstance<ITextbookRepository>();

        #endregion

        #region 构造函数

        public DeclarationAppl(ITypeAdapter adapter, ITeacherRepository teacherRepo, ITeachingTaskRepository teachingTaskRepo, ITextbookRepository textbookRepo)
        {
            _adapter          = adapter;
            _teacherRepo      = teacherRepo;
            _teachingTaskRepo = teachingTaskRepo;
            _textbookRepo     = textbookRepo;
        }
        public void BlogEnumerableToBlogDTOList()
        {
            //Arrange
            var blog = BlogFactory.CreateBlog("Name", "Url", 0);

            IEnumerable <Blog> blogs = new List <Blog>()
            {
                blog
            };

            //Act
            ITypeAdapter adapter = TypeAdapterFactory.CreateAdapter();
            var          dtos    = adapter.Adapt <IEnumerable <Blog>, List <BlogDTO> >(blogs);

            //Assert
            Assert.NotNull(dtos);
            Assert.True(dtos.Any());
            Assert.True(dtos.Count == 1);

            var dto = dtos[0];

            Assert.Equal(blog.BlogId, dto.BlogId);
            Assert.Equal(blog.Name, dto.Name);
            Assert.Equal(blog.Url, dto.Url);
            Assert.Equal(blog.Rating, dto.Rating);
        }
        public void EnumerableBookToListBookDTOAdapter()
        {
            //Arrange
            var book = new Book("the title", "The description", "Krasis Press", "ABD12");

            book.ChangeUnitPrice(10);
            book.IncrementStock(10);
            book.GenerateNewIdentity();

            var books = new List <Book>()
            {
                book
            };

            //Act
            ITypeAdapter adapter  = TypeAdapterFactory.CreateAdapter();
            var          booksDTO = adapter.Adapt <IEnumerable <Book>, List <BookDTO> >(books);

            //Assert
            Assert.Equal(books[0].Id, booksDTO[0].Id);
            Assert.Equal(books[0].Title, booksDTO[0].Title);
            Assert.Equal(books[0].Description, booksDTO[0].Description);
            Assert.Equal(books[0].AmountInStock, booksDTO[0].AmountInStock);
            Assert.Equal(books[0].UnitPrice, booksDTO[0].UnitPrice);
            Assert.Equal(books[0].ISBN, booksDTO[0].ISBN);
            Assert.Equal(books[0].Publisher, booksDTO[0].Publisher);
        }
Beispiel #7
0
        public void AdaptBankAccountToBankAccountDTO()
        {
            //Arrange
            var country = new Country("Spain", "es-ES");

            country.GenerateNewIdentity();

            var customer = CustomerFactory.CreateCustomer("jhon", "el rojo", "+3441", "company", country, new Address("", "", "", ""));

            customer.GenerateNewIdentity();

            BankAccount account = new BankAccount();

            account.GenerateNewIdentity();
            account.BankAccountNumber = new BankAccountNumber("4444", "5555", "3333333333", "02");
            account.SetCustomerOwnerOfThisBankAccount(customer);
            account.DepositMoney(1000, "reason");
            account.Lock();

            //Act
            ITypeAdapter adapter        = TypeAdapterFactory.CreateAdapter();
            var          bankAccountDTO = adapter.Adapt <BankAccount, BankAccountDTO>(account);


            //Assert
            Assert.Equal(account.Id, bankAccountDTO.Id);
            Assert.Equal(account.Iban, bankAccountDTO.BankAccountNumber);
            Assert.Equal(account.Balance, bankAccountDTO.Balance);
            Assert.Equal(account.Customer.FirstName, bankAccountDTO.CustomerFirstName);
            Assert.Equal(account.Customer.LastName, bankAccountDTO.CustomerLastName);
            Assert.Equal(account.Locked, bankAccountDTO.Locked);
        }
        public void EnumerableProductToListProductDTOAdapter()
        {
            //Arrange
            var software = new Software("the title", "The description", "AB001");

            software.ChangeUnitPrice(10);
            software.IncrementStock(10);
            software.GenerateNewIdentity();

            var products = new List <Software>()
            {
                software
            };

            //Act
            ITypeAdapter adapter     = TypeAdapterFactory.CreateAdapter();
            var          productsDTO = adapter.Adapt <IEnumerable <Product>, List <ProductDTO> >(products);

            //Assert
            Assert.AreEqual(products[0].Id, productsDTO[0].Id);
            Assert.AreEqual(products[0].Title, productsDTO[0].Title);
            Assert.AreEqual(products[0].Description, productsDTO[0].Description);
            Assert.AreEqual(products[0].AmountInStock, productsDTO[0].AmountInStock);
            Assert.AreEqual(products[0].UnitPrice, productsDTO[0].UnitPrice);
        }
        private readonly ITextbookRepository _textbookRepo; //= ServiceLocator.Current.GetInstance<ITextbookRepository>();

        #endregion Fields

        #region Constructors

        public DeclarationAppl(ITypeAdapter adapter, ITeacherRepository teacherRepo, ITeachingTaskRepository teachingTaskRepo, ITextbookRepository textbookRepo)
        {
            _adapter = adapter;
            _teacherRepo = teacherRepo;
            _teachingTaskRepo = teachingTaskRepo;
            _textbookRepo = textbookRepo;
        }
Beispiel #10
0
 public ReportManagerService(
     ITypeAdapter typeAdapter,
     IInstructionProcessorFactoryProxy instructionProcessorFactoryProxy)
 {
     _typeAdapter = typeAdapter;
     InstructionProcessorFactoryProxy = instructionProcessorFactoryProxy;
 }
 public ReleaseClassBookAppl(ITypeAdapter adapter, IProfessionalClassRepository classRepo, ISubscriptionRepository subscriptionRepo, IInventoryRepository inventoryRepo, IStorageRepository storageRepo)
 {
     _adapter = adapter;
     _classRepo = classRepo;
     _subscriptionRepo = subscriptionRepo;
     _inventoryRepo = inventoryRepo;
     _storageRepo = storageRepo;
 }
 public ReleaseClassBookAppl(ITypeAdapter adapter, IProfessionalClassRepository classRepo, ISubscriptionRepository subscriptionRepo, IInventoryRepository inventoryRepo, IStorageRepository storageRepo)
 {
     _adapter          = adapter;
     _classRepo        = classRepo;
     _subscriptionRepo = subscriptionRepo;
     _inventoryRepo    = inventoryRepo;
     _storageRepo      = storageRepo;
 }
Beispiel #13
0
 public PersonController(
     ITypeAdapterFactory adapterFactory,
     IPersonService personService
     )
 {
     _adapter       = adapterFactory.Create();
     _personService = personService;
 }
Beispiel #14
0
        public void OrderToOrderDTOAdapter()
        {
            //Arrange

            Customer customer = new Customer();

            customer.GenerateNewIdentity();
            customer.FirstName = "Unai";
            customer.LastName  = "Zorrilla";

            Product product = new Software("the product title", "the product description", "license code");

            product.GenerateNewIdentity();


            Order order = new Order();

            order.GenerateNewIdentity();
            order.OrderDate           = DateTime.Now;
            order.ShippingInformation = new ShippingInfo("shippingName", "shippingAddress", "shippingCity", "shippingZipCode");
            order.SetTheCustomerForThisOrder(customer);

            var orderLine = order.AddNewOrderLine(product.Id, 10, 10, 0.5M);

            orderLine.SetProduct(product);

            //Act
            ITypeAdapter adapter  = TypeAdapterFactory.CreateAdapter();
            var          orderDTO = adapter.Adapt <Order, OrderDTO>(order);

            //Assert
            Assert.AreEqual(orderDTO.Id, order.Id);
            Assert.AreEqual(orderDTO.OrderDate, order.OrderDate);
            Assert.AreEqual(orderDTO.DeliveryDate, order.DeliveryDate);

            Assert.AreEqual(orderDTO.ShippingAddress, order.ShippingInformation.ShippingAddress);
            Assert.AreEqual(orderDTO.ShippingCity, order.ShippingInformation.ShippingCity);
            Assert.AreEqual(orderDTO.ShippingName, order.ShippingInformation.ShippingName);
            Assert.AreEqual(orderDTO.ShippingZipCode, order.ShippingInformation.ShippingZipCode);

            Assert.AreEqual(orderDTO.CustomerFullName, order.Customer.FullName);
            Assert.AreEqual(orderDTO.CustomerId, order.Customer.Id);

            Assert.AreEqual(orderDTO.OrderNumber, string.Format("{0}/{1}-{2}", order.OrderDate.Year, order.OrderDate.Month, order.SequenceNumberOrder));


            Assert.IsNotNull(orderDTO.OrderLines);
            Assert.IsTrue(orderDTO.OrderLines.Any());

            Assert.AreEqual(orderDTO.OrderLines[0].Id, orderLine.Id);
            Assert.AreEqual(orderDTO.OrderLines[0].Amount, orderLine.Amount);
            Assert.AreEqual(orderDTO.OrderLines[0].Discount, orderLine.Discount * 100);
            Assert.AreEqual(orderDTO.OrderLines[0].UnitPrice, orderLine.UnitPrice);
            Assert.AreEqual(orderDTO.OrderLines[0].TotalLine, orderLine.TotalLine);
            Assert.AreEqual(orderDTO.OrderLines[0].ProductId, product.Id);
            Assert.AreEqual(orderDTO.OrderLines[0].ProductTitle, product.Title);
        }
        private void InsertLegacySerializer(ColumnTypeCode typeCode, ITypeAdapter typeAdapter, bool reverse)
        {
            var type             = typeAdapter.GetDataType();
            var legacySerializer = new LegacyTypeSerializer(typeCode, typeAdapter, reverse);

            _primitiveSerializers[type]       = legacySerializer;
            _primitiveDeserializers[typeCode] = legacySerializer;
            _defaultTypes[typeCode]           = _ => type;
        }
 public ReleaseTextbookForQueryAppl(ITypeAdapter adapter, IStudentReleaseRecordRepository recordRepo, ITeachingTaskRepository taskRepo, IProfessionalClassRepository classRepo, IStudentRepository stuRepo, IBooksellerRepository booksellerRepo)
 {
     _adapter = adapter;
     _recordRepo = recordRepo;
     _taskRepo = taskRepo;
     _classRepo = classRepo;
     _stuRepo = stuRepo;
     _booksellerRepo = booksellerRepo;
 }
 public DropClassBookAppl(IInventoryRepository inventoryRepo, IStudentReleaseRecordRepository studentReleaseRecordRepo, ITypeAdapter typeAdapter, IInStockRecordRepository inStockRecordRepo, ITypeAdapter adapter, IProfessionalClassRepository classRepository)
 {
     _inventoryRepo            = inventoryRepo;
     _studentReleaseRecordRepo = studentReleaseRecordRepo;
     _typeAdapter       = typeAdapter;
     _inStockRecordRepo = inStockRecordRepo;
     _adapter           = adapter;
     _classRepository   = classRepository;
 }
 public DropClassBookAppl(IInventoryRepository inventoryRepo, IStudentReleaseRecordRepository studentReleaseRecordRepo, ITypeAdapter typeAdapter, IInStockRecordRepository inStockRecordRepo, ITypeAdapter adapter, IProfessionalClassRepository classRepository)
 {
     _inventoryRepo = inventoryRepo;
     _studentReleaseRecordRepo = studentReleaseRecordRepo;
     _typeAdapter = typeAdapter;
     _inStockRecordRepo = inStockRecordRepo;
     _adapter = adapter;
     _classRepository = classRepository;
 }
        /// <summary>
        /// Create a new type adapter from currect factory
        /// </summary>
        /// <returns>Created type adapter</returns>
        public static ITypeAdapter CreateAdapter()
        {
            if (currentAdapter == null)
            {
                currentAdapter = currentTypeAdapterFactory.Create();
            }

            return(currentAdapter);
        }
        /// <summary>
        /// Create a new type adapter from currect factory
        /// </summary>
        /// <returns>Created type adapter</returns>
        public static ITypeAdapter CreateAdapter()
        {
            if (currentAdapter == null)
            {
                currentAdapter = currentTypeAdapterFactory.Create();
            }

            return currentAdapter;
        }
Beispiel #21
0
 public ReleaseTextbookForQueryAppl(ITypeAdapter adapter, IStudentReleaseRecordRepository recordRepo, ITeachingTaskRepository taskRepo, IProfessionalClassRepository classRepo, IStudentRepository stuRepo, IBooksellerRepository booksellerRepo)
 {
     _adapter        = adapter;
     _recordRepo     = recordRepo;
     _taskRepo       = taskRepo;
     _classRepo      = classRepo;
     _stuRepo        = stuRepo;
     _booksellerRepo = booksellerRepo;
 }
 public ReportTemplateService(
     IUnitOfWork unitOfWork,
     ITypeAdapter typeAdapter,
     IReportTemplateRepository repository,
     IReportTemplateElementRepository reportTemplateElementRepository)
     : base(unitOfWork, typeAdapter, repository)
 {
     _reportTemplateElementRepository = reportTemplateElementRepository;
 }
Beispiel #23
0
 public TextbookAppl(
     ITypeAdapter adapter,
     ITextbookRepository bookRepo,
     IPressRepository pressRepo
     )
 {
     _adapter   = adapter;
     _bookRepo  = bookRepo;
     _pressRepo = pressRepo;
 }
 public TextbookFeeAppl(ITypeAdapter adapter, ISchoolRepository schoolRepo, IStudentRepository stuRepo, IStudentReleaseRecordRepository stuReleaseRepo, IProfessionalClassRepository proClassRepo, ITeachingTaskRepository taskRepo, IBooksellerRepository booksellerRepo)
 {
     _adapter           = adapter;
     _schoolRepo        = schoolRepo;
     _classRepo         = proClassRepo;
     _stuRepo           = stuRepo;
     _studentRecordRepo = stuReleaseRepo;
     _taskRepo          = taskRepo;
     _booksellerRepo    = booksellerRepo;
 }
 public TextbookAppl(
     ITypeAdapter adapter,
     ITextbookRepository bookRepo,
     IPressRepository pressRepo
     )
 {
     _adapter = adapter;
     _bookRepo = bookRepo;
     _pressRepo = pressRepo;
 }
 public InventoryAppl(ITypeAdapter adapter,
     IStorageRepository storage,
     IInventoryRepository inventory,
     ITextbookRepository textbook)
 {
     _adapter = adapter;
     _storageRepo = storage;
     _inventoryRepo = inventory;
     _textbookRepo = textbook;
 }
 public TextbookFeeAppl(ITypeAdapter adapter, ISchoolRepository schoolRepo, IStudentRepository stuRepo, IStudentReleaseRecordRepository stuReleaseRepo, IProfessionalClassRepository proClassRepo, ITeachingTaskRepository taskRepo, IBooksellerRepository booksellerRepo)
 {
     _adapter = adapter;
     _schoolRepo = schoolRepo;
     _classRepo = proClassRepo;
     _stuRepo = stuRepo;
     _studentRecordRepo = stuReleaseRepo;
     _taskRepo = taskRepo;
     _booksellerRepo = booksellerRepo;
 }
Beispiel #28
0
 public InventoryAppl(ITypeAdapter adapter,
                      IStorageRepository storage,
                      IInventoryRepository inventory,
                      ITextbookRepository textbook)
 {
     _adapter       = adapter;
     _storageRepo   = storage;
     _inventoryRepo = inventory;
     _textbookRepo  = textbook;
 }
 public DropStudentBookAppl(IInventoryRepository inventoryRepo, IStudentReleaseRecordRepository studentReleaseRecordRepo, ITypeAdapter typeAdapter, IInStockRecordRepository inStockRecordRepo, IBooksellerRepository booksellerRepository, ITypeAdapter adapter, IProfessionalClassRepository classRepository, IStudentRepository stuRepo)
 {
     _inventoryRepo = inventoryRepo;
     _studentReleaseRecordRepo = studentReleaseRecordRepo;
     _typeAdapter = typeAdapter;
     _inStockRecordRepo = inStockRecordRepo;
     _booksellerRepository = booksellerRepository;
     _adapter = adapter;
     _classRepository = classRepository;
     _stuRepo = stuRepo;
 }
 public DropStudentBookAppl(IInventoryRepository inventoryRepo, IStudentReleaseRecordRepository studentReleaseRecordRepo, ITypeAdapter typeAdapter, IInStockRecordRepository inStockRecordRepo, IBooksellerRepository booksellerRepository, ITypeAdapter adapter, IProfessionalClassRepository classRepository, IStudentRepository stuRepo)
 {
     _inventoryRepo            = inventoryRepo;
     _studentReleaseRecordRepo = studentReleaseRecordRepo;
     _typeAdapter          = typeAdapter;
     _inStockRecordRepo    = inStockRecordRepo;
     _booksellerRepository = booksellerRepository;
     _adapter         = adapter;
     _classRepository = classRepository;
     _stuRepo         = stuRepo;
 }
 public ReportTemplateController(
     ITypeAdapter typeAdapter,
     IUnitOfWork unitOfWork,
     UserManager <User> userManager,
     IOrganizationRoleService organizationRoleService,
     IReportTemplateService reportTemplateService)
     : base(typeAdapter, unitOfWork, userManager)
 {
     this.organizationRoleService = organizationRoleService;
     this.reportTemplateService   = reportTemplateService;
 }
Beispiel #32
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="unitOfWork"></param>
 /// <param name="typeAdapter"></param>
 /// <param name="repository"></param>
 public ReportService(
     IUnitOfWork unitOfWork,
     ITypeAdapter typeAdapter,
     IReportRepository repository,
     IReportElementRepository reportElementRepository,
     IReportManagerService reportManagerService)
     : base(unitOfWork, typeAdapter, repository)
 {
     _reportElementRepository = reportElementRepository;
     _reportManagerService    = reportManagerService;
 }
Beispiel #33
0
 protected ApplicationServiceBase(ILogger <TApplicationService> logger,
                                  ITypeAdapter <TDomainEntity, TUiDto> domainToUiDtoAdapter,
                                  ITypeAdapter <TBareDto, TDomainEntity> bareDtoToDomainAdapter,
                                  ITypeAdapter <TRuleset, TRulesDto> rulesToDtoAdapter,
                                  IDomainService <TDomainEntity, TModelEntity, TRuleset> domainService)
 {
     _logger = logger;
     _bareDtoToDomainAdapter = bareDtoToDomainAdapter;
     _rulesToDtoAdapter      = rulesToDtoAdapter;
     _domainToUiDtoAdapter   = domainToUiDtoAdapter;
     _domainService          = domainService;
 }
 protected DomainServiceBase(ILogger <TDomainService> logger,
                             ICrudService <TDomainService, TModelEntity, TContext> crudService,
                             ITypeAdapter <TDomainEntity, TModelEntity> domainToModelAdapter,
                             ITypeAdapter <TModelEntity, TDomainEntity> modelToDomainAdapter,
                             TContext context)
 {
     _logger               = logger;
     _crudService          = crudService;
     _domainToModelAdapter = domainToModelAdapter;
     _modelToDomainAdapter = modelToDomainAdapter;
     _context              = context;
 }
 public ReleaseStudentBookAppl(IStudentDeclarationRepository declarationRepository, ITypeAdapter adapter, IStudentReleaseRecordRepository studentReleaseRecordRepository, IStudentRepository studentRepository, ITeachingTaskRepository teachingTaskRepository, ITextbookRepository textbookRepository, IInventoryRepository inventoryRepository, IOutStockRecordRepository outStockRecordRepository, IBooksellerRepository booksellerRepository, IProfessionalClassRepository classRepository, IReleaseRecordRepository releaseRecordRepository, ITypeAdapter typeAdapter)
 {
     _declarationRepository = declarationRepository;
     _stuRepo = studentRepository;
     _teachingTaskRepository = teachingTaskRepository;
     _inventoryRepository = inventoryRepository;
     _outStockRecordRepository = outStockRecordRepository;
     _booksellerRepository = booksellerRepository;
     _classRepository = classRepository;
     _releaseRecordRepository = releaseRecordRepository;
     _adapter = typeAdapter;
 }
Beispiel #36
0
 public ReleaseStudentBookAppl(IStudentDeclarationRepository declarationRepository, ITypeAdapter adapter, IStudentReleaseRecordRepository studentReleaseRecordRepository, IStudentRepository studentRepository, ITeachingTaskRepository teachingTaskRepository, ITextbookRepository textbookRepository, IInventoryRepository inventoryRepository, IOutStockRecordRepository outStockRecordRepository, IBooksellerRepository booksellerRepository, IProfessionalClassRepository classRepository, IReleaseRecordRepository releaseRecordRepository, ITypeAdapter typeAdapter)
 {
     _declarationRepository = declarationRepository;
     _stuRepo = studentRepository;
     _teachingTaskRepository   = teachingTaskRepository;
     _inventoryRepository      = inventoryRepository;
     _outStockRecordRepository = outStockRecordRepository;
     _booksellerRepository     = booksellerRepository;
     _classRepository          = classRepository;
     _releaseRecordRepository  = releaseRecordRepository;
     _adapter = typeAdapter;
 }
        public void CustomerEnumerableToCustomerListDTOListAdapt()
        {
            //Arrange



            var country = new Country("Spain", "es-ES");

            country.GenerateNewIdentity();

            var address = new Address("Monforte", "27400", "AddressLine1", "AddressLine2");

            var customer = CustomerFactory.CreateCustomer("Jhon", "El rojo", "617404929", "Spirtis", country, address);
            var picture  = new Picture {
                RawPhoto = new byte[0] {
                }
            };

            customer.ChangeTheCurrentCredit(1000M);
            customer.ChangePicture(picture);
            customer.SetTheCountryForThisCustomer(country);

            IEnumerable <Customer> customers = new List <Customer>()
            {
                customer
            };

            //Act
            ITypeAdapter adapter = TypeAdapterFactory.CreateAdapter();

            var dtos = adapter.Adapt <IEnumerable <Customer>, List <CustomerListDTO> >(customers);

            //Assert

            Assert.IsNotNull(dtos);
            Assert.IsTrue(dtos.Any());
            Assert.IsTrue(dtos.Count == 1);

            CustomerListDTO dto = dtos[0];

            Assert.AreEqual(customer.Id, dto.Id);
            Assert.AreEqual(customer.FirstName, dto.FirstName);
            Assert.AreEqual(customer.LastName, dto.LastName);
            Assert.AreEqual(customer.Company, dto.Company);
            Assert.AreEqual(customer.Telephone, dto.Telephone);
            Assert.AreEqual(customer.CreditLimit, dto.CreditLimit);
            Assert.AreEqual(customer.Address.City, dto.AddressCity);
            Assert.AreEqual(customer.Address.ZipCode, dto.AddressZipCode);
            Assert.AreEqual(customer.Address.AddressLine1, dto.AddressAddressLine1);
            Assert.AreEqual(customer.Address.AddressLine2, dto.AddressAddressLine2);
        }
Beispiel #38
0
        public void MapperTest()
        {
            TypeAdapterFactory.SetCurrent(new AutomapperTypeAdapterFactory());
            ITypeAdapter adapter = TypeAdapterFactory.Create();

            Mapper.CreateMap <Usuario, UsuarioDTO>();

            var usuario = new Usuario {
                Id = 10, Nome = "Wilson Marques"
            };
            var usuarioDTO = adapter.Adapt <Usuario, UsuarioDTO>(usuario);

            Assert.IsInstanceOfType(usuarioDTO, typeof(UsuarioDTO));
            Assert.AreEqual(usuario.Id, usuarioDTO.Id);
        }
        public void BlogToBlogDTOAdapter()
        {
            //Arrange
            var blog = BlogFactory.CreateBlog("Name", "Url", 0);

            //Act
            ITypeAdapter adapter = TypeAdapterFactory.CreateAdapter();
            var          dto     = adapter.Adapt <Blog, BlogDTO>(blog);

            //Assert
            Assert.Equal(blog.BlogId, dto.BlogId);
            Assert.Equal(blog.Name, dto.Name);
            Assert.Equal(blog.Url, dto.Url);
            Assert.Equal(blog.Rating, dto.Rating);
        }
Beispiel #40
0
        public void EnumerableOrderToOrderListDTOAdapter()
        {
            //Arrange

            Customer customer = new Customer();

            customer.GenerateNewIdentity();
            customer.FirstName = "Unai";
            customer.LastName  = "Zorrilla";

            Product product = new Software("the product title", "the product description", "license code");

            product.GenerateNewIdentity();


            Order order = new Order();

            order.GenerateNewIdentity();
            order.OrderDate           = DateTime.Now;
            order.ShippingInformation = new ShippingInfo("shippingName", "shippingAddress", "shippingCity", "shippingZipCode");
            order.SetTheCustomerForThisOrder(customer);

            var line = order.AddNewOrderLine(product.Id, 1, 200, 0);


            var orders = new List <Order>()
            {
                order
            };

            //Act
            ITypeAdapter adapter      = TypeAdapterFactory.CreateAdapter();
            var          orderListDTO = adapter.Adapt <IEnumerable <Order>, List <OrderListDTO> >(orders);

            //Assert
            Assert.AreEqual(orderListDTO[0].Id, order.Id);
            Assert.AreEqual(orderListDTO[0].OrderDate, order.OrderDate);
            Assert.AreEqual(orderListDTO[0].DeliveryDate, order.DeliveryDate);
            Assert.AreEqual(orderListDTO[0].TotalOrder, order.GetOrderTotal());

            Assert.AreEqual(orderListDTO[0].ShippingAddress, order.ShippingInformation.ShippingAddress);
            Assert.AreEqual(orderListDTO[0].ShippingCity, order.ShippingInformation.ShippingCity);
            Assert.AreEqual(orderListDTO[0].ShippingName, order.ShippingInformation.ShippingName);
            Assert.AreEqual(orderListDTO[0].ShippingZipCode, order.ShippingInformation.ShippingZipCode);

            Assert.AreEqual(orderListDTO[0].CustomerFullName, order.Customer.FullName);
            Assert.AreEqual(orderListDTO[0].CustomerId, order.Customer.Id);
        }
        //the customer repository
        /// <summary>
        /// Create a new instance of Customer Management Service
        /// </summary>
        /// <param name="typesAdapter">Associated TypesAdapter, intented to ve resolved with DI</param>
        /// <param name="customerRepository">Associated CustomerRepository, intented to be resolved with DI</param>
        /// <param name="countryRepository">Associated country repository</param>
        public CustomerAppService(ITypeAdapter typesAdapter, // the types adatper
            ICountryRepository countryRepository, //the country repository
            ICustomerRepository customerRepository)
        {
            if (customerRepository == null)
                throw new ArgumentNullException("customerRepository");

            if (countryRepository == null)
                throw new ArgumentNullException("countryRepository");

            if (typesAdapter == null)
                throw new ArgumentNullException("typesAdapter");

            _typesAdapter = typesAdapter;
            _countryRepository = countryRepository;
            _customerRepository = customerRepository;
        }
        private readonly ITeacherDeclarationRepository _teaDeclRepo; // = ServiceLocator.Current.GetInstance<ITeacherDeclarationRepository>();

        #endregion Fields

        #region Constructors

        public SubscriptionAppl(ITypeAdapter adapter,
            IStudentDeclarationJiaoWuRepository stuDeclJiaoWuRepo,
            ITeacherDeclarationJiaoWuRepository teaDeclJiaoWuRepo,
            IStudentDeclarationRepository stuDeclRepo,
            ITeacherDeclarationRepository teaDeclRepo,
            ISubscriptionRepository subscriptionRepo,
            IRepositoryContext context
            )
        {
            _adapter = adapter;
            _stuDeclRepo = stuDeclRepo;
            _teaDeclRepo = teaDeclRepo;
            _stuDeclJiaoWuRepo = stuDeclJiaoWuRepo;
            _teaDeclJiaoWuRepo = teaDeclJiaoWuRepo;
            _subscriptionRepo = subscriptionRepo;
            _contextForUpdate = context;
        }
        public void Initialize()
        {
            _context = new EntityFrameworkRepositoryContext();
            _trans = new TransactionScope();

            _adapter = new AutoMapperTypeAdapter();
            _stuDeclJiaoWuRepo = new StudentDeclarationJiaoWuRepository(_context);
            _teaDeclJiaoWuRepo = new TeacherDeclarationJiaoWuRepository(_context);
            _stuDeclRepo = new StudentDeclarationRepository(_context);
            _teaDeclRepo = new TeacherDeclarationRepository(_context);
            _subscriptionRepo = new SubscriptionRepository(_context);

            _appl = new SubscriptionAppl(
                _adapter,
                _stuDeclJiaoWuRepo,
                _teaDeclJiaoWuRepo,
                _stuDeclRepo,
                _teaDeclRepo,
                _subscriptionRepo
                );
        }
        //the associated order repository
        /// <summary>
        /// Create a new instance of sales management service
        /// </summary>
        /// <param name="typeAdapter">The type adapter to use</param>
        /// <param name="orderRepository">The associated order repository</param>
        /// <param name="productRepository">The associated product repository</param>
        public SalesAppService(ITypeAdapter typeAdapter, //the type adapter
            IProductRepository productRepository,//associated product repository
            IOrderRepository orderRepository,
            ICustomerRepository customerRepository)
        {
            if (typeAdapter == null)
                throw new ArgumentNullException("typeAdapter");

            if (orderRepository == null)
                throw new ArgumentNullException("orderRepository");

            if (productRepository == null)
                throw new ArgumentNullException("productRepository");

            if (customerRepository == null)
                throw new ArgumentNullException("customerRepository");

            _typeAdapter = typeAdapter;
            _orderRepository = orderRepository;
            _productRepository = productRepository;
            _customerRepository = customerRepository;
        }
        // the entities - dto adapters
        /// <summary>
        /// Create a new instance 
        /// </summary>
        public BankAppService(IBankAccountRepository bankAccountRepository, // the bank account repository dependency
            ICustomerRepository customerRepository, // the customer repository dependency
            IBankTransferService transferService, // bank transfer domain services
            ITypeAdapter adapter)
        {
            //check preconditions
            if (bankAccountRepository == null)
                throw new ArgumentNullException("bankAccountRepository");

            if (customerRepository == null)
                throw new ArgumentNullException("customerRepository");

            if (adapter == null)
                throw new ArgumentNullException("adapter");

            if (transferService == null)
                throw new ArgumentNullException("trasferService");

            _bankAccountRepository = bankAccountRepository;
            _customerRepository = customerRepository;
            _adapter = adapter;
            _transferService = transferService;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RESTEmployeeService"/> class.
 /// </summary>
 public RESTEmployeeService()
 {
     this.ebo = ServiceFactory.GetInstance<IEmployeeBusinessObject>("NoOLazyloadedAndProxyCreated");
     this.enityadapter = new EmployeeAdapter();
 }
 public CasMapperAppl(ITypeAdapter adapter, ICasMapperRepository casRepo, ITbmisUserRepository userRepo)
 {
     _adapter = adapter;
     _casRepo = casRepo;
     _userRepo = userRepo;
 }
 public DeclarationQueryAppl(ITypeAdapter adapter, IStudentDeclarationJiaoWuRepository studentRepo, ITeacherDeclarationJiaoWuRepository teacherRepo)
 {
     _adapter = adapter;
     _studentRepo = studentRepo;
     _teacherRepo = teacherRepo;
 }
 public TextbookApprovalAppl(ITypeAdapter adapter, ITextbookRepository textbookRepo)
 {
     _adapter = adapter;
     _textbookRepo = textbookRepo;
 }
 public void BeginCustomerAppService()
 {
     typeAdapter = new TypeAdapter(new RegisterTypesMap[] { new  ModuleRegisterTypesMap() });
 }
 public StorageAppl(ITypeAdapter adapter, IStorageRepository repo)
 {
     _adapter = adapter;
     _repo = repo;
 }
 public FeedbackApprovalAppl(ITypeAdapter adapter, IFeedbackRepository repo)
 {
     _adapter = adapter;
     _repo = repo;
 }
        private readonly ISchoolRepository _schoolRepo; //= ServiceLocator.Current.GetInstance<ITeachingTaskRepository>();

        #endregion Fields

        #region Constructors

        public DeclarationProgressAppl(ITypeAdapter adapter, ISchoolRepository schoolRepo, IDepartmentRepository departRepo)
        {
            _adapter = adapter;
            _schoolRepo = schoolRepo;
            _departRepo = departRepo;
        }
 /// <summary>
 /// Map Dto with entity objects
 /// </summary>
 private void PrepareTypeAdapter()
 {
     this.userTypeAdapter = new TypeAdapter(new RegisterTypesMap[] { new UserRegisterTypesMap() });
 }
 public DeclarationApprovalAppl(ITypeAdapter adapter, IDeclarationRepository declRepo)
 {
     _adapter = adapter;
     _declRepo = declRepo;
 }
 internal LegacyTypeSerializer(ColumnTypeCode typeCode, ITypeAdapter adapter, bool reverse)
 {
     _typeCode = typeCode;
     _adapter = adapter;
     _reverse = reverse;
 }
        private readonly ISubscriptionRepository _subscriptionRepo; //= ServiceLocator.Current.GetInstance<ISubscriptionRepository>();

        #endregion Fields

        #region Constructors

        public FeedbackAppl(ITypeAdapter adapter, ISubscriptionRepository subscriptionRepo)
        {
            _adapter = adapter;
            _subscriptionRepo = subscriptionRepo;
        }
Beispiel #58
0
 private void InsertLegacySerializer(ColumnTypeCode typeCode, ITypeAdapter typeAdapter, bool reverse)
 {
     var type = typeAdapter.GetDataType();
     var legacySerializer = new LegacyTypeSerializer(typeCode, typeAdapter, reverse);
     _primitiveSerializers[type] = legacySerializer;
     _primitiveDeserializers[typeCode] = legacySerializer;
     _defaultTypes[typeCode] = _ => type;
 }
 public BannerFacade(IUnitOfWork uow, IBannerRepository bannerRepository, ITypeAdapter typeAdapter)
 {
     _uow = uow;
     _bannerRepository = bannerRepository;
     _typeAdapter = typeAdapter;
 }