public void Setup() { var companies = new List <Entities.Company> { new Entities.Company { Id = 1, Name = "First Company" }, new Entities.Company { Id = 2, Name = "Second Company" }, new Entities.Company { Id = 3, Name = "Third Company" }, }; _companiesDbSet = MockSetGenerator.CreateAsyncMockSet(companies); _dbContextMock = new Mock <CldpDbContext>(); _dbContextMock.Setup(c => c.Companies).Returns(_companiesDbSet); _dbContextMock.Setup(x => x.SaveChanges()).Verifiable(); var userServiceMock = new Mock <IUserService>(); _sut = new Database.Company.CompanyService(_dbContextMock.Object, userServiceMock.Object); }
public void Setup() { var companies = new List <Entities.Company> { new Entities.Company { Id = 1, Name = "Parent Company" }, new Entities.Company { Id = 2, Name = "Child Company", ParentId = 1 }, }; var companiesDbSet = MockSetGenerator.CreateAsyncMockSet(companies); var dbContextMock = new Mock <CldpDbContext>(); dbContextMock.Setup(c => c.Companies).Returns(companiesDbSet); var userServiceMock = new Mock <IUserService>(); _sut = new Database.Company.CompanyService(dbContextMock.Object, userServiceMock.Object); }
public void Setup() { var products = new List <Entities.Catalog.Product> { new Entities.Catalog.Product { Id = 1, Name = "First product" }, new Entities.Catalog.Product { Id = 2, Name = "Second product" } }; var productDbSet = MockSetGenerator.CreateAsyncMockSet(products); var dbContextMock = new Mock <CldpDbContext>(); dbContextMock.Setup(p => p.Products).Returns(productDbSet); _sut = new Database.Product.ProductService(dbContextMock.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 }; #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); }
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); }
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); }
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); }
public void Setup() { // grandchild reseller of main company var mainCompanyGrandChildReseller1 = new Entities.Company { Id = 1, Name = "Main Company Grand Child Reseller 1", Type = 0, }; var mainCompanyGrandChildReseller2 = new Entities.Company { Id = 2, Name = "Main Company Grand Child Reseller 2", Type = 0, }; var mainCompanyGrandChildReseller3 = new Entities.Company { Id = 3, Name = "Main Company Grand Child Reseller 3", Type = 0, }; // grandchild customer of main company var mainCompanyGrandChildCustomer1 = new Entities.Company { Id = 4, Name = "Main Company Grand Child Customer 1", Type = 1, }; var mainCompanyGrandChildCustomer2 = new Entities.Company { Id = 5, Name = "Main Company Grand Child Customer 2", Type = 1, }; // child resellers of main company var mainCompanyChildReseller1 = new Entities.Company { Id = 6, Name = "Main Company Child Reseller 1", Type = 0, MyCompanies = new List <Entities.Company> { mainCompanyGrandChildReseller1, mainCompanyGrandChildReseller2, mainCompanyGrandChildCustomer1 } }; var mainCompanyChildReseller2 = new Entities.Company { Id = 7, Name = "Main Company Child Reseller 2", Type = 0, MyCompanies = new List <Entities.Company> { mainCompanyGrandChildReseller3, mainCompanyGrandChildCustomer2 } }; // child customers of main company var mainCompanyChildCustomer1 = new Entities.Company { Id = 8, Name = "Main Company Child Customer 1", Type = 1, }; var mainCompanyChildCustomer2 = new Entities.Company { Id = 9, Name = "Main Company Child Customer 2", Type = 1, }; var mainCompanyChildCustomer3 = new Entities.Company { Id = 10, Name = "Main Company Child Customer 3", Type = 1, }; var mainCompanyChildCustomer4 = new Entities.Company { Id = 11, Name = "Main Company Child Customer 4", Type = 1, }; // child resellers of other company var otherCompanyChildReseller1 = new Entities.Company { Id = 12, Name = "Other Company Child Reseller 1", Type = 0 }; var otherCompanyChildReseller2 = new Entities.Company { Id = 13, Name = "Other Company Child Reseller 2", Type = 0 }; // child customers of other company var otherCompanyChildCustomer1 = new Entities.Company { Id = 14, Name = "Other Company Child Customer 1", Type = 1 }; var otherCompanyChildCustomer2 = new Entities.Company { Id = 15, Name = "Other Company Child Customer 2", Type = 1 }; // main company var mainCompany = new Entities.Company { Id = 16, Name = "Main Company", MyCompanies = new List <Entities.Company> { mainCompanyChildReseller1, mainCompanyChildReseller2, mainCompanyChildCustomer1, mainCompanyChildCustomer2, mainCompanyChildCustomer3, mainCompanyChildCustomer4 } }; // other company var otherCompany = new Entities.Company { Id = 17, Name = "Other Company", MyCompanies = new List <Entities.Company> { otherCompanyChildReseller1, otherCompanyChildReseller2, otherCompanyChildCustomer1, otherCompanyChildCustomer2, } }; var companies = new List <Entities.Company> { mainCompany, mainCompanyGrandChildReseller1, mainCompanyGrandChildReseller2, mainCompanyGrandChildReseller3, mainCompanyGrandChildCustomer1, mainCompanyGrandChildCustomer2, mainCompanyChildReseller1, mainCompanyChildReseller2, mainCompanyChildCustomer1, mainCompanyChildCustomer2, mainCompanyChildCustomer3, mainCompanyChildCustomer4, otherCompany, otherCompanyChildReseller1, otherCompanyChildReseller2, otherCompanyChildCustomer1, otherCompanyChildCustomer2 }; var companiesDbSet = MockSetGenerator.CreateAsyncMockSet(companies); var dbContextMock = new Mock <CldpDbContext>(); dbContextMock.Setup(c => c.Companies).Returns(companiesDbSet); var mockedUsers = new List <UserModel> { new UserModel { Id = 1, FirstName = "Fname1", LastName = "Lname1" }, new UserModel { Id = 2, FirstName = "Fname2", LastName = "Lname2" }, new UserModel { Id = 3, FirstName = "Fname3", LastName = "Lname3" }, new UserModel { Id = 4, FirstName = "Fname4", LastName = "Lname4" }, new UserModel { Id = 5, FirstName = "Fname5", LastName = "Lname5" }, }; var userServiceMock = new Mock <IUserService>(); userServiceMock.Setup(x => x.GetUsers(It.IsAny <int>())).Returns(mockedUsers); _sut = new Database.Company.CompanyService(dbContextMock.Object, userServiceMock.Object); }