public void ensureCatalogueCollectionCanBeCreatedIfAllCustomizedProductsWereAddedToCustomizedProductCollection() { CustomizedProductCollection customizedProductCollection = new CustomizedProductCollection("Closets Spring 2019"); CustomizedProduct customizedProduct1 = buildCustomizedProduct("1234"); customizedProduct1.finalizeCustomization(); //!customized products added to collections need to be finished customizedProductCollection.addCustomizedProduct(customizedProduct1); CustomizedProduct customizedProduct2 = buildCustomizedProduct("1235"); customizedProduct2.finalizeCustomization(); //!customized products added to collections need to be finished customizedProductCollection.addCustomizedProduct(customizedProduct2); List <CustomizedProduct> customizedProducts = new List <CustomizedProduct>() { customizedProduct1, customizedProduct2 }; CatalogueCollection catalogueCollection = new CatalogueCollection(customizedProductCollection, customizedProducts); Assert.NotNull(catalogueCollection); }
private CustomizedProductCollection buildCustomizedProductCollection() { CustomizedProductCollection customizedProductCollection = new CustomizedProductCollection("Closets Spring 2019"); CustomizedProduct customizedProduct1 = buildCustomizedProduct("1234"); customizedProduct1.finalizeCustomization(); //!customized products added to collections need to be finished customizedProductCollection.addCustomizedProduct(customizedProduct1); CustomizedProduct customizedProduct2 = buildCustomizedProduct("1235"); customizedProduct2.finalizeCustomization(); //!customized products added to collections need to be finished customizedProductCollection.addCustomizedProduct(customizedProduct2); return(customizedProductCollection); }
public void ensureHasCustomizedProductReturnsTrueIfCustomizedProductWasAdded() { CustomizedProductCollection collection = new CustomizedProductCollection("Collection"); CustomizedProduct customizedProduct = buildFinishedCustomizedProductInstance(); collection.addCustomizedProduct(customizedProduct); Assert.True(collection.hasCustomizedProduct(customizedProduct)); }
public void ensureAddingPendingCustomizedProductThrowsException() { Product product = buildValidProduct(); CustomizedProductCollection instance = new CustomizedProductCollection("Mario"); Assert.Throws <ArgumentException>(() => instance.addCustomizedProduct( buildUnfinishedCustomizedProductInstance() )); }
public void ensureAddCustomizedProductWorksForValidProduct() { CustomizedProduct customizedProduct = buildFinishedCustomizedProductInstance(); CustomizedProductCollection instance = new CustomizedProductCollection("Mario"); instance.addCustomizedProduct(customizedProduct); Assert.NotEmpty(instance.collectionProducts); Assert.Equal(customizedProduct, instance.collectionProducts[0].customizedProduct); }
public void ensureAddCustomizedProductFailsIfItAlreadyExists() { CustomizedProduct customizedProduct = buildFinishedCustomizedProductInstance(); List <CustomizedProduct> list = new List <CustomizedProduct>(); list.Add(customizedProduct); CustomizedProductCollection instance = new CustomizedProductCollection("Mario", list); Assert.Throws <ArgumentException>(() => instance.addCustomizedProduct(customizedProduct)); }
public void ensureCreatingCatalogueCollectionWithCustomizedProductCollectionAddsAllCustomizedProducts() { CustomizedProductCollection customizedProductCollection = new CustomizedProductCollection("Closets Spring 2019"); CustomizedProduct customizedProduct1 = buildCustomizedProduct("1234"); customizedProduct1.finalizeCustomization(); //!customized products added to collections need to be finished customizedProductCollection.addCustomizedProduct(customizedProduct1); CustomizedProduct customizedProduct2 = buildCustomizedProduct("1235"); customizedProduct2.finalizeCustomization(); //!customized products added to collections need to be finished customizedProductCollection.addCustomizedProduct(customizedProduct2); CatalogueCollection catalogueCollection = new CatalogueCollection(customizedProductCollection); Assert.True(catalogueCollection.hasCustomizedProduct(customizedProduct1)); Assert.True(catalogueCollection.hasCustomizedProduct(customizedProduct2)); }
private CustomizedProductCollection createCustomizedProductCollection() { CustomizedProductCollection customizedProductCollection = new CustomizedProductCollection("hello"); CustomizedProduct customizedProduct = buildCustomizedProductInstance(); customizedProductCollection.addCustomizedProduct(customizedProduct); return(customizedProductCollection); }
public void ensureAddingValidCustomizedProductAddsCustomizedProduct() { CatalogueCollection catalogueCollection = buildCatalogueCollection(); CustomizedProductCollection customizedProductCollection = catalogueCollection.customizedProductCollection; CustomizedProduct customizedProduct = buildCustomizedProduct("123545"); customizedProduct.finalizeCustomization(); customizedProductCollection.addCustomizedProduct(customizedProduct); catalogueCollection.addCustomizedProduct(customizedProduct); Assert.Equal(3, catalogueCollection.catalogueCollectionProducts.Count); Assert.True(catalogueCollection.hasCustomizedProduct(customizedProduct)); }
public void ensureAddingValidCustomizedProductDoesNotThrowException() { CatalogueCollection catalogueCollection = buildCatalogueCollection(); CustomizedProductCollection customizedProductCollection = catalogueCollection.customizedProductCollection; CustomizedProduct customizedProduct = buildCustomizedProduct("123545"); customizedProduct.finalizeCustomization(); customizedProductCollection.addCustomizedProduct(customizedProduct); Action addValidCustomizedProduct = () => catalogueCollection.addCustomizedProduct(customizedProduct); Exception exception = Record.Exception(addValidCustomizedProduct); Assert.Null(exception); }
public void ensureCatalogueCollectionCantBeCreatedWithDuplicateCustomizedProductsInCustomizedProductEnumerable() { CustomizedProductCollection customizedProductCollection = new CustomizedProductCollection("Closets Spring 2019"); CustomizedProduct customizedProduct1 = buildCustomizedProduct("1234"); customizedProduct1.finalizeCustomization(); //!customized products added to collections need to be finished customizedProductCollection.addCustomizedProduct(customizedProduct1); CustomizedProduct customizedProduct2 = buildCustomizedProduct("1235"); List <CustomizedProduct> customizedProducts = new List <CustomizedProduct>() { customizedProduct1, customizedProduct2, customizedProduct1 }; Action createCatalogueCollection = () => new CatalogueCollection(customizedProductCollection, customizedProducts); Assert.Throws <ArgumentException>(createCatalogueCollection); }
/// <summary> /// Updates a customized product collection by adding a new customized product to it /// </summary> /// <param name="modelView">model view with the necessary update information</param> /// <returns>Updated customized product collection or throws an exception if an error occurs</returns> public static CustomizedProductCollection update(AddCustomizedProductToCustomizedProductCollectionModelView modelView) { CustomizedProductCollectionRepository customizedProductCollectionRepository = PersistenceContext.repositories() .createCustomizedProductCollectionRepository(); CustomizedProductCollection customizedProductCollection = customizedProductCollectionRepository.find(modelView.customizedProductCollectionId); checkIfCustomizedProductCollectionWasFound( customizedProductCollection, modelView.customizedProductCollectionId ); CustomizedProduct customizedProduct = PersistenceContext.repositories() .createCustomizedProductRepository() .find(modelView.customizedProductId); if (customizedProduct == null) { throw new ArgumentException( string.Format( UNABLE_TO_FIND_CUSTOMIZED_PRODUCT, modelView.customizedProductId) ); } customizedProductCollection.addCustomizedProduct(customizedProduct); CustomizedProductCollection updatedCustomizedProductCollection = customizedProductCollectionRepository.update(customizedProductCollection); checkIfUpdatedCustomizedProductCollectionWasSaved( updatedCustomizedProductCollection, modelView.customizedProductCollectionId ); return(updatedCustomizedProductCollection); }
public void ensureAddCustomizedProductFailsIfItIsNull() { CustomizedProductCollection instance = new CustomizedProductCollection("Mario"); Assert.Throws <ArgumentException>(() => instance.addCustomizedProduct(null)); }