Exemple #1
0
        public async Task CreateNewCatalog(int companyId, int sourceCatalogId, CatalogModel resellerCatalogModel)
        {
            var company = await _dbContext.Companies.Include(c => c.CompanyCatalogs.Select(cc => cc.Catalog.CatalogProductItems.Select(cpi => cpi.ProductItem))).FirstOrDefaultAsync(c => c.Id == companyId);

            if (company == null)
            {
                throw new CompanyNotFoundException($"CompanyId: {companyId}");
            }

            var sourceCompanyCatalog = company.CompanyCatalogs.FirstOrDefault(cc =>
                                                                              cc.CatalogType == CatalogType.MyCatalog && cc.CatalogId == sourceCatalogId);

            if (sourceCompanyCatalog == null)
            {
                throw new NonExistingCompanyCatalogException($"CompanyId {companyId}, CatalogId {sourceCatalogId}");
            }

            var newCatalog = new Entities.Catalog.Catalog
            {
                Name        = resellerCatalogModel.Name,
                Description = resellerCatalogModel.Description
            };

            sourceCompanyCatalog.Catalog.CatalogProductItems.ForEach(productItem =>
            {
                newCatalog.CatalogProductItems.Add(new CatalogProductItem
                {
                    Catalog          = newCatalog,
                    ProductItem      = productItem.ProductItem,
                    RetailPrice      = productItem.RetailPrice,
                    ResellerPrice    = productItem.ResellerPrice,
                    FixedRetailPrice = productItem.FixedRetailPrice,
                    Available        = productItem.Available
                });
            });

            _dbContext.Catalogs.Add(newCatalog);
            _dbContext.CompanyCatalogs.Add(new CompanyCatalog
            {
                Catalog     = newCatalog,
                Company     = company,
                CatalogType = CatalogType.MyCatalog
            });

            foreach (var assignedCompanies in resellerCatalogModel.CompaniesAssignedToCatalog)
            {
                await AssignCatalogToCompany(companyId, assignedCompanies.CompanyId, newCatalog.Id);
            }

            await _dbContext.SaveChangesAsync();
        }
Exemple #2
0
        public async Task GenerateDefaultCompanyCatalog(int companyId)
        {
            var company = await _dbContext.Companies.Include(c => c.CompanyCatalogs.Select(cc => cc.Catalog.CatalogProductItems)).FirstOrDefaultAsync(c => c.Id == companyId);

            if (company == null)
            {
                throw new CompanyNotFoundException($"CompanyId: {companyId}");
            }

            if (company.CompanyCatalogs.Any(cc => cc.CatalogType == CatalogType.MyCatalog))
            {
                throw new Exception($"Default catalog for company {companyId} already exists");
            }

            var assignedCompanyCatalog = company.CompanyCatalogs.FirstOrDefault(cc => cc.CatalogType == CatalogType.Assigned);

            if (assignedCompanyCatalog == null)
            {
                throw new NoAssignedCatalogException($"CompanyId: {companyId}");
            }

            var newCatalog = new Entities.Catalog.Catalog
            {
                Name = "Default Price Schedule"
            };

            foreach (var catalogProduct in assignedCompanyCatalog.Catalog.CatalogProductItems.Where(p => p.Available))
            {
                newCatalog.CatalogProductItems.Add(new CatalogProductItem
                {
                    FixedRetailPrice = catalogProduct.FixedRetailPrice,
                    RetailPrice      = catalogProduct.RetailPrice,
                    ProductItemId    = catalogProduct.ProductItemId,
                    ResellerPrice    = _catalogUtilities.CalculateResellerPrice(catalogProduct.RetailPrice, catalogProduct.ResellerPrice),
                    Available        = catalogProduct.Available
                });
            }

            _dbContext.Catalogs.Add(newCatalog);

            company.CompanyCatalogs.Add(new CompanyCatalog
            {
                Catalog     = newCatalog,
                CatalogType = CatalogType.MyCatalog,
                Default     = true
            });

            await _dbContext.SaveChangesAsync();
        }
Exemple #3
0
        public void Setup()
        {
            #region Companies
            var masterCompany = new Entities.Company
            {
                Id     = 1,
                Name   = "Master Company",
                Parent = null
            };

            var firstChildOfMaster = new Entities.Company
            {
                Id     = 2,
                Name   = "First Child of Master Company",
                Parent = masterCompany
            };

            var secondChildOfMaster = new Entities.Company
            {
                Id     = 3,
                Name   = "Second Child of Master Company",
                Parent = masterCompany
            };

            masterCompany.MyCompanies = new List <Entities.Company> {
                firstChildOfMaster, secondChildOfMaster
            };

            var firstChildsFirstChild = new Entities.Company
            {
                Id     = 4,
                Name   = "First Child's First Child",
                Parent = firstChildOfMaster
            };

            var firstChildsSecondChild = new Entities.Company
            {
                Id     = 5,
                Name   = "First Child's Second Child",
                Parent = firstChildOfMaster
            };

            firstChildOfMaster.MyCompanies = new List <Entities.Company> {
                firstChildsFirstChild, firstChildsSecondChild
            };

            #endregion

            #region Catalogs
            var defaultCatalog = new Entities.Catalog.Catalog
            {
                Id   = 1,
                Name = "Default Catalog",
            };

            var masterAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 2,
                Name = "Master's Assignable Catalog",
            };

            var firstChildsFirstAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 3,
                Name = "First Child's First Assignable Catalog",
            };

            var firstChildsSecondAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 4,
                Name = "First Child's Second Assignable Catalog",
            };

            var secondChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 5,
                Name = "Second Child's Assignable Catalog",
            };

            var firstChildsFirstChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 6,
                Name = "First Child's First Child's Assignable Catalog",
            };

            var firstChildsSecondChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 7,
                Name = "First Child's Second Child's Assignable Catalog",
            };
            #endregion

            #region Company Catalogs
            masterCompany.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = defaultCatalog,
                    CatalogId   = 1,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = masterAssignableCatalog,
                    CatalogId   = 2,
                    CatalogType = CatalogType.MyCatalog,
                }
            };

            firstChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = defaultCatalog,
                    CatalogId   = 1,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstAssignableCatalog,
                    CatalogId   = 3,
                    CatalogType = CatalogType.MyCatalog,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsSecondAssignableCatalog,
                    CatalogId   = 4,
                    CatalogType = CatalogType.MyCatalog,
                }
            };

            secondChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = masterAssignableCatalog,
                    CatalogId   = 2,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = secondChildsAssignableCatalog,
                    CatalogId   = 5,
                    CatalogType = CatalogType.MyCatalog,
                },
            };

            firstChildsFirstChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstAssignableCatalog,
                    CatalogId   = 3,
                    CatalogType = CatalogType.MyCatalog,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstChildsAssignableCatalog,
                    CatalogId   = 6,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            firstChildsSecondChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstAssignableCatalog,
                    CatalogId   = 3,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsSecondChildsAssignableCatalog,
                    CatalogId   = 7,
                    CatalogType = CatalogType.MyCatalog,
                },
            };

            #endregion

            var companies = new List <Entities.Company>
            {
                masterCompany,
                firstChildOfMaster,
                firstChildsFirstChild,
                firstChildsSecondChild,
                secondChildOfMaster,
            };

            var companiesDbSet = MockSetGenerator.CreateAsyncMockSet(companies);
            var dbContextMock  = new Mock <CldpDbContext>();
            dbContextMock.Setup(c => c.Companies).Returns(companiesDbSet);

            var catalogUtilitiesMock = new Mock <ICatalogUtilities>();

            var catalogProductItemServiceMock = new Mock <ICatalogProductItemService>();

            _sut = new Database.Catalog.CompanyCatalogService(dbContextMock.Object, catalogProductItemServiceMock.Object, catalogUtilitiesMock.Object);
        }
Exemple #4
0
        public void Setup()
        {
            // companies
            var masterCompany = new Entities.Company
            {
                Id     = 1,
                Name   = "Master Company",
                Parent = null
            };

            var firstChildOfMaster = new Entities.Company
            {
                Id     = 2,
                Name   = "First Child of Master Company",
                Parent = masterCompany
            };

            var secondChildOfMaster = new Entities.Company
            {
                Id     = 3,
                Name   = "Second Child of Master Company",
                Parent = masterCompany
            };

            masterCompany.MyCompanies = new List <Entities.Company> {
                firstChildOfMaster, secondChildOfMaster
            };

            var firstChildsFirstChild = new Entities.Company
            {
                Id     = 4,
                Name   = "First Child's First Child",
                Parent = firstChildOfMaster
            };

            var firstChildsSecondChild = new Entities.Company
            {
                Id     = 5,
                Name   = "First Child's Second Child",
                Parent = firstChildOfMaster
            };

            firstChildOfMaster.MyCompanies = new List <Entities.Company> {
                firstChildsFirstChild, firstChildsSecondChild
            };

            var secondChildsFirstChild = new Entities.Company
            {
                Id     = 6,
                Name   = "Second Child's First Child",
                Parent = secondChildOfMaster
            };

            var secondChildsSecondChild = new Entities.Company
            {
                Id     = 7,
                Name   = "Second Child's Second Child",
                Parent = secondChildOfMaster
            };

            secondChildOfMaster.MyCompanies = new List <Entities.Company> {
                secondChildsFirstChild, secondChildsSecondChild
            };

            var firstGrandGrandChildOfMaster = new Entities.Company
            {
                Id     = 8,
                Name   = "Grand Child of Master's First Child",
                Parent = firstChildsFirstChild
            };

            firstChildsFirstChild.MyCompanies = new List <Entities.Company> {
                firstGrandGrandChildOfMaster
            };

            var secondGrandGrandChildOfMaster = new Entities.Company
            {
                Id     = 9,
                Name   = "Grand Child of Master's Second Child",
                Parent = secondChildsFirstChild
            };

            secondChildsFirstChild.MyCompanies = new List <Entities.Company> {
                secondGrandGrandChildOfMaster
            };

            // product items

            var firstProductItem = new Entities.Catalog.ProductItem
            {
                Id   = 1,
                Name = "First Product Item"
            };

            var secondProductItem = new Entities.Catalog.ProductItem
            {
                Id   = 2,
                Name = "Second Product Item"
            };

            var thirdProductItem = new Entities.Catalog.ProductItem
            {
                Id   = 3,
                Name = "Third Product Item"
            };

            // catalogs

            var defaultCatalog = new Entities.Catalog.Catalog
            {
                Id   = 1,
                Name = "Default Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 10
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 20
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 30
                    }
                }
            };

            var masterAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 2,
                Name = "Master's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 5
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 10
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 15
                    }
                }
            };

            var firstChildsFirstAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 3,
                Name = "First Child's First Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 15
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 30
                    },
                }
            };

            var firstChildsSecondAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 4,
                Name = "First Child's Second Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 1
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 2
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 3
                    }
                }
            };

            var secondChildsFirstAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 5,
                Name = "Second Child's First Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 3
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 6
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 9
                    }
                }
            };

            var firstChildsFirstChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 6,
                Name = "First Child's First Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 2
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 4
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 6
                    }
                }
            };

            var firstChildsSecondChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 7,
                Name = "First Child's Second Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 4
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 8
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 12
                    }
                }
            };

            var secondChildsFirstChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 8,
                Name = "Second Child's First Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 6
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 12
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 18
                    }
                }
            };

            var secondChildsSecondChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 9,
                Name = "Second Child's Second Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 12
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 24
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 32
                    }
                }
            };

            var firstGrandGrandChildOfMasterAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 10,
                Name = "First Grand Grand Child of Master's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 11
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 22
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 33
                    }
                }
            };

            var secondGrandGrandChildOfMasterAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 11,
                Name = "Second Grand Grand Child of Master's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        ProductItem      = firstProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 21
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        ProductItem      = secondProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 22
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        ProductItem      = thirdProductItem,
                        FixedRetailPrice = false,
                        RetailPrice      = 23
                    }
                }
            };


            // company catalogs

            masterCompany.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = defaultCatalog,
                    CatalogId   = 1,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = masterAssignableCatalog,
                    CatalogId   = 2,
                    CatalogType = CatalogType.MyCatalog,
                }
            };

            firstChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = defaultCatalog,
                    CatalogId   = 1,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstAssignableCatalog,
                    CatalogId   = 3,
                    CatalogType = CatalogType.MyCatalog,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsSecondAssignableCatalog,
                    CatalogId   = 4,
                    CatalogType = CatalogType.MyCatalog,
                }
            };
            firstChildsFirstChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstAssignableCatalog,
                    CatalogId   = 3,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstChildsAssignableCatalog,
                    CatalogId   = 6,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            firstChildsSecondChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstAssignableCatalog,
                    CatalogId   = 3,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsSecondChildsAssignableCatalog,
                    CatalogId   = 7,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            firstGrandGrandChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstChildsAssignableCatalog,
                    CatalogId   = 6,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstGrandGrandChildOfMasterAssignableCatalog,
                    CatalogId   = 10,
                    CatalogType = CatalogType.MyCatalog,
                },
            };

            secondChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = masterAssignableCatalog,
                    CatalogId   = 2,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstAssignableCatalog,
                    CatalogId   = 5,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            secondChildsFirstChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstAssignableCatalog,
                    CatalogId   = 5,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstChildsAssignableCatalog,
                    CatalogId   = 8,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            secondChildsSecondChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstAssignableCatalog,
                    CatalogId   = 5,
                    CatalogType = CatalogType.MyCatalog,
                },
                new CompanyCatalog
                {
                    Catalog     = secondChildsSecondChildsAssignableCatalog,
                    CatalogId   = 9,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            secondGrandGrandChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstChildsAssignableCatalog,
                    CatalogId   = 8,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = secondGrandGrandChildOfMasterAssignableCatalog,
                    CatalogId   = 11,
                    CatalogType = CatalogType.MyCatalog,
                },
            };

            var companies = new List <Entities.Company>
            {
                masterCompany,
                firstChildOfMaster,
                firstChildsFirstChild,
                firstGrandGrandChildOfMaster,
                firstChildsSecondChild,
                secondChildOfMaster,
                secondChildsFirstChild,
                secondGrandGrandChildOfMaster,
                secondChildsSecondChild
            };

            _companiesDbSet = MockSetGenerator.CreateAsyncMockSet(companies);
            _dbContextMock  = new Mock <CldpDbContext>();
            _dbContextMock.Setup(c => c.Companies).Returns(_companiesDbSet);

            var catalogUtilitiesMock = new Mock <ICatalogUtilities>();

            _sut = new Database.Catalog.CatalogProductItemService(_dbContextMock.Object, catalogUtilitiesMock.Object);
        }
Exemple #5
0
        public void Setup()
        {
            // companies
            var firstCompany = new Entities.Company
            {
                Id   = 1,
                Name = "Master Company",
            };

            var secondCompany = new Entities.Company
            {
                Id   = 2,
                Name = "Second Company",
            };

            var thirdCompany = new Entities.Company
            {
                Id   = 3,
                Name = "Third Company",
            };

            // catalogs

            var firstCatalog = new Entities.Catalog.Catalog
            {
                Id   = 1,
                Name = "First Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId = 1,
                        ResellerPrice = 10
                    },
                    new CatalogProductItem
                    {
                        ProductItemId = 2,
                        ResellerPrice = 20
                    },
                    new CatalogProductItem
                    {
                        ProductItemId = 3,
                        ResellerPrice = 30
                    }
                }
            };

            var secondCatalog = new Entities.Catalog.Catalog
            {
                Id   = 2,
                Name = "Second Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId = 1,
                        ResellerPrice = 5
                    },
                    new CatalogProductItem
                    {
                        ProductItemId = 2,
                        ResellerPrice = 10
                    },
                    new CatalogProductItem
                    {
                        ProductItemId = 3,
                        ResellerPrice = 15
                    }
                }
            };

            var thirdCatalog = new Entities.Catalog.Catalog
            {
                Id   = 3,
                Name = "Third Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId = 1,
                        ResellerPrice = 15
                    },
                    new CatalogProductItem
                    {
                        ProductItemId = 2,
                        ResellerPrice = 30
                    },
                }
            };

            // company catalogs

            firstCompany.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog   = firstCatalog,
                    CatalogId = 1,
                },
                new CompanyCatalog
                {
                    Catalog   = secondCatalog,
                    CatalogId = 2,
                },
                new CompanyCatalog
                {
                    Catalog   = thirdCatalog,
                    CatalogId = 3,
                }
            };

            var companies = new List <Entities.Company>
            {
                firstCompany,
                secondCompany,
                thirdCompany,
            };

            _companiesDbSet = MockSetGenerator.CreateAsyncMockSet(companies);
            _dbContextMock  = new Mock <CldpDbContext>();
            _dbContextMock.Setup(c => c.Companies).Returns(_companiesDbSet);

            var catalogUtilitiesMock = new Mock <ICatalogUtilities>();

            _sut = new Database.Catalog.CatalogProductItemService(_dbContextMock.Object, catalogUtilitiesMock.Object);
        }
Exemple #6
0
        public void Setup()
        {
            #region Companies
            var masterCompany = new Entities.Company
            {
                Id     = 1,
                Name   = "Master Company",
                Parent = null
            };

            var firstChildOfMaster = new Entities.Company
            {
                Id     = 2,
                Name   = "First Child of Master Company",
                Parent = masterCompany
            };

            var secondChildOfMaster = new Entities.Company
            {
                Id     = 3,
                Name   = "Second Child of Master Company",
                Parent = masterCompany
            };

            masterCompany.MyCompanies = new List <Entities.Company> {
                firstChildOfMaster, secondChildOfMaster
            };

            var firstChildsFirstChild = new Entities.Company
            {
                Id     = 4,
                Name   = "First Child's First Child",
                Parent = firstChildOfMaster
            };

            var firstChildsSecondChild = new Entities.Company
            {
                Id     = 5,
                Name   = "First Child's Second Child",
                Parent = firstChildOfMaster
            };

            firstChildOfMaster.MyCompanies = new List <Entities.Company> {
                firstChildsFirstChild, firstChildsSecondChild
            };

            #endregion

            #region Catalogs
            var defaultCatalog = new Entities.Catalog.Catalog
            {
                Id   = 1,
                Name = "Default Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        Available        = true,
                        FixedRetailPrice = true,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 4,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    }
                }
            };

            var masterFirstAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 2,
                Name = "Master's First Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        Available        = true,
                        FixedRetailPrice = true,
                        RetailPrice      = 11,
                        ResellerPrice    = 6,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 11,
                        ResellerPrice    = 6,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 11,
                        ResellerPrice    = 6,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 4,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 11,
                        ResellerPrice    = 6,
                    }
                }
            };

            var masterSecondAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 8,
                Name = "Master's Second Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        Available        = true,
                        FixedRetailPrice = true,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        Available        = false,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 4,
                        Available        = false,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    }
                }
            };

            var firstChildsFirstAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 3,
                Name = "First Child's First Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        Available        = true,
                        FixedRetailPrice = true,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 4,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    }
                }
            };

            var firstChildsSecondAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 4,
                Name = "First Child's Second Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 4,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    }
                }
            };

            var secondChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 5,
                Name = "Second Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        Available        = true,
                        FixedRetailPrice = true,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 4,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    }
                }
            };

            var firstChildsFirstChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 6,
                Name = "First Child's First Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        Available        = true,
                        FixedRetailPrice = true,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 4,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    }
                }
            };

            var firstChildsSecondChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 7,
                Name = "First Child's Second Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    new CatalogProductItem
                    {
                        ProductItemId    = 1,
                        Available        = true,
                        FixedRetailPrice = true,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 2,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 3,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    },
                    new CatalogProductItem
                    {
                        ProductItemId    = 4,
                        Available        = true,
                        FixedRetailPrice = false,
                        RetailPrice      = 10,
                        ResellerPrice    = 5,
                    }
                }
            };
            #endregion

            #region Company Catalogs

            var masterAssigned = new CompanyCatalog
            {
                Catalog     = defaultCatalog,
                CatalogId   = 1,
                Company     = masterCompany,
                CatalogType = CatalogType.Assigned,
            };
            var masterFirstAssignable = new CompanyCatalog
            {
                Catalog     = masterFirstAssignableCatalog,
                CatalogId   = 2,
                Company     = masterCompany,
                CatalogType = CatalogType.MyCatalog
            };
            var masterSecondAssignable = new CompanyCatalog
            {
                Catalog     = masterSecondAssignableCatalog,
                CatalogId   = 8,
                Company     = masterCompany,
                CatalogType = CatalogType.MyCatalog
            };
            masterCompany.CompanyCatalogs = new List <CompanyCatalog>
            {
                masterAssigned,
                masterFirstAssignable,
                masterSecondAssignable
            };

            var firstChildOfMasterAssigned = new CompanyCatalog
            {
                Catalog     = defaultCatalog,
                CatalogId   = 1,
                Company     = firstChildOfMaster,
                CatalogType = CatalogType.Assigned
            };
            var firstChildOfMasterFirstAssignable = new CompanyCatalog
            {
                Catalog     = firstChildsFirstAssignableCatalog,
                CatalogId   = 3,
                Company     = firstChildOfMaster,
                CatalogType = CatalogType.MyCatalog
            };
            var firstChildOfMasterSecondAssignable = new CompanyCatalog
            {
                Catalog     = firstChildsSecondAssignableCatalog,
                CatalogId   = 4,
                Company     = firstChildOfMaster,
                CatalogType = CatalogType.MyCatalog
            };
            firstChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                firstChildOfMasterAssigned,
                firstChildOfMasterFirstAssignable,
                firstChildOfMasterSecondAssignable
            };

            var secondChildOfMasterAssigned = new CompanyCatalog
            {
                Catalog     = masterFirstAssignableCatalog,
                CatalogId   = 2,
                Company     = secondChildOfMaster,
                CatalogType = CatalogType.Assigned
            };
            var secondChildOfMasterAssignable = new CompanyCatalog
            {
                Catalog     = secondChildsAssignableCatalog,
                CatalogId   = 5,
                Company     = secondChildOfMaster,
                CatalogType = CatalogType.MyCatalog
            };
            secondChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                secondChildOfMasterAssigned,
                secondChildOfMasterAssignable
            };

            var firstChildsFirstChildAssigned = new CompanyCatalog
            {
                Catalog     = firstChildsFirstAssignableCatalog,
                CatalogId   = 3,
                Company     = firstChildsFirstChild,
                CatalogType = CatalogType.Assigned
            };
            var firstChildsFirstChildAssignable = new CompanyCatalog
            {
                Catalog     = firstChildsFirstChildsAssignableCatalog,
                CatalogId   = 6,
                Company     = firstChildsFirstChild,
                CatalogType = CatalogType.MyCatalog,
            };
            firstChildsFirstChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                firstChildsFirstChildAssigned,
                firstChildsFirstChildAssignable
            };

            var firstChildsSecondChildAssigned = new CompanyCatalog
            {
                Catalog     = firstChildsSecondAssignableCatalog,
                CatalogId   = 4,
                Company     = firstChildsSecondChild,
                CatalogType = CatalogType.Assigned
            };
            var firstChildsSecondsChildAssignable = new CompanyCatalog
            {
                Catalog     = firstChildsSecondChildsAssignableCatalog,
                CatalogId   = 7,
                Company     = firstChildsSecondChild,
                CatalogType = CatalogType.MyCatalog
            };
            firstChildsSecondChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                firstChildsSecondChildAssigned,
                firstChildsSecondsChildAssignable
            };

            #endregion

            var companies = new List <Entities.Company>
            {
                masterCompany,
                firstChildOfMaster,
                firstChildsFirstChild,
                firstChildsSecondChild,
                secondChildOfMaster
            };

            var companyCatalogs = new List <CompanyCatalog>
            {
                masterAssigned,
                masterFirstAssignable,
                masterSecondAssignable,
                firstChildOfMasterAssigned,
                firstChildOfMasterFirstAssignable,
                firstChildOfMasterSecondAssignable,
                secondChildOfMasterAssigned,
                secondChildOfMasterAssignable,
                firstChildsFirstChildAssigned,
                firstChildsFirstChildAssignable,
                firstChildsSecondChildAssigned,
                firstChildsSecondsChildAssignable
            };

            _companiesDbSet       = MockSetGenerator.CreateAsyncMockSet(companies);
            _companyCatalogsDbSet = MockSetGenerator.CreateAsyncMockSet(companyCatalogs);

            _dbContextMock = new Mock <CldpDbContext>();
            _dbContextMock.Setup(c => c.Companies).Returns(_companiesDbSet);
            _dbContextMock.Setup(c => c.CompanyCatalogs).Returns(_companyCatalogsDbSet);

            var catalogUtilitiesMock = new Mock <ICatalogUtilities>();

            _catalogProductItemServiceMock = new Mock <ICatalogProductItemService>();
            _catalogProductItemServiceMock.Setup(c => c.AddProductItemToCatalog(It.IsAny <CatalogProductModel>())).Returns(Task.CompletedTask);
            _catalogProductItemServiceMock.Setup(c => c.RemoveProductItemFromCatalog(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.CompletedTask);
            _catalogProductItemServiceMock.Setup(c => c.UpdateFixedRetailPrice(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(Task.CompletedTask);

            _sut = new Database.Catalog.CompanyCatalogService(_dbContextMock.Object, _catalogProductItemServiceMock.Object, catalogUtilitiesMock.Object);
        }
        public void Setup()
        {
            #region Companies
            var masterCompany = new Entities.Company
            {
                Id     = 1,
                Name   = "Master Company",
                Parent = null
            };

            var firstChildOfMaster = new Entities.Company
            {
                Id     = 2,
                Name   = "First Child of Master Company",
                Parent = masterCompany
            };

            var secondChildOfMaster = new Entities.Company
            {
                Id     = 3,
                Name   = "Second Child of Master Company",
                Parent = masterCompany
            };

            masterCompany.MyCompanies = new List <Entities.Company> {
                firstChildOfMaster, secondChildOfMaster
            };

            var firstChildsFirstChild = new Entities.Company
            {
                Id     = 4,
                Name   = "First Child's First Child",
                Parent = firstChildOfMaster
            };

            var firstChildsSecondChild = new Entities.Company
            {
                Id     = 5,
                Name   = "First Child's Second Child",
                Parent = firstChildOfMaster
            };

            firstChildOfMaster.MyCompanies = new List <Entities.Company> {
                firstChildsFirstChild, firstChildsSecondChild
            };

            var secondChildsFirstChild = new Entities.Company
            {
                Id     = 6,
                Name   = "Second Child's First Child",
                Parent = secondChildOfMaster
            };

            var secondChildsSecondChild = new Entities.Company
            {
                Id     = 7,
                Name   = "Second Child's Second Child",
                Parent = secondChildOfMaster
            };

            secondChildOfMaster.MyCompanies = new List <Entities.Company> {
                secondChildsFirstChild, secondChildsSecondChild
            };

            var firstGrandGrandChildOfMaster = new Entities.Company
            {
                Id     = 8,
                Name   = "Grand Child of Master's First Child",
                Parent = firstChildsFirstChild
            };

            firstChildsFirstChild.MyCompanies = new List <Entities.Company> {
                firstGrandGrandChildOfMaster
            };

            var secondGrandGrandChildOfMaster = new Entities.Company
            {
                Id     = 9,
                Name   = "Grand Child of Master's Second Child",
                Parent = secondChildsFirstChild
            };

            secondChildsFirstChild.MyCompanies = new List <Entities.Company> {
                secondGrandGrandChildOfMaster
            };
            #endregion

            #region CatalogProductItems
            var defaultCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 1,
                Available     = false
            };
            var defaultCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 1,
                Available     = true
            };
            var defaultCatalogThirdProductItem = new CatalogProductItem
            {
                ProductItemId = 3,
                CatalogId     = 1,
                Available     = true
            };
            var defaultCatalogFourthProductItem = new CatalogProductItem
            {
                ProductItemId = 4,
                CatalogId     = 1,
                Available     = true
            };

            var masterAssignableCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 2,
                Available     = true
            };
            var masterAssignableCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 2,
                Available     = true
            };
            var masterAssignableCatalogThirdProductItem = new CatalogProductItem
            {
                ProductItemId = 3,
                CatalogId     = 2,
                Available     = true
            };
            var masterAssignableCatalogFourthProductItem = new CatalogProductItem
            {
                ProductItemId = 4,
                CatalogId     = 2,
                Available     = true
            };

            var firstChildsFirstAssignableCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 3,
                Available     = true
            };
            var firstChildsFirstAssignableCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 3,
                Available     = true
            };

            var firstChildsSecondAssignableCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 4,
                Available     = true
            };
            var firstChildsSecondAssignableCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 4,
                Available     = true
            };
            var firstChildsSecondAssignableCatalogThirdProductItem = new CatalogProductItem
            {
                ProductItemId = 3,
                CatalogId     = 4,
                Available     = true
            };

            var secondChildsFirstAssignableCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 5,
                Available     = true
            };
            var secondChildsFirstAssignableCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 5,
                Available     = true
            };
            var secondChildsFirstAssignableCatalogThirdProductItem = new CatalogProductItem
            {
                ProductItemId = 3,
                CatalogId     = 5,
                Available     = true
            };

            var firstChildsFirstChildsAssignableCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 6,
                Available     = true
            };
            var firstChildsFirstChildsAssignableCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 6,
                Available     = true
            };
            var firstChildsFirstChildsAssignableCatalogThirdProductItem = new CatalogProductItem
            {
                ProductItemId = 3,
                CatalogId     = 6,
                Available     = true
            };

            var firstChildsSecondChildsAssignableCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 7,
                Available     = true
            };
            var firstChildsSecondChildsAssignableCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 7,
                Available     = true
            };

            var secondChildsFirstChildsAssignableCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 8,
                Available     = true
            };
            var secondChildsFirstChildsAssignableCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 8,
                Available     = true
            };
            var secondChildsFirstChildsAssignableCatalogThirdProductItem = new CatalogProductItem
            {
                ProductItemId = 3,
                CatalogId     = 8,
                Available     = true
            };

            var secondChildsSecondChildsAssignableCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 9,
                Available     = true
            };
            var secondChildsSecondChildsAssignableCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 9,
                Available     = true
            };
            var secondChildsSecondChildsAssignableCatalogThirdProductItem = new CatalogProductItem
            {
                ProductItemId = 3,
                CatalogId     = 9,
                Available     = true
            };

            var firstGrandGrandChildOfMasterAssignableCatalogFirstProductItem = new CatalogProductItem
            {
                ProductItemId = 1,
                CatalogId     = 10,
                Available     = true
            };
            var firstGrandGrandChildOfMasterAssignableCatalogSecondProductItem = new CatalogProductItem
            {
                ProductItemId = 2,
                CatalogId     = 10,
                Available     = true
            };
            var firstGrandGrandChildOfMasterAssignableCatalogThirdProductItem = new CatalogProductItem
            {
                ProductItemId = 3,
                CatalogId     = 10,
                Available     = true
            };

            var secondGrandGrandChildOfMasterAssignableCatalogThirdProductItem = new CatalogProductItem
            {
                ProductItemId = 3,
                CatalogId     = 11,
                Available     = true
            };

            #endregion

            #region Catalogs
            var defaultCatalog = new Entities.Catalog.Catalog
            {
                Id   = 1,
                Name = "Default Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    defaultCatalogFirstProductItem,
                    defaultCatalogSecondProductItem,
                    defaultCatalogThirdProductItem,
                    defaultCatalogFourthProductItem
                }
            };

            var masterAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 2,
                Name = "Master's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    masterAssignableCatalogFirstProductItem,
                    masterAssignableCatalogSecondProductItem,
                    masterAssignableCatalogThirdProductItem,
                    masterAssignableCatalogFourthProductItem,
                }
            };

            var firstChildsFirstAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 3,
                Name = "First Child's First Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    firstChildsFirstAssignableCatalogFirstProductItem,
                    firstChildsFirstAssignableCatalogSecondProductItem
                }
            };

            var firstChildsSecondAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 4,
                Name = "First Child's Second Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    firstChildsSecondAssignableCatalogFirstProductItem,
                    firstChildsSecondAssignableCatalogSecondProductItem,
                    firstChildsSecondAssignableCatalogThirdProductItem
                }
            };

            var secondChildsFirstAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 5,
                Name = "Second Child's First Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    secondChildsFirstAssignableCatalogFirstProductItem,
                    secondChildsFirstAssignableCatalogSecondProductItem,
                    secondChildsFirstAssignableCatalogThirdProductItem
                }
            };

            var firstChildsFirstChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 6,
                Name = "First Child's First Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    firstChildsFirstChildsAssignableCatalogFirstProductItem,
                    firstChildsFirstChildsAssignableCatalogSecondProductItem,
                    firstChildsFirstChildsAssignableCatalogThirdProductItem
                }
            };

            var firstChildsSecondChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 7,
                Name = "First Child's Second Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    firstChildsSecondChildsAssignableCatalogFirstProductItem,
                    firstChildsSecondChildsAssignableCatalogSecondProductItem
                }
            };

            var secondChildsFirstChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 8,
                Name = "Second Child's First Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    secondChildsFirstChildsAssignableCatalogFirstProductItem,
                    secondChildsFirstChildsAssignableCatalogSecondProductItem,
                    secondChildsFirstChildsAssignableCatalogThirdProductItem
                }
            };

            var secondChildsSecondChildsAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 9,
                Name = "Second Child's Second Child's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    secondChildsSecondChildsAssignableCatalogFirstProductItem,
                    secondChildsSecondChildsAssignableCatalogSecondProductItem,
                    secondChildsSecondChildsAssignableCatalogThirdProductItem
                }
            };

            var firstGrandGrandChildOfMasterAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 10,
                Name = "First Grand Grand Child of Master's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    firstGrandGrandChildOfMasterAssignableCatalogFirstProductItem,
                    firstGrandGrandChildOfMasterAssignableCatalogSecondProductItem,
                    firstGrandGrandChildOfMasterAssignableCatalogThirdProductItem
                }
            };

            var secondGrandGrandChildOfMasterAssignableCatalog = new Entities.Catalog.Catalog
            {
                Id   = 11,
                Name = "Second Grand Grand Child of Master's Assignable Catalog",
                CatalogProductItems = new List <CatalogProductItem>
                {
                    secondGrandGrandChildOfMasterAssignableCatalogThirdProductItem
                }
            };
            #endregion

            #region Company Catalogs
            masterCompany.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = defaultCatalog,
                    CatalogId   = 1,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = masterAssignableCatalog,
                    CatalogId   = 2,
                    CatalogType = CatalogType.MyCatalog,
                }
            };

            firstChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = defaultCatalog,
                    CatalogId   = 1,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstAssignableCatalog,
                    CatalogId   = 3,
                    CatalogType = CatalogType.MyCatalog,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsSecondAssignableCatalog,
                    CatalogId   = 4,
                    CatalogType = CatalogType.MyCatalog,
                }
            };
            firstChildsFirstChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstAssignableCatalog,
                    CatalogId   = 3,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstChildsAssignableCatalog,
                    CatalogId   = 6,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            firstChildsSecondChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstAssignableCatalog,
                    CatalogId   = 3,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstChildsSecondChildsAssignableCatalog,
                    CatalogId   = 7,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            firstGrandGrandChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = firstChildsFirstChildsAssignableCatalog,
                    CatalogId   = 6,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = firstGrandGrandChildOfMasterAssignableCatalog,
                    CatalogId   = 10,
                    CatalogType = CatalogType.MyCatalog,
                },
            };

            secondChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = masterAssignableCatalog,
                    CatalogId   = 2,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstAssignableCatalog,
                    CatalogId   = 5,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            secondChildsFirstChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstAssignableCatalog,
                    CatalogId   = 5,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstChildsAssignableCatalog,
                    CatalogId   = 8,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            secondChildsSecondChild.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstAssignableCatalog,
                    CatalogId   = 5,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = secondChildsSecondChildsAssignableCatalog,
                    CatalogId   = 9,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            secondGrandGrandChildOfMaster.CompanyCatalogs = new List <CompanyCatalog>
            {
                new CompanyCatalog
                {
                    Catalog     = secondChildsFirstChildsAssignableCatalog,
                    CatalogId   = 8,
                    CatalogType = CatalogType.Assigned,
                },
                new CompanyCatalog
                {
                    Catalog     = secondGrandGrandChildOfMasterAssignableCatalog,
                    CatalogId   = 11,
                    CatalogType = CatalogType.MyCatalog,
                },
            };
            #endregion

            var companies = new List <Entities.Company>
            {
                masterCompany,
                firstChildOfMaster,
                firstChildsFirstChild,
                firstGrandGrandChildOfMaster,
                firstChildsSecondChild,
                secondChildOfMaster,
                secondChildsFirstChild,
                secondGrandGrandChildOfMaster,
                secondChildsSecondChild
            };
            var catalogProductItems = new List <CatalogProductItem>
            {
                defaultCatalogFirstProductItem,
                defaultCatalogSecondProductItem,
                defaultCatalogThirdProductItem,
                defaultCatalogFourthProductItem,
                masterAssignableCatalogFirstProductItem,
                masterAssignableCatalogSecondProductItem,
                masterAssignableCatalogThirdProductItem,
                masterAssignableCatalogFourthProductItem,
                firstChildsFirstAssignableCatalogFirstProductItem,
                firstChildsFirstAssignableCatalogSecondProductItem,
                firstChildsSecondAssignableCatalogFirstProductItem,
                firstChildsSecondAssignableCatalogSecondProductItem,
                firstChildsSecondAssignableCatalogThirdProductItem,
                secondChildsFirstAssignableCatalogFirstProductItem,
                secondChildsFirstAssignableCatalogSecondProductItem,
                secondChildsFirstAssignableCatalogThirdProductItem,
                firstChildsFirstChildsAssignableCatalogFirstProductItem,
                firstChildsFirstChildsAssignableCatalogSecondProductItem,
                firstChildsFirstChildsAssignableCatalogThirdProductItem,
                firstChildsSecondChildsAssignableCatalogFirstProductItem,
                firstChildsSecondChildsAssignableCatalogSecondProductItem,
                secondChildsFirstChildsAssignableCatalogFirstProductItem,
                secondChildsFirstChildsAssignableCatalogSecondProductItem,
                secondChildsFirstChildsAssignableCatalogThirdProductItem,
                secondChildsSecondChildsAssignableCatalogFirstProductItem,
                secondChildsSecondChildsAssignableCatalogSecondProductItem,
                secondChildsSecondChildsAssignableCatalogThirdProductItem,
                firstGrandGrandChildOfMasterAssignableCatalogFirstProductItem,
                firstGrandGrandChildOfMasterAssignableCatalogSecondProductItem,
                firstGrandGrandChildOfMasterAssignableCatalogThirdProductItem,
                secondGrandGrandChildOfMasterAssignableCatalogThirdProductItem
            };

            _companiesDbSet           = MockSetGenerator.CreateAsyncMockSet(companies);
            _catalogProductItemsDbSet = MockSetGenerator.CreateAsyncMockSet(catalogProductItems);
            _dbContextMock            = new Mock <CldpDbContext>();
            _dbContextMock.Setup(c => c.Companies).Returns(_companiesDbSet);
            _dbContextMock.Setup(c => c.CatalogProductItems).Returns(_catalogProductItemsDbSet);

            var catalogUtilitiesMock = new Mock <ICatalogUtilities>();
            catalogUtilitiesMock.Setup(x => x.CalculateResellerPrice(It.IsAny <decimal>(), It.IsAny <decimal>())).Returns(10);

            _sut = new Database.Catalog.CatalogProductItemService(_dbContextMock.Object, catalogUtilitiesMock.Object);
        }