Beispiel #1
0
        private (Item, Item) MockRepository(Guid id, DateTime currentTime)
        {
            var receivedItem = ItemFactory.CreateItem(Guid.Empty, "This is a text.");
            var expectedItem = ItemFactory.CreateItem(id, receivedItem.Text, currentTime, currentTime);

            _itemRepository.CreateAsync(ArgExtended.IsItem(expectedItem)).Returns(expectedItem);

            return(receivedItem, expectedItem);
        }
        public async Task UpdateAsync_ExistingItem_UpdatesItem()
        {
            var currentTime = new DateTime(2018, 10, 1, 8, 42, 5);
            var id          = Guid.Parse("F7148339-E162-4657-B886-C29BF6A2D312");

            var(originalItem, receivedItem, changedItem) = CreateItems(id, currentTime);

            _itemObtainingService.ExistsAsync(id).Returns(true);
            _itemObtainingService.GetById(id).Returns(originalItem);
            _dateTimeWrapper.CurrentDateTime().Returns(currentTime, DateTime.MinValue);

            await _itemUpdatingService.UpdateAsync(receivedItem);

            await _itemRepository.Received(1).UpdateAsync(ArgExtended.IsItem(changedItem));
        }