コード例 #1
0
        public void you_can_get_a_list_of_products()
        {
            var finder = new FindCommand(Internet, Settings.BaseUrl);
            var result = finder.FindAll();

            Assert.That(result.Length, Is.GreaterThan(0), "Expected at least one product returned");
        }
コード例 #2
0
        public void find_all_fails_when_internet_returns_401_unauthorized()
        {
            var expectedStatus = HttpStatusCode.Unauthorized;

            var unauthorizedResponse = NewFakeResponse(expectedStatus);

            var internet = MockRepository.GenerateStub<TheInternet>();
            internet.Stub(it => it.Get(Arg<Uri>.Is.Anything)).Return(unauthorizedResponse);

            var finder = new FindCommand(internet, "http://xxx");

            var expectedError = String.Format(
                "Authorization failed. The server returned status {0} ({1}).",
                expectedStatus,
                (Int32)expectedStatus
            );

            var theError = Assert.Throws<Exception>(() => finder.FindAll());

            Assert.AreEqual(expectedError, theError.Message, "The error was raised, but the message does not match.");
        }
コード例 #3
0
        public void you_can_delete_them_all()
        {
            var finder = new FindCommand(Internet, Settings.BaseUrl);
            var delete = new DeleteCommand(Internet, Settings.BaseUrl);
            var result = finder.FindAll();

            var count = 0;

            Console.WriteLine("Deleting {0} products", result.Length);

            foreach (var product in result) {
                delete.Delete(product.Key);
                count++;
            }

            Console.WriteLine("Deleted {0} products", count);

            Assert.AreEqual(0, finder.FindAll().Length, "Expected them all to have been deleted");
        }