public void SetUp() { _customerDt = new CustomerDt(); _companySettings = new SalesSettings(); _mockedCompany = new Mock <ICompany>(); _mockedCustomer = new Mock <ICustomer>(); _mockedCompanySalesTransactions = new Mock <IGetSalesSettings>(); _mockedCustomerRetriever = new Mock <ICustomerRetriever>(); _mockedCompanySalesTransactions.Setup(x => x.Get()).Returns(_companySettings); _mockedCustomerRetriever.Setup(x => x.GetCustomer(It.IsAny <string>())).Returns(_customerDt); _mockedCustomerBuilder = new Mock <CustomerBuilder>(); _mockedCustomerBuilder.Setup(x => x.InstantiateCompany(_companySettings)).Returns(_mockedCompany.Object); _mockedCustomerBuilder.Setup(x => x.InstantiateCustomer(_customerDt, It.IsAny <ICompany>())).Returns(_mockedCustomer.Object); IKernel kernel = new StandardKernel(); kernel.Bind <IGetSalesSettings>().ToConstant(_mockedCompanySalesTransactions.Object); kernel.Bind <ICustomerRetriever>().ToConstant(_mockedCustomerRetriever.Object); NinjectDependencyInjector.Instance.Initialize(kernel); _customerBuilder = _mockedCustomerBuilder.Object; }
private void AddSalesSettings(XElement root, SectionId sectionId) { string nodeName = sectionId.ToString(); var defaultPrice = XmlParseHelper.Get <decimal>(root, "Payment", "Settings", nodeName, "DefaultPrice"); Dictionary <string, decimal> pricesByNames = XmlParseHelper.GetDictionary <string, decimal>(root, "Payment", "Settings", nodeName, "PriceByName"); Dictionary <long, decimal> pricesByIds = XmlParseHelper.GetDictionary <long, decimal>(root, "Payment", "Settings", nodeName, "PriceById"); var discount = XmlParseHelper.Get <decimal>(root, "Payment", "Settings", nodeName, "Discount"); var summDiscountPrice = XmlParseHelper.Get <decimal>(root, "Payment", "Settings", nodeName, "SummDiscountPrice"); var salesSettings = new SalesSettings(defaultPrice, pricesByNames, pricesByIds) { Discount = discount, SummDiscountPrice = summDiscountPrice }; if (salesSettings.IsInvalid) { return; } _salesSettings.Add(sectionId, salesSettings); }
public Company(SalesSettings company) { _company = company; }
internal virtual ICompany InstantiateCompany(SalesSettings company) { return(new Company(company)); }