コード例 #1
0
        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");
        }
コード例 #2
0
        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");
        }