Beispiel #1
0
        public async Task FindOneRandomUser()
        {
            var interest = new Interest
            {
                Name = StringGenerator.GenerateRandomString(10)
            };

            await _interestRepository.AddAsync(interest);

            interest.Id.Should().NotBeEmpty();

            var publicInfo1 = new PublicInfo
            {
                NickName   = StringGenerator.GenerateNameWithTimeStamp("user"),
                PictureUrl = StringGenerator.GenerateRandomString(50)
            };

            var user1 = new User
            {
                Email      = StringGenerator.GenerateEmailWithTimeStamp("rnd_user", "mail.com"),
                Gender     = Gender.Female,
                LookingFor = Gender.Male,
                PublicInfo = publicInfo1
            };

            await _userRepository.AddAsync(user1);

            user1.Id.Should().NotBeEmpty();

            var publicInfo2 = new PublicInfo
            {
                NickName   = StringGenerator.GenerateNameWithTimeStamp("user"),
                PictureUrl = StringGenerator.GenerateRandomString(50)
            };

            var user2 = new User
            {
                Email      = StringGenerator.GenerateEmailWithTimeStamp("rnd_user", "mail.com"),
                Gender     = Gender.Male,
                LookingFor = Gender.Female,
                PublicInfo = publicInfo2
            };

            await _userRepository.AddAsync(user2);

            user2.Id.Should().NotBeEmpty();

            var  userService1 = new UserService(new ReturnsZeroRandomGeneratorMock());
            User rndUser1     = await userService1.GetOneRandomUser(x => x.Gender == Gender.Female);

            Assert.NotNull(rndUser1);

            var  userService2 = new UserService(new ReturnsOneRandomGeneratorMock());
            User rndUser2     = await userService2.GetOneRandomUser(x => x.Gender == Gender.Female);

            Assert.NotNull(rndUser2);

            Assert.NotEqual(rndUser1.Id, rndUser2.Id);
        }