Beispiel #1
0
        public async Task Should_create_new_item()
        {
            // Arrange
            Item newItem = new Item {
                Id = Guid.NewGuid().ToString(), Author = "J. K. Rowling", HideAuthor = false, Title = "Fly Phising", Description = "I was wondering if you could tell if you have a book...", Votes = 0
            };

            ItemRepositoryMock.Setup(x => x.CreateNewItemAsync(newItem, default(CancellationToken))).ReturnsAsync(newItem.Id);
            ItemRepositoryMock.Setup(x => x.GetItemByIdAsync(newItem.Id, default(CancellationToken))).ReturnsAsync(newItem);

            // Act
            Item resultItem = await ServiceUnderTest.CreateItemAsync(newItem, default(CancellationToken));

            // Assert
            Assert.Same(newItem, resultItem);
        }