Esempio n. 1
0
        public async Task Validate_when_user_is_owner_of_backpack()
        {
            // Arrange
            string userSub = Guid.NewGuid().ToString();
            var    user    = new User
            {
                FirstName = "Integration",
                LastName  = "Test",
                Sub       = userSub
            };

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

            await _dbContext.Users.AddAsync(user);

            await _dbContext.Backpacks.AddAsync(backpack);

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

            await _dbContext.SaveChangesAsync();

            var sut = new GetBackpackContributorsValidator(_dbContext);

            // Act
            bool isValid = await sut.IsValidAsync(new GetBackpackContributors(userSub, backpack.Id));

            // Assert
            isValid.ShouldBeTrue();
        }
Esempio n. 2
0
        public async Task Invalidate_request_when_no_user_found_by_sub(string sub)
        {
            // Arrange
            var sut = new GetBackpackContributorsValidator(_dbContext);

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

            // Assert
            isValid.ShouldBeFalse();
        }
Esempio n. 3
0
        public async Task Invalidate_when_backpack_does_not_exist()
        {
            // Arrange
            string userSub = Guid.NewGuid().ToString();
            var    user    = new User
            {
                FirstName = "Integration",
                LastName  = "Test",
                Sub       = userSub
            };

            await _dbContext.Users.AddAsync(user);

            await _dbContext.SaveChangesAsync();

            var sut = new GetBackpackContributorsValidator(_dbContext);

            // Act
            bool isValid = await sut.IsValidAsync(new GetBackpackContributors(userSub, Guid.NewGuid()));

            // Assert
            isValid.ShouldBeFalse();
        }