public void Index_Action_Should_Return_ViewResult_With_Filter()
        {
            var streamServiceFake = new Mock<IStreamService>();
            var controller = new HomeController(streamServiceFake.Object);
            var streamFilter = new StreamFilter { From = new DateTime(2005, 5, 5) };

            var returnsViewResult = controller.Index(streamFilter).ReturnsViewResult();

            Assert.AreEqual(new DateTime(2005, 5, 5), ((StreamFilter)returnsViewResult.Model).From);
        }
        public void Given_Callback_For_Stream_Jsonp_Result_Is_Returned()
        {
            var filter = new StreamFilter
            {
                Callback = "callback"
            };
            var fakeStorage = new Mock<IStreamStorage>();
            var streamApi = new StreamApiController(fakeStorage.Object);

            var result = streamApi.Stream(filter);

            Assert.IsInstanceOf<JsonpResult>(result);
        }
        public void Items_Action_Should_Return_ViewResult_With_ItemsView()
        {
            var streamServiceFake = new Mock<IStreamService>();
            streamServiceFake.Setup(x => x.GetItems(It.IsAny<StreamFilter>())).Returns(new List<Item> { new Item() });
            var controller = new HomeController(streamServiceFake.Object);
            var streamFilter = new StreamFilter { From = new DateTime(2005, 5, 5) };

            var returnsViewResult = controller.Items(streamFilter).ReturnsViewResult();
            var itemsView = (ItemsView)returnsViewResult.Model;

            Assert.AreEqual(new DateTime(2005, 5, 5), itemsView.Filter.From);
            Assert.AreEqual(1, itemsView.Items.Count());
        }
        public void Given_Date_And_Limit_Api_Returns_Limited_Number_Of_Items()
        {
            var filter = new StreamFilter
            {
                From = DateTime.UtcNow.AddDays(-1),
                Limit = 10
            };
            var fakeStorage = new Mock<IStreamStorage>();
            var streamApi = new StreamApiController(fakeStorage.Object);

            streamApi.Stream(filter);

            fakeStorage.Verify(s => s.GetLatest(filter.Type, filter.From, filter.To, filter.Limit), Times.Once());
        }
 public StreamSubscriptionMock(object callback, StreamFilter filter)
     : base(null)
 {
     Callback = callback;
     Filter = filter;
 }
        public void Given_No_Limit_StreamFilter_Returns_Non_Null_Limit()
        {
            var filter = new StreamFilter();

            Assert.IsNotNull(filter.From);
        }
        public void Given_No_From_Date_StreamFilter_Returns_Non_Null_Date()
        {
            var filter = new StreamFilter();

            Assert.IsNotNull(filter.From);
        }
        public void With_No_Arguments_Api_Returns_Items()
        {
            var filter = new StreamFilter();
            var fakeStorage = new Mock<IStreamStorage>();
            var streamApi = new StreamApiController(fakeStorage.Object);

            streamApi.Stream(filter);

            fakeStorage.Verify(s => s.GetLatest(filter.Type, filter.From, filter.To, filter.Limit), Times.Once());
        }
Beispiel #9
0
        public async Task prefix_stream_name()
        {
            var streamPrefix = _fixture.GetStreamName();
            var events       = _fixture.CreateTestEvents(10).ToArray();

            foreach (var e in events)
            {
                await _fixture.Client.AppendToStreamAsync($"{streamPrefix}_{Guid.NewGuid():n}",
                                                          AnyStreamRevision.NoStream, new[] { e });
            }

            var result = await _fixture.Client.ReadAllAsync(Direction.Forwards, Position.Start, 100,
                                                            filterOptions : new FilterOptions(StreamFilter.Prefix(streamPrefix)))
                         .ToArrayAsync();

            Assert.Equal(events.Select(x => x.EventId), result.Select(x => x.OriginalEvent.EventId));
        }
Beispiel #10
0
 public override Task Subscribe(Actor actor, StreamFilter filter = null)
 {
     Subscribed = actor;
     Filter     = filter;
     return(TaskDone.Done);
 }
Beispiel #11
0
 public override Task <StreamSubscription> Subscribe <T>(Action <T> callback, StreamFilter filter      = null) => Create(callback, filter);
Beispiel #12
0
 public override Task <StreamSubscription> Subscribe(Func <object, Task> callback, StreamFilter filter = null) => Create(callback, filter);