public async Task RecordsFeedback() { var model = new SearchSideBySideViewModel { SearchTerm = " json ", OldHits = 23, NewHits = 42, BetterSide = " new ", MostRelevantPackage = " NuGet.Core ", ExpectedPackages = " NuGet.Packaging, NuGet.Versioning ", Comments = " comments ", EmailAddress = " [email protected] ", }; var searchUrl = "https://localhost/experiments/search-sxs?q=json"; await Target.RecordFeedbackAsync(model, searchUrl); TelemetryService.Verify( x => x.TrackSearchSideBySideFeedback( "json", 23, 42, "new", "NuGet.Core", "NuGet.Packaging, NuGet.Versioning", true, true), Times.Once); MessageService.Verify( x => x.SendMessageAsync(It.IsAny <SearchSideBySideMessage>(), false, false), Times.Once); }
public async Task ReturnsSearchResults() { var searchTerm = " json "; var result = await Target.SearchAsync(searchTerm, CurrentUser); Assert.Equal("json", result.SearchTerm); Assert.True(result.OldSuccess, "The old search should have succeeded."); Assert.Equal(OldSearchResults.Hits, result.OldHits); var oldA = Assert.Single(result.OldItems); Assert.Equal("1.0.0", oldA.Version); Assert.True(result.NewSuccess, "The new search should have succeeded."); Assert.Equal(NewSearchResults.Hits, result.NewHits); Assert.Equal(2, result.NewItems.Count); Assert.Equal("2.0.0", result.NewItems[0].Version); Assert.Equal("3.0.0", result.NewItems[1].Version); Assert.Equal("*****@*****.**", result.EmailAddress); OldSearchService.Verify(x => x.Search(It.IsAny <SearchFilter>()), Times.Once); NewSearchService.Verify(x => x.Search(It.IsAny <SearchFilter>()), Times.Once); TelemetryService.Verify(x => x.TrackSearchSideBySide("json", true, 1, true, 2), Times.Once); AssertSearchFilters(result.SearchTerm); }
public async Task ReturnsEmptyModelWithNoSearchTerm(string searchTerm) { var result = await Target.SearchAsync(searchTerm, CurrentUser); Assert.Equal(string.Empty, result.SearchTerm); Assert.Equal("*****@*****.**", result.EmailAddress); OldSearchService.Verify(x => x.Search(It.IsAny <SearchFilter>()), Times.Never); NewSearchService.Verify(x => x.Search(It.IsAny <SearchFilter>()), Times.Never); TelemetryService.Verify( x => x.TrackSearchSideBySide(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <int>()), Times.Never); }
public void ParsesValidVersion2(string input, int previewSearchBucket, int packageDependentBucket) { TelemetryService.Setup(t => t.TrackABTestEnrollmentUpgraded(2, 3, It.IsAny <int>(), It.IsAny <int>())); var success = Target.TryDeserialize(input, out var enrollment); TelemetryService.Verify(t => t.TrackABTestEnrollmentUpgraded(2, 3, It.IsAny <int>(), It.IsAny <int>()), Times.Once); Assert.True(success, "The derialization should have succeeded."); Assert.NotNull(enrollment); Assert.Equal(ABTestEnrollmentState.Upgraded, enrollment.State); Assert.Equal(3, enrollment.SchemaVersion); Assert.Equal(previewSearchBucket, enrollment.PreviewSearchBucket); Assert.Equal(packageDependentBucket, enrollment.PackageDependentBucket); }