public void Valid()
        {
            var profileValidationResult = ProfileValidationResult.CreateValid();

            Assert.True(profileValidationResult.IsValid);
            Assert.Equal("", profileValidationResult.UserId);
            Assert.Equal("", profileValidationResult.Errors);
        }
Example #2
0
        public async Task VerifyAllProfiles_NoProfileErrors()
        {
            var users = new List <SlackUser> {
                new SlackUser(), new SlackUser()
            };
            var creationResult = await CreateProfileBot(true);

            creationResult.SlackIntegration.Setup(s => s.GetAllUsers()).ReturnsAsync(users);
            creationResult.SlackProfileChecker.Setup(s => s.ValidateProfile(It.IsAny <SlackUser>()))
            .Returns(ProfileValidationResult.CreateValid());

            creationResult.SlackIntegration.Raise(s => s.MessageReceived += null,
                                                  MessageParserTests.CreateMessage(adminUser.Id, "validate all users"));

            creationResult.SlackIntegration.Verify(s => s.SendDirectMessage(adminUser.Id, "No profiles contain errors :)"));
        }
Example #3
0
        public async Task AnswerRegularUser_ValidProfile()
        {
            var user = new SlackUser {
                Id = "U1TBU8337"
            };
            var creationResult = await CreateProfileBot(true);

            var slackIntegration = creationResult.SlackIntegration;

            slackIntegration.Setup(s => s.GetUser("U1TBU8337")).ReturnsAsync(user);
            creationResult.SlackProfileChecker.Setup(s => s.ValidateProfile(It.IsAny <SlackUser>())).Returns(ProfileValidationResult.CreateValid());

            slackIntegration.Raise(s => s.MessageReceived += null,
                                   MessageParserTests.CreateMessage("U1TBU8337", "Any message"));

            slackIntegration.Verify(s => s.SendDirectMessage("U1TBU8337", "Checking your profile"));
            slackIntegration.Verify(s => s.SendDirectMessage("U1TBU8337", "Well done <@U1TBU8337>, your profile is complete"));
        }
Example #4
0
        public async Task NotifySingleProfile_ValidProfile()
        {
            var user = new SlackUser {
                Id = adminUser.Id
            };
            var creationResult = await CreateProfileBot(true);

            var slackIntegration = creationResult.SlackIntegration;

            slackIntegration.Setup(s => s.GetUser(adminUser.Id)).ReturnsAsync(user);
            creationResult.SlackProfileChecker.Setup(s => s.ValidateProfile(It.IsAny <SlackUser>())).Returns(ProfileValidationResult.CreateValid());

            slackIntegration.Raise(s => s.MessageReceived += null,
                                   MessageParserTests.CreateMessage(adminUser.Id, "Notify <@U1TBU8336>"));

            slackIntegration.Verify(s => s.SendDirectMessage(adminUser.Id, "Notifying <@U1TBU8336>"));
            slackIntegration.Verify(s => s.SendDirectMessage(adminUser.Id, "<@U1TBU8336> has a complete profile"));
        }