Esempio n. 1
0
        public async Task TestBookmarksApiDeleteAsync()
        {
            // Find out how many bookmarks there are

            // Arrange
            int actualBookmarkCount = 0;

            // Act
            IHttpActionResult bookmarkResult = controller.Get();
            var message = await bookmarkResult.ExecuteAsync(new System.Threading.CancellationToken());

            var bookmarks = await message.Content.ReadAsAsync <IEnumerable <Bookmark> >();

            foreach (var b in bookmarks)
            {
                actualBookmarkCount++;
            }

            ///////////////////////////////////////////////////////////////

            // Arrange
            Guid b1Guid    = new Guid("ffffffff-4444-4444-4444-222222222222");
            Guid wrongGuid = new Guid("99999999-1111-4444-4444-222222222222");

            // Act
            bookmarkResult = controller.Delete(wrongGuid);
            message        = await bookmarkResult.ExecuteAsync(new System.Threading.CancellationToken());

            // Assert
            Assert.AreEqual(HttpStatusCode.BadRequest, message.StatusCode);

            // Act
            bookmarkResult = controller.Delete(b1Guid);
            message        = await bookmarkResult.ExecuteAsync(new System.Threading.CancellationToken());

            // Assert
            Assert.AreEqual(HttpStatusCode.OK, message.StatusCode);

            ///////////////////////////////////////////////////////////////

            // Check that there is one less Bookmark

            // Arrange
            int expectedBookmarkCount = actualBookmarkCount - 1;

            actualBookmarkCount = 0;

            // Act
            bookmarkResult = controller.Get();
            message        = await bookmarkResult.ExecuteAsync(new System.Threading.CancellationToken());

            bookmarks = await message.Content.ReadAsAsync <IEnumerable <Bookmark> >();

            foreach (var b in bookmarks)
            {
                actualBookmarkCount++;
            }

            Assert.AreEqual(expectedBookmarkCount, actualBookmarkCount);
        }
Esempio n. 2
0
        public void Delete()
        {
            // Arrange
            BookmarksController controller = new BookmarksController(this.BookmarksRepository);

            // Act
            controller.Delete(5);

            // Assert
        }