public void SoftwareToSoftwareDTOAdapter()
        {
            //Arrange
            var software = new Software("the title", "The description","AB001");
            software.ChangeUnitPrice(10);
            software.IncrementStock(10);
            software.GenerateNewIdentity();
            //Act
            ITypeAdapter adapter = TypeAdapterFactory.CreateAdapter();
            var softwareDTO = adapter.Adapt<Software, SoftwareDTO>(software);

            //Assert
            Assert.AreEqual(software.Id, softwareDTO.Id);
            Assert.AreEqual(software.Title, softwareDTO.Title);
            Assert.AreEqual(software.Description, softwareDTO.Description);
            Assert.AreEqual(software.AmountInStock, softwareDTO.AmountInStock);
            Assert.AreEqual(software.UnitPrice, softwareDTO.UnitPrice);
            Assert.AreEqual(software.LicenseCode, softwareDTO.LicenseCode);
        }
        public void ProductToProductDTOAdapter()
        {
            //Arrange
            var product = new Software("the title", "The description","AB001");
            product.ChangeUnitPrice(10);
            product.IncrementStock(10);
            product.GenerateNewIdentity();

            //Act
            ITypeAdapter adapter = TypeAdapterFactory.CreateAdapter();
            var productDTO = adapter.Adapt<Product, ProductDTO>(product);

            //Assert
            Assert.AreEqual(product.Id, productDTO.Id);
            Assert.AreEqual(product.Title, productDTO.Title);
            Assert.AreEqual(product.Description, productDTO.Description);
            Assert.AreEqual(product.AmountInStock, productDTO.AmountInStock);
            Assert.AreEqual(product.UnitPrice, productDTO.UnitPrice);
        }
        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);
        }
        /// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService"/>
        /// </summary>
        /// <param name="softwareDTO"><see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService"/></param>
        public SoftwareDTO AddNewSoftware(SoftwareDTO softwareDTO)
        {
            if (softwareDTO == null)
                throw new ArgumentException(Messages.warning_CannotAddSoftwareWithNullInformation);

            //Create the softare entity
            var newSoftware = new Software(softwareDTO.Title, softwareDTO.Description,softwareDTO.LicenseCode);

            //set unit price and stock
            newSoftware.ChangeUnitPrice(softwareDTO.UnitPrice);
            newSoftware.IncrementStock(softwareDTO.AmountInStock);

            //Assign the poid
            newSoftware.GenerateNewIdentity();

            //save software
            SaveProduct(newSoftware);

            //return software dto
            return newSoftware.ProjectedAs<SoftwareDTO>();
        }