public ReceivingProtocolTests(SharedTestDirectory testDirectory) { _logger = new RecordingLogger(); _scheduler = new TestScheduler(); _store = new LmdbMessageStore(testDirectory.CreateNewDirectoryForTest()); _protocol = new ReceivingProtocol(_store, _logger, _scheduler); }
public void SetUp() { peers.ClearAll(); sources.ClearAll(); theGraph = new ChannelGraph { NodeId = "Test@Local" }; theGraph.AddReplyChannel("memory", "memory://1".ToUri()); theCurrentNode = new TransportNode(theGraph); theLogger = new RecordingLogger(); theSubscriptions = new SubscriptionRepository(theGraph, new InMemorySubscriptionPersistence()); theSubscriptions.Persist(theCurrentNode); settings = new HealthMonitoringSettings { TaskAvailabilityCheckTimeout = 5.Seconds(), }; _controller = new Lazy <PersistentTaskController>(() => { var controller = new PersistentTaskController(theGraph, theLogger, this, sources.ToArray()); sources.SelectMany(x => x.FakeTasks()).Select(x => x.Subject) .Each(subject => controller.FindAgent(subject)); return(controller); }); theContextIs(); }
public BaseFacts(ITestOutputHelper output) { _downloadDataClient = new Mock <IDownloadDataClient>(); _verifiedPackagesDataClient = new Mock <IVerifiedPackagesDataClient>(); _popularityTransferDataClient = new Mock <IPopularityTransferDataClient>(); _telemetryService = new Mock <IAzureSearchTelemetryService>(); _logger = output.GetLogger <AuxiliaryDataCache>(); _token = CancellationToken.None; _downloadData = Data.GetAuxiliaryFileResult(new DownloadData(), "downloads-etag"); _verifiedPackages = Data.GetAuxiliaryFileResult(new HashSet <string>(StringComparer.OrdinalIgnoreCase), "verified-packages-etag"); _popularityTransfers = Data.GetAuxiliaryFileResult(new PopularityTransferData(), "popularity-transfer-etag"); _downloadDataClient .Setup(x => x.ReadLatestIndexedAsync(It.IsAny <IAccessCondition>(), It.IsAny <StringCache>())) .ReturnsAsync(() => _downloadData); _verifiedPackagesDataClient .Setup(x => x.ReadLatestAsync(It.IsAny <IAccessCondition>(), It.IsAny <StringCache>())) .ReturnsAsync(() => _verifiedPackages); _popularityTransferDataClient .Setup(x => x.ReadLatestIndexedAsync(It.IsAny <IAccessCondition>(), It.IsAny <StringCache>())) .ReturnsAsync(() => _popularityTransfers); _target = new AuxiliaryDataCache( _downloadDataClient.Object, _verifiedPackagesDataClient.Object, _popularityTransferDataClient.Object, _telemetryService.Object, _logger); }
protected override void beforeEach() { logs = RecordLogging(); registered = new BinderTarget(); request = ClassUnderTest; }
public void start_with_empty_logs() { var logger = new RecordingLogger(); logger.DebugMessages.ShouldHaveCount(0); logger.InfoMessages.ShouldHaveCount(0); logger.ErrorMessages.ShouldHaveCount(0); }
public BaseFacts(ITestOutputHelper output) { _cloudBlobClient = new Mock <ICloudBlobClient>(); _cloudBlobContainer = new Mock <ICloudBlobContainer>(); _options = new Mock <IOptionsSnapshot <AzureSearchJobConfiguration> >(); _config = new AzureSearchJobConfiguration { StorageContainer = "container-name", }; _logger = output.GetLogger <BlobContainerBuilder>(); _retryDuration = TimeSpan.FromMilliseconds(10); _options .Setup(x => x.Value) .Returns(() => _config); _cloudBlobClient .Setup(x => x.GetContainerReference(It.IsAny <string>())) .Returns(() => _cloudBlobContainer.Object); _target = new BlobContainerBuilder( _cloudBlobClient.Object, _options.Object, _logger, _retryDuration); }
public void log_debug_message_should_be_formatted() { var logger = new RecordingLogger(); logger.Debug("Fun times {0}", "at ridgemont high"); var logEntry = logger.DebugMessages.OfType<StringMessage>().First(); logEntry.Message.ShouldEqual("Fun times at ridgemont high"); }
public void log_info_with_func_message_should_log() { var logger = new RecordingLogger(); logger.Info(() => "Stale information"); var logEntry = logger.InfoMessages.OfType<StringMessage>().First(); logEntry.Message.ShouldEqual("Stale information"); }
public BaseFacts(ITestOutputHelper output) { _collector = new Mock<ICollector>(); _storageFactory = new Mock<IStorageFactory>(); _httpMessageHandler = new Mock<TestHttpMessageHandler>() { CallBase = true }; _blobContainerBuilder = new Mock<IBlobContainerBuilder>(); _indexBuilder = new Mock<IIndexBuilder>(); _options = new Mock<IOptionsSnapshot<Catalog2AzureSearchConfiguration>>(); _logger = output.GetLogger<Catalog2AzureSearchCommand>(); _config = new Catalog2AzureSearchConfiguration { StorageConnectionString = "UseDevelopmentStorage=true", StorageContainer = "container-name", }; _storage = new TestCursorStorage(new Uri("https://example/base/")); _options.Setup(x => x.Value).Returns(() => _config); _storageFactory.Setup(x => x.Create(It.IsAny<string>())).Returns(() => _storage); _target = new Catalog2AzureSearchCommand( _collector.Object, _storageFactory.Object, () => _httpMessageHandler.Object, _blobContainerBuilder.Object, _indexBuilder.Object, _options.Object, _logger); }
public void SetUp() { foo1 = new JobStatusDTO { JobKey = "1", NodeName = "foo" }; foo2 = new JobStatusDTO { JobKey = "2", NodeName = "foo" }; foo3 = new JobStatusDTO { JobKey = "3", NodeName = "foo" }; bar1 = new JobStatusDTO { JobKey = "1", NodeName = "bar" }; bar2 = new JobStatusDTO { JobKey = "2", NodeName = "bar" }; thePersistence = new InMemorySchedulePersistence(); thePersistence.Persist(new[] { foo1, foo2, foo3, bar1, bar2 }); theLogger = new RecordingLogger(); theStatusMonitor = new ScheduleStatusMonitor(theChannelGraph, new ScheduledJobGraph(), thePersistence, theLogger, SystemTime.Default()); }
public BaseFacts(ITestOutputHelper output) { _serviceClient = new Mock <ISearchServiceClientWrapper>(); _indexesOperations = new Mock <IIndexesOperationsWrapper>(); _options = new Mock <IOptionsSnapshot <AzureSearchJobConfiguration> >(); _config = new AzureSearchJobConfiguration { SearchIndexName = "search", HijackIndexName = "hijack", Scoring = new AzureSearchScoringConfiguration { FieldWeights = new Dictionary <string, double> { { nameof(IndexFields.PackageId), 3.0 }, { nameof(IndexFields.TokenizedPackageId), 4.0 }, }, DownloadScoreBoost = 5.0, } }; _logger = output.GetLogger <IndexBuilder>(); _options .Setup(x => x.Value) .Returns(() => _config); _serviceClient .Setup(x => x.Indexes) .Returns(() => _indexesOperations.Object); _target = new IndexBuilder( _serviceClient.Object, _options.Object, _logger); }
public Facts(ITestOutputHelper output) { _id = "NuGet.Versioning"; _accessCondition = new Mock <IAccessCondition>(); _versionList = new VersionListData(new Dictionary <string, VersionPropertiesData> { { "2.0.0", new VersionPropertiesData(listed: true, semVer2: false) }, }); _cloudBlobClient = new Mock <ICloudBlobClient>(); _cloudBlobContainer = new Mock <ICloudBlobContainer>(); _cloudBlob = new Mock <ISimpleCloudBlob>(); _options = new Mock <IOptionsSnapshot <AzureSearchJobConfiguration> >(); _logger = output.GetLogger <VersionListDataClient>(); _config = new AzureSearchJobConfiguration { StorageContainer = "unit-test-container", }; _options .Setup(x => x.Value) .Returns(() => _config); _cloudBlobClient .Setup(x => x.GetContainerReference(It.IsAny <string>())) .Returns(() => _cloudBlobContainer.Object); _cloudBlobContainer .Setup(x => x.GetBlobReference(It.IsAny <string>())) .Returns(() => _cloudBlob.Object); _cloudBlob .Setup(x => x.UploadFromStreamAsync(It.IsAny <Stream>(), It.IsAny <AccessCondition>())) .Returns(Task.CompletedTask) .Callback <Stream, AccessCondition>((s, _) => { using (s) using (var buffer = new MemoryStream()) { s.CopyTo(buffer); var bytes = buffer.ToArray(); _savedBytes.Add(bytes); _savedStrings.Add(Encoding.UTF8.GetString(bytes)); } }); _cloudBlob .Setup(x => x.OpenReadAsync(It.IsAny <AccessCondition>())) .ThrowsAsync(new StorageException( new RequestResult { HttpStatusCode = (int)HttpStatusCode.NotFound, }, message: "Not found.", inner: null)); _cloudBlob .Setup(x => x.Properties) .Returns(new CloudBlockBlob(new Uri("https://example/blob")).Properties); _target = new VersionListDataClient( _cloudBlobClient.Object, _options.Object, _logger); }
public RecordingLogger RecordLogging() { var logger = new RecordingLogger(); Services.Inject <ILogger>(logger); return(logger); }
public void log_error_should_be_recorded() { var logger = new RecordingLogger(); logger.Error("Error logged", new InvalidOperationException("blah")); var logEntry = logger.ErrorMessages.OfType<ExceptionReport>().First(); logEntry.Message.ShouldEqual("Error logged"); logEntry.ExceptionType.ShouldEqual(typeof(InvalidOperationException).Name); }
public static RecordingLogger RecordLogging <T>(this RhinoAutoMocker <T> mocker) where T : class { var logger = new RecordingLogger(); mocker.Inject <ILogger>(logger); return(logger); }
public void SetUp() { recordingLogger = new RecordingLogger(); events = new EventAggregator(() => recordingLogger, new IListener[0]); handler = new StubMessage1Handler(); events.AddListener(handler); }
public async Task correctly_correlates_by_stream() { var streams = new List <EventStream>(); var logger = new RecordingLogger(); using (var session = theStore.LightweightSession()) { session.Logger = logger; for (int i = 0; i < 20; i++) { var joined = new MembersJoined { Day = i, Location = Guid.NewGuid().ToString(), Members = new string[] { Guid.NewGuid().ToString() } }; var departed = new MembersDeparted { Day = i, Location = Guid.NewGuid().ToString(), Members = new[] { Guid.NewGuid().ToString() } }; var reached = new ArrivedAtLocation { Day = i, Location = Guid.NewGuid().ToString() }; session.Events.Append(Guid.NewGuid(), joined, departed, reached); } await session.SaveChangesAsync().ConfigureAwait(false); streams.AddRange(logger.LastCommit.GetStreams()); } var types = new Type[] { typeof(MembersJoined), typeof(MembersDeparted), typeof(ArrivedAtLocation) }; var settings = new DaemonSettings { LeadingEdgeBuffer = 0.Seconds() }; using (var data = new Fetcher(theStore, settings, new AsyncOptions(), Substitute.For <IDaemonLogger>(), new StubErrorHandler(), types)) { var page = await data.FetchNextPage(0).ConfigureAwait(false); foreach (var stream in page.Streams) { var existing = streams.Single(x => x.Id == stream.Id); existing.Events.Select(x => x.Id) .ShouldHaveTheSameElementsAs(stream.Events.Select(x => x.Id)); } } }
public void log_info_with_func_message_should_log() { var logger = new RecordingLogger(); logger.Info(() => "Stale information"); var logEntry = logger.InfoMessages.OfType <StringMessage>().First(); logEntry.Message.ShouldEqual("Stale information"); }
public void log_debug_message_should_be_formatted() { var logger = new RecordingLogger(); logger.Debug("Fun times {0}", "at ridgemont high"); var logEntry = logger.DebugMessages.OfType <StringMessage>().First(); logEntry.Message.ShouldEqual("Fun times at ridgemont high"); }
public void log_error_should_be_recorded() { var logger = new RecordingLogger(); logger.Error("Error logged", new InvalidOperationException("blah")); var logEntry = logger.ErrorMessages.OfType <ExceptionReport>().First(); logEntry.Message.ShouldEqual("Error logged"); logEntry.ExceptionType.ShouldEqual(typeof(InvalidOperationException).Name); }
public ProduceWorkAsync(ITestOutputHelper output) { _entitiesContextFactory = new Mock <IEntitiesContextFactory>(); _entitiesContext = new Mock <IEntitiesContext>(); _options = new Mock <IOptionsSnapshot <Db2AzureSearchConfiguration> >(); _config = new Db2AzureSearchConfiguration { DatabaseBatchSize = 2, }; _developmentOptions = new Mock <IOptionsSnapshot <Db2AzureSearchDevelopmentConfiguration> >(); _developmentConfig = new Db2AzureSearchDevelopmentConfiguration(); _logger = output.GetLogger <NewPackageRegistrationProducer>(); _packageRegistrations = DbSetMockFactory.Create <PackageRegistration>(); _packages = DbSetMockFactory.Create <Package>(); _work = new ConcurrentBag <NewPackageRegistration>(); _token = CancellationToken.None; _auxiliaryFileClient = new Mock <IAuxiliaryFileClient>(); _excludedPackages = new HashSet <string>(StringComparer.OrdinalIgnoreCase); _auxiliaryFileClient .Setup(x => x.LoadExcludedPackagesAsync()) .ReturnsAsync(() => _excludedPackages); _downloads = new DownloadData(); _auxiliaryFileClient .Setup(x => x.LoadDownloadDataAsync()) .ReturnsAsync(() => _downloads); _downloadOverrides = new Dictionary <string, long>(StringComparer.OrdinalIgnoreCase); _auxiliaryFileClient .Setup(x => x.LoadDownloadOverridesAsync()) .ReturnsAsync(() => _downloadOverrides); _entitiesContextFactory .Setup(x => x.CreateAsync(It.IsAny <bool>())) .ReturnsAsync(() => _entitiesContext.Object); _entitiesContext .Setup(x => x.Set <PackageRegistration>()) .Returns(() => _packageRegistrations); _entitiesContext .Setup(x => x.Set <Package>()) .Returns(() => _packages); _options .Setup(x => x.Value) .Returns(() => _config); _developmentOptions .Setup(x => x.Value) .Returns(() => _developmentConfig); _target = new NewPackageRegistrationProducer( _entitiesContextFactory.Object, _auxiliaryFileClient.Object, _options.Object, _developmentOptions.Object, _logger); }
public BaseFacts(ITestOutputHelper output) { _registrationClient = new Mock <IRegistrationClient>(); _catalogClient = new Mock <ICatalogClient>(); _options = new Mock <IOptionsSnapshot <Catalog2AzureSearchConfiguration> >(); _config = new Catalog2AzureSearchConfiguration { MaxConcurrentBatches = 1, }; _telemetryService = new Mock <IAzureSearchTelemetryService>(); _logger = output.GetLogger <CatalogLeafFetcher>(); _options.Setup(x => x.Value).Returns(() => _config); _config.RegistrationsBaseUrl = "https://example/v3-registration/"; _versions = new List <IReadOnlyList <NuGetVersion> > { new List <NuGetVersion> { Parse("1.0.0"), }, new List <NuGetVersion> { Parse("1.0.0"), Parse("2.0.0-alpha"), }, new List <NuGetVersion> { Parse("1.0.0"), Parse("3.0.0+git"), }, new List <NuGetVersion> { Parse("1.0.0"), Parse("2.0.0-alpha"), Parse("3.0.0+git"), Parse("4.0.0-beta.1"), }, }; _eachVersion = new[] { Parse("1.0.0"), Parse("2.0.0-alpha"), Parse("3.0.0+git"), Parse("4.0.0-beta.1"), }; _target = new CatalogLeafFetcher( _registrationClient.Object, _catalogClient.Object, _options.Object, _telemetryService.Object, _logger); }
protected override void beforeEach() { logs = Services.RecordLogging(); correlation = new BehaviorCorrelation(new FakeNode()); Services.Inject(correlation); inner = MockFor <IActionBehavior>(); ClassUnderTest.Inner = inner; ClassUnderTest.InvokePartial(); }
public void SetUp() { theServiceBus = new RiggedServiceBus(); theSubscriptions = MockRepository.GenerateMock <ISubscriptionRepository>(); theLogger = new RecordingLogger(); thePeer = new TransportPeer(new HealthMonitoringSettings(), theNode, theSubscriptions, theServiceBus, theLogger); theSubscriptions.Stub(x => x.FindPeer(theNode.Id)) .Return(theNode); theContextIs(); }
public void SetUp() { theServiceBus = new RiggedServiceBus(); theSubscriptions = MockRepository.GenerateMock<ISubscriptionRepository>(); theLogger = new RecordingLogger(); thePeer = new TransportPeer(new HealthMonitoringSettings(), theNode, theSubscriptions, theServiceBus, theLogger); theSubscriptions.Stub(x => x.FindPeer(theNode.Id)) .Return(theNode); theContextIs(); }
protected override void beforeEach() { logs = Services.RecordLogging(); correlation = new BehaviorCorrelation(new FakeNode()); Services.Inject(correlation); Services.Inject <IExceptionHandlingObserver>(new ExceptionHandlingObserver()); exception = new NotImplementedException(); inner = MockFor <IActionBehavior>(); inner.Expect(x => x.InvokePartial()).Throw(exception); ClassUnderTest.Inner = inner; }
public void SetUp() { theGraph = new ChannelGraph(); theNode = new ChannelNode(); theNode.Channel = new InMemoryChannel(new Uri("memory://foo")); theInvoker = new RecordingHandlerPipeline(); theCallback = MockRepository.GenerateMock <IMessageCallback>(); theLogger = new RecordingLogger(); theReceiver = new Receiver(theInvoker, theGraph, theNode); }
public void doesnt_throw_if_receive_only_fails_intermittently() { var channel = new FakeChannel { StopAfter = 20 }; var node = new ChannelNode { Channel = channel, Scheduler = new FakeScheduler() }; var logger = new RecordingLogger(); var receiver = new RecordingReceiver(); node.StartReceiving(receiver, logger); channel.HitCount.ShouldBe(20); }
public ReceiverTests(SharedTestDirectory testDirectory) { var port = PortFinder.FindPort(); //to make it possible to run in parallel _endpoint = new IPEndPoint(IPAddress.Loopback, port); _logger = new RecordingLogger(); _store = new LmdbMessageStore(testDirectory.CreateNewDirectoryForTest()); _store.CreateQueue("test"); _sendingStore = new LmdbMessageStore(testDirectory.CreateNewDirectoryForTest()); _sendingStore.CreateQueue("test"); _sender = new SendingProtocol(_sendingStore, _logger); var protocol = new ReceivingProtocol(_store, _logger); _receiver = new Receiver(_endpoint, protocol, new NoSecurity(), _logger); }
public BaseFacts(ITestOutputHelper output) { _blobClient = new Mock <ICloudBlobClient>(); _config = new Db2AzureSearchConfiguration(); _configStorage = new AuxiliaryDataStorageConfiguration(); _options = new Mock <IOptionsSnapshot <Db2AzureSearchConfiguration> >(); _optionsStorage = new Mock <IOptionsSnapshot <AuxiliaryDataStorageConfiguration> >(); _telemetryService = new Mock <IAzureSearchTelemetryService>(); _logger = output.GetLogger <AuxiliaryFileClient>(); _container = new Mock <ICloudBlobContainer>(); _blob = new Mock <ISimpleCloudBlob>(); _etag = "\"something\""; _config.AuxiliaryDataStorageContainer = "my-container"; _config.AuxiliaryDataStorageDownloadsPath = "my-downloads.json"; _config.AuxiliaryDataStorageDownloadOverridesPath = "my-download-overrides.json"; _config.AuxiliaryDataStorageVerifiedPackagesPath = "my-verified-packages.json"; _config.AuxiliaryDataStorageExcludedPackagesPath = "my-excluded-packages.json"; _options.Setup(x => x.Value).Returns(() => _config); _configStorage.AuxiliaryDataStorageContainer = "my-container"; _configStorage.AuxiliaryDataStorageDownloadsPath = "my-downloads.json"; _configStorage.AuxiliaryDataStorageDownloadOverridesPath = "my-download-overrides.json"; _configStorage.AuxiliaryDataStorageExcludedPackagesPath = "my-excluded-packages.json"; _optionsStorage.Setup(x => x.Value).Returns(() => _configStorage); _blobClient .Setup(x => x.GetContainerReference(It.IsAny <string>())) .Returns(() => _container.Object); _container .Setup(x => x.GetBlobReference(It.IsAny <string>())) .Returns(() => _blob.Object); _blob .Setup(x => x.OpenReadAsync(It.IsAny <AccessCondition>())) .ReturnsAsync(() => new MemoryStream(Encoding.UTF8.GetBytes("[]"))); _blob .Setup(x => x.ETag) .Returns(() => _etag); _blob .Setup(x => x.Properties) .Returns(new BlobProperties()); _target = new AuxiliaryFileClient( _blobClient.Object, _optionsStorage.Object, _telemetryService.Object, _logger); }
public void continuous_receive_errors() { var logger = new RecordingLogger(); var receiver = new RecordingReceiver(); var channel = MockRepository.GenerateMock<IChannel>(); channel.Expect(x => x.Receive(receiver)) .Throw(new Exception("I failed")); var node = new ChannelNode { Channel = channel, Scheduler = new FakeScheduler() }; Assert.Throws<ReceiveFailureException>(() => node.StartReceiving(receiver, logger)); }
public void continuous_receive_errors() { var logger = new RecordingLogger(); var receiver = new RecordingReceiver(); var channel = MockRepository.GenerateMock <IChannel>(); channel.Expect(x => x.Receive(receiver)) .Throw(new Exception("I failed")); var node = new ChannelNode { Channel = channel, Scheduler = new FakeScheduler() }; Assert.Throws <ReceiveFailureException>(() => node.StartReceiving(receiver, logger)); }
public BaseFacts(ITestOutputHelper output) { _search = new Mock <ISearchDocumentBuilder>(); _hijack = new Mock <IHijackDocumentBuilder>(); _logger = output.GetLogger <PackageEntityIndexActionBuilder>(); _search .Setup(x => x.LatestFlagsOrNull(It.IsAny <VersionLists>(), It.IsAny <SearchFilters>())) .Returns <VersionLists, SearchFilters>((vl, sf) => new SearchDocument.LatestFlags( vl.GetLatestVersionInfoOrNull(sf), isLatestStable: true, isLatest: true)); _target = new PackageEntityIndexActionBuilder( _search.Object, _hijack.Object, _logger); }
protected override void beforeEach() { theHandlers = Services.CreateMockArrayFor <IEnvelopeHandler>(5); theLogger = new RecordingLogger(); Services.Inject <ILogger>(theLogger); theContinuation = MockFor <IContinuation>(); theEnvelope = ObjectMother.Envelope(); theHandlers[3].Stub(x => x.Handle(theEnvelope)) .Return(theContinuation); theHandlers[4].Stub(x => x.Handle(theEnvelope)) .Return(MockRepository.GenerateMock <IContinuation>()); theFoundContinuation = ClassUnderTest.FindContinuation(theEnvelope); }
protected override void beforeEach() { logs = Services.RecordLogging(); correlation = new BehaviorCorrelation(new FakeNode()); Services.Inject(correlation); Services.Inject <IExceptionHandlingObserver>(new ExceptionHandlingObserver()); exception = new NotImplementedException(); inner = MockFor <IActionBehavior>(); inner.Expect(x => x.InvokePartial()).Throw(exception); MockFor <IDebugDetector>().Stub(x => x.IsDebugCall()).Return(true); ClassUnderTest.Inner = inner; Exception <NotImplementedException> .ShouldBeThrownBy(() => { ClassUnderTest.InvokePartial(); }); }
public void SetUp() { theEnvelope = ObjectMother.Envelope(); theEnvelope.Message = new object(); theContinuationContext = new TestContinuationContext(); theContext = new FubuTransportation.Runtime.Invocation.InvocationContext(theEnvelope, new HandlerChain()); theContext.EnqueueCascading(new object()); theContext.EnqueueCascading(new object()); theContext.EnqueueCascading(new object()); theSender = new RecordingEnvelopeSender(); theContinuation = new ChainSuccessContinuation(theContext); theLogger = new RecordingLogger(); theContinuation.Execute(theEnvelope, theContinuationContext); }
public void Setup() { _logger = new RecordingLogger(); }
public async Task correctly_correlates_by_stream() { var streams = new List<EventStream>(); var logger = new RecordingLogger(); using (var session = theStore.LightweightSession()) { session.Logger = logger; for (int i = 0; i < 20; i++) { var joined = new MembersJoined { Day = i, Location = Guid.NewGuid().ToString(), Members = new string[] { Guid.NewGuid().ToString() } }; var departed = new MembersDeparted { Day = i, Location = Guid.NewGuid().ToString(), Members = new[] { Guid.NewGuid().ToString() } }; var reached = new ArrivedAtLocation { Day = i, Location = Guid.NewGuid().ToString() }; session.Events.Append(Guid.NewGuid(), joined, departed, reached); } await session.SaveChangesAsync().ConfigureAwait(false); streams.AddRange(logger.LastCommit.GetStreams()); } var types = new Type[] { typeof(MembersJoined), typeof(MembersDeparted), typeof(ArrivedAtLocation) }; var settings = new DaemonSettings { LeadingEdgeBuffer = 0.Seconds() }; using (var data = new Fetcher(theStore, settings, new AsyncOptions(), Substitute.For<IDaemonLogger>(), new StubErrorHandler(), types)) { var page = await data.FetchNextPage(0).ConfigureAwait(false); foreach (var stream in page.Streams) { var existing = streams.Single(x => x.Id == stream.Id); existing.Events.Select(x => x.Id) .ShouldHaveTheSameElementsAs(stream.Events.Select(x => x.Id)); } } }
public void Setup() { _logger = new RecordingLogger(); ReceivingProtocol.Logger = _logger; }
public void Setup() { _logger = new RecordingLogger(); wasSuccessful = false; error = null; sender = new Sender(_logger) { Destination = new Endpoint("localhost", 23456), Messages = new[] { new Message { Data = new byte[] {1, 2, 4}, Id = MessageId.GenerateRandom(), Queue = "ag", SentAt = new DateTime(2004, 4, 4) }, }, Success = () => { wasSuccessful = true; }, }; }
public void ReceiveFailed_error_handling() { var node = new ChannelNode { Key = "TestKey", Channel = new FakeChannel { StopAfter = 2 }, Scheduler = new FakeScheduler() }; var logger = new RecordingLogger(); node.StartReceiving(new RecordingReceiver(), logger); logger.ErrorMessages.ShouldHaveCount(1); logger.InfoMessages.ShouldHaveCount(1); var message = logger.InfoMessages.Cast<ReceiveFailed>().Single(); message.ChannelKey.ShouldBe(node.Key); message.Exception.ShouldNotBeNull(); }