public async Task User_can_add_a_shoutout_message_to_their_profile()
        {
            // arrange
            var username             = "******";
            var expectedShoutMessage = $"This is my shoutout message! Here is my URL:";
            var twitchLibMessage     = TwitchLibMessageBuilder.Create()
                                       .WithUsername(username)
                                       .Build();
            var chatMessage = ChatMessageBuilder.Create()
                              .WithTwitchLibMessage(twitchLibMessage)
                              .WithMessage($"!profile-shout {expectedShoutMessage}")
                              .Build();
            var request = new ModifyProfile(chatMessage);

            // act
            await _handler.Handle(request, CancellationToken.None);

            // assert
            _mockMutateInBuilder.Verify(x =>
                                        x.Upsert("shoutMessage", expectedShoutMessage, true),
                                        Times.Once);
        }
示例#2
0
        public async Task Should_not_create_a_profile_if_one_already_exists()
        {
            // arrange
            var username         = "******";
            var twitchLibMessage = TwitchLibMessageBuilder.Create()
                                   .WithUsername(username)
                                   .Build();
            var chatMessage = ChatMessageBuilder.Create()
                              .WithTwitchLibMessage(twitchLibMessage)
                              .WithMessage("notnull")
                              .Build();
            var request = new ModifyProfile(chatMessage);

            MockCollection.Setup(x => x.ExistsAsync(username, null))
            .ReturnsAsync(new FakeExistsResult(true));

            // act
            await _handler.Handle(request, CancellationToken.None);

            // assert
            MockCollection.Verify(x => x.InsertAsync(username, It.IsAny <TwitcherProfile>(), null), Times.Never);
        }
        public async Task Should_create_a_profile_if_one_doesnt_exist()
        {
            // arrange
            var username         = "******";
            var twitchLibMessage = TwitchLibMessageBuilder.Create()
                                   .WithUsername(username)
                                   .Build();
            var chatMessage = ChatMessageBuilder.Create()
                              .WithTwitchLibMessage(twitchLibMessage)
                              .WithMessage("doesntmatter")
                              .Build();
            var request = new ModifyProfile(chatMessage);

            // act
            await _handler.Handle(request, CancellationToken.None);

            // assert
            _mockBucket.Verify(x => x.InsertAsync(It.Is <IDocument <TwitcherProfile> >(
                                                      y =>
                                                      y.Id == username &&
                                                      y.Content.Type == "profile")), Times.Once);
        }
示例#4
0
        public async Task Should_create_a_profile_if_one_doesnt_exist()
        {
            // arrange
            var username         = "******";
            var twitchLibMessage = TwitchLibMessageBuilder.Create()
                                   .WithUsername(username)
                                   .Build();
            var chatMessage = ChatMessageBuilder.Create()
                              .WithTwitchLibMessage(twitchLibMessage)
                              .WithMessage("doesntmatter")
                              .Build();
            var request = new ModifyProfile(chatMessage);

            MockCollection.Setup(m => m.ExistsAsync(username, null))
            .ReturnsAsync(new FakeExistsResult(false));

            // act
            await _handler.Handle(request, CancellationToken.None);

            // assert
            MockCollection.Verify(x => x.InsertAsync(username, It.Is <TwitcherProfile>(
                                                         y => y.Type == "profile"), null), Times.Once);
        }
        public async Task Should_not_create_a_profile_if_one_already_exists()
        {
            // arrange
            var username         = "******";
            var twitchLibMessage = TwitchLibMessageBuilder.Create()
                                   .WithUsername(username)
                                   .Build();
            var chatMessage = ChatMessageBuilder.Create()
                              .WithTwitchLibMessage(twitchLibMessage)
                              .WithMessage("notnull")
                              .Build();
            var request = new ModifyProfile(chatMessage);

            _mockBucket.Setup(x => x.ExistsAsync(username)).ReturnsAsync(true);

            // act
            await _handler.Handle(request, CancellationToken.None);

            // assert
            _mockBucket.Verify(x => x.InsertAsync(It.Is <IDocument <TwitcherProfile> >(
                                                      y =>
                                                      y.Id == username)), Times.Never);
        }
        /// <summary>
        /// Closes the active window and regenerates/open the Modify Profil Window for the connected student
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void profileBtn_Click(object sender, EventArgs e)
        {
            ModifyProfile mod = new ModifyProfile(connection, student.ID);

            mod.Show();
        }
示例#7
0
        /// <summary>
        /// Opens the modify profile window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            ModifyProfile modWin = new ModifyProfile(connection, admin.ID);

            modWin.Show();
        }