public void you_can_add_a_new_design()
        {
            var theInitialDesignCount = ExampleProduct.Designs.Count;

            var command = new DesignRepository(Internet, Settings.BaseUrl);
            var theNewDesign = NewDesign();

            var result = command.Add(ExampleProduct.Key, theNewDesign);

            Assert.AreEqual(theInitialDesignCount + 1, result.Designs.Count, "Expected the new design to have been added");
        }
        public void you_cannot_delete_the_last_design()
        {
            var command = new DesignRepository(Internet, Settings.BaseUrl);

            Assert.AreEqual(1, ExampleProduct.Designs.Count,
                "Invalid test data. " +
                "Test expects there to be exactly one design in order to prove that it cannot be deleted."
            );

            var theError = Assert.Throws<Exception>(() =>
                command.Delete(ExampleProduct.Key, ExampleProduct.Designs[0].Key
            ));

            Assert.That(theError.Message, Is.StringEnding("\"Bad Request. Error deleting design.Product must have at least one design\""));

            var theRefreshedProduct = new FindCommand(Internet, Settings.BaseUrl).Find(ExampleProduct.Key);

            Assert.AreEqual(1, theRefreshedProduct.Designs.Count, "Expected the product to still have its last design");
        }
        public void you_can_delete_a_design()
        {
            var theLastDesign = ExampleProduct.Designs[0];
            var addNewDesign = new DesignRepository(Internet, Settings.BaseUrl);

            ExampleProduct = addNewDesign.Add(ExampleProduct.Key, NewDesign());

            Assert.AreEqual(2, ExampleProduct.Designs.Count,
                "Invalid test data" +
                "In order for this test to be valid, the product needs to have " +
                "more than one design (since you can't delete the last one)"
            );

            var command = new DesignRepository(Internet, Settings.BaseUrl);

            var theRefreshedProduct = command.Delete(ExampleProduct.Key, ExampleProduct.Designs[1].Key);

            Assert.AreEqual(1, theRefreshedProduct.Designs.Count, "Expected the design to have been deleted");
            Assert.AreEqual(theLastDesign.Key, theRefreshedProduct.Designs[0].Key, "Expected that the newly-added one was deleted");
        }
        public void you_can_update_an_existing_design_for_example_you_can_change_its_material()
        {
            var command = new DesignRepository(Internet, Settings.BaseUrl);

            var theDesign = ExampleProduct.Designs[0];
            var theOriginalMaterial = theDesign.MaterialKey;

            theDesign.MaterialKey = ExampleMaterials.SUPERFINE_PLASTIC;

            var result = command.Update(ExampleProduct.Key, theDesign);

            var theUpdatedDesign = result.Designs[0];

            Assert.AreEqual(ExampleMaterials.SUPERFINE_PLASTIC, theUpdatedDesign.MaterialKey,
                "Expected the design's material key to have been updated"
            );

            Assert.AreNotEqual(theOriginalMaterial, theUpdatedDesign.MaterialKey,
                "Expected the design's material key to have been changed from what it was"
            );
        }
        public void you_can_only_change_the_file_name_when_uploading_a_new_design_file()
        {
            var command = new DesignRepository(Internet, Settings.BaseUrl);

            var theDesign = ExampleProduct.Designs[0];

            var theNewFile = new FileInfo("res\\another_bottom_new.stl");

            var result = command.Update(ExampleProduct.Key, theDesign, theNewFile);

            var theUpdatedDesign = result.Designs[0];

            Assert.AreEqual(theNewFile.Name, theUpdatedDesign.Filename, "Expected the filename to have been updated");
        }