Ejemplo n.º 1
0
        public async Task Invalidate_request_when_item_does_not_exist()
        {
            // Arrange
            var contributorSub = Guid.NewGuid().ToString();
            var backpackId     = Guid.NewGuid();

            var contributor = new User
            {
                FirstName = "Contributor",
                LastName  = "User",
                Sub       = contributorSub
            };

            var backpack = new Domain.Entities.Backpack
            {
                Id   = backpackId,
                Name = "A backpack"
            };

            await _dbContext.Users.AddAsync(contributor);

            await _dbContext.Backpacks.AddAsync(backpack);

            await _dbContext.BackpacksToUsers.AddAsync(new BackpackToUser { Backpack = backpack, User = contributor });

            await _dbContext.SaveChangesAsync();

            var sut = new UpdateBackpackItemValidator(_dbContext);

            // Act
            bool isValid = await sut.IsValidAsync(new UpdateBackpackItem(contributorSub, Guid.NewGuid(), new BackpackItemRequest()));

            // Assert
            isValid.ShouldBeFalse();
        }
Ejemplo n.º 2
0
        public async Task Invalidate_request_when_no_user_found_by_sub(string sub)
        {
            // Arrange
            var sut = new UpdateBackpackItemValidator(_dbContext);

            // Act
            bool isValid = await sut.IsValidAsync(new UpdateBackpackItem(sub, Guid.NewGuid(), new BackpackItemRequest()));

            // Assert
            isValid.ShouldBeFalse();
        }