コード例 #1
0
        public void Unsubscribes_on_Dispose()
        {
            var sut = new Server.Directors.OpenLogFileDirector(_eventBus, _runtimeClientContext);
            sut.Initiate("one", new DomainModel.Request<DomainModel.FileDownloadOptions> { Token = "SOMETOKEN", Message = new DomainModel.FileDownloadOptions() });
            sut.Dispose();

            A.CallTo(() => _eventBus.Unsubscribe(A<object>.That.IsSameAs(sut))).MustHaveHappened(Repeated.Exactly.Once);
        }
コード例 #2
0
        public void HappyPath()
        {
            var sut = new Server.Directors.OpenLogFileDirector(_eventBus, _runtimeClientContext);

            var fileContent = new byte[10];
            var successfulMessage = DomainModel.Response<byte[]>.Success("SOMETOKEN", fileContent);

            A.CallTo(() => _runtimeClient.BeginOpenLogFile(A<DomainModel.Request<DomainModel.FileDownloadOptions>>.Ignored))
                .Invokes(() => sut.Handle(DomainModel.Response<byte[]>.Success("SOMETOKEN", fileContent)));

            sut.Initiate("one", new DomainModel.Request<DomainModel.FileDownloadOptions> { Token = "SOMETOKEN", Message = new DomainModel.FileDownloadOptions { RelativeOrAbsolutePath = "some/path/to/file.log" } });
            sut.PendingTask.Wait();

            sut.PendingTask.Result.Message.ShouldBeSameAs(fileContent);
            A.CallTo(() => _eventBus.Subscribe(A<object>.That.IsSameAs(sut), A<string>.That.IsEqualTo("SOMETOKEN"))).MustHaveHappened();
        }
コード例 #3
0
        public void Throws_A_TimeoutException_When_Client_Does_Not_Respond()
        {
            var sut = new Server.Directors.OpenLogFileDirector(_eventBus, _runtimeClientContext, 1);

            Should.Throw<TimeoutException>(() =>
            {
                try
                {
                    sut.Initiate("one", new DomainModel.Request<DomainModel.FileDownloadOptions> { Token = "SOMETOKEN", Message = new DomainModel.FileDownloadOptions() });
                    sut.PendingTask.Wait();
                }
                catch (AggregateException ex)
                {
                    throw ex.HeadException();
                }
            });

            sut.PendingTask.Status.ShouldBe(TaskStatus.Faulted);
        }