Example #1
0
        public OrderServiceTest()
        {
            IEsnecilGeneratorResource esnecilGeneratorFile = new EsnecilGeneratorFile();

            var dbContext = Db.GetContext();

            _repository       = new Repository(dbContext);
            _invoiceManager   = new InvoiceManager(_repository);
            _esnecilGenerator = new TrialEsnecilGenerator(esnecilGeneratorFile);

            _orderService        = new OrderService(_repository, _invoiceManager, _esnecilGenerator);
            _productPriceService = new ProductPriceService(_repository);

            //CreateOrder();
            CreateProducts();
            CreateProductPrices();
        }
Example #2
0
        public OrderService(IRepository repository, IInvoiceManager invoiceManager, EsnecilGeneratorBase esnecilGenerator)
        {
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }
            if (esnecilGenerator == null)
            {
                throw new ArgumentNullException("esnecilGenerator");
            }
            if (invoiceManager == null)
            {
                throw new ArgumentNullException("invoiceManager");
            }

            _repository       = repository;
            _esnecilGenerator = esnecilGenerator;
            _invoiceManager   = invoiceManager;
        }
Example #3
0
        public void GenerateLicense_Should_GenerateEsnecilSerialNoAndCode_WhenValidGeneratorFileAndCustomerInfoIsSet()
        {
            //Dictionary<string, string> customerInfo = new Dictionary<string, string>();
            //customerInfo.Add("Email", "*****@*****.**");
            //customerInfo.Add("Name", "Akuabata Egenti");
            //customerInfo.Add("Phone", "09087651122");
            //customerInfo.Add("Address", "99 Opebi road, Ikeja Lagos");
            //customerInfo.Add("CodeID", "109930");

            Dictionary <string, string> customerInfo = new Dictionary <string, string>
            {
                { "Email", "*****@*****.**" },
                { "Name", "Akuabata Egenti" },
                { "Phone", "09087651122" },
                { "Address", "99 Opebi road, Ikeja Lagos" },
                { "CodeID", "109930" }
            };

            //var discountsDictionary = new Dictionary<AccountStatus, IAccountDiscountCalculator>
            //  {
            //    {AccountStatus.NotRegistered, new NotRegisteredDiscountCalculator()},
            //    {AccountStatus.SimpleCustomer, new SimpleCustomerDiscountCalculator()},
            //    {AccountStatus.ValuableCustomer, new ValuableCustomerDiscountCalculator()},
            //    {AccountStatus.MostValuableCustomer, new MostValuableCustomerDiscountCalculator()}
            //};

            IEsnecilGeneratorResource esnecilGeneratorFile = new EsnecilGeneratorFile();
            IEsnecilGeneratorFactory  generatorFactory     = new EsnecilGeneratorFactory(esnecilGeneratorFile);
            EsnecilGeneratorBase      generator            = generatorFactory.Create(EsnecilType.Trial);
            RawEsnecil esnecil = generator.GenerateLicense(customerInfo);

            //RawEsnecil esnecil = generator.GenerateLicense(filePath, customerInfo);

            Assert.NotNull(esnecil);
            Assert.NotNull(esnecil.SerialCode);
            Assert.NotNull(esnecil.EsnecilCode);
            Assert.True(esnecil.GeneratedOn.Date == DateTime.Today.Date);
            Assert.True(esnecil.SerialCode.Length > 5);
            Assert.True(esnecil.EsnecilCode.Length > 5);
            Assert.True(esnecil.DetectDateRollback);
            Assert.True(esnecil.EnableTamperChecking);
            Assert.Equal(1, esnecil.NoOfUsers);
        }