public void Given_Filter_With_Id_Get_Is_Called() { var filter = new StreamFilter { Id = "Id" }; var fakeStorage = new Mock<IStreamStorage>(); fakeStorage.Setup(s => s.Get(It.IsAny<string>())).Returns(new Item()); var streamApi = this.BuildStreamController(fakeStorage.Object); streamApi.Get(filter); fakeStorage.Verify(s => s.Get(filter.Id), Times.Once()); }
public void Given_Empty_Filter_GetLatest_Is_Called() { var filter = new StreamFilter(); var fakeStorage = new Mock<IStreamStorage>(); fakeStorage.Setup(s => s.GetLatest(It.IsAny<int>())).Returns(new List<Item>()); var streamApi = this.BuildStreamController(fakeStorage.Object); streamApi.Get(filter); fakeStorage.Verify(s => s.GetLatest(filter.Limit), Times.Once()); }
public void Given_Filter_With_Min_Id_GetNewer_Is_Called() { var item = new Item(); var filter = new StreamFilter { Min_Id = "Min_Id" }; var fakeStorage = new Mock<IStreamStorage>(); fakeStorage.Setup(s => s.Get(It.IsAny<string>())).Returns(item); fakeStorage.Setup(s => s.GetNewer(It.IsAny<Item>(), It.IsAny<int>())).Returns(new List<Item>()); var streamApi = this.BuildStreamController(fakeStorage.Object); streamApi.Get(filter); fakeStorage.Verify(s => s.GetNewer(item, filter.Limit), Times.Once()); }
public void Given_No_Limit_StreamFilter_Returns_Default_Limit() { var filter = new StreamFilter(); Assert.That(filter.Limit, Is.EqualTo(StreamFilter.DefaultLimit)); }
public void Given_No_From_Date_StreamFilter_Returns_Non_Null_Date() { var filter = new StreamFilter(); Assert.IsNotNull(filter.From); }
public void Given_Bigger_Limit_Than_Maximum_Allowed_Later_Is_Used() { var filter = new StreamFilter { Limit = StreamFilter.MaxAllowedLimit + 1 }; Assert.That(filter.Limit, Is.EqualTo(StreamFilter.MaxAllowedLimit)); }