public void GetFields_UnknownEnum_ReturnsEmptyString() { Assert.False(Enum.IsDefined(typeof(FieldResolutionMethod), Int32.MaxValue)); IPartialResponseConfig partialReponseConfig = GetMockResponseConfig((FieldResolutionMethod)Int32.MaxValue); var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); Assert.Equal(string.Empty, FieldsRetriever.GetFields(reqContextMock, partialReponseConfig)); }
public void FieldsFromQueryString_NoFields_ReturnsEmptyString() { var request = MockRepository.GenerateStub <IRequest>(); Assert.Equal( string.Empty, FieldsRetriever.FieldsFromQueryString( request, new DefaultPartialResponseConfig().FieldsQueryStringName)); }
public void FieldsFromHeader_NoFields_ReturnsEmptyString() { var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); Assert.Equal( string.Empty, FieldsRetriever.FieldsFromHeader( reqContextMock, new DefaultPartialResponseConfig().FieldsHeaderName)); }
public void FieldsFromQueryString_EmptyFields_ReturnsEmptyString() { var partialReponseConfig = new DefaultPartialResponseConfig(); IRequestContext reqContextMock = GenerateRequestMockWithQueryString( partialReponseConfig.FieldsQueryStringName, string.Empty); Assert.Equal( string.Empty, FieldsRetriever.FieldsFromQueryString(reqContextMock, partialReponseConfig.FieldsQueryStringName)); }
public void FieldsFromHeader_EmptyFields_ReturnsEmptyString() { var partialReponseConfig = new DefaultPartialResponseConfig(); var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); reqContextMock.Expect(x => x.GetHeader(partialReponseConfig.FieldsHeaderName)).Return(string.Empty); Assert.Equal( string.Empty, FieldsRetriever.FieldsFromHeader(reqContextMock, partialReponseConfig.FieldsHeaderName)); }
public void GetFields_HeaderOnlyQueryStringSet_ReturnsEmptyString() { IPartialResponseConfig partialReponseConfig = GetMockResponseConfig(FieldResolutionMethod.HeaderOnly); const string IdField = "id"; var request = MockRepository.GenerateStub <IRequest>(); StubQueryString(request, partialReponseConfig.FieldsQueryStringName, IdField); Assert.Equal(string.Empty, FieldsRetriever.GetFields(request, partialReponseConfig)); }
public void FieldsFromHeader_OneField_OneFieldReturned() { var partialReponseConfig = new DefaultPartialResponseConfig(); const string IdField = "id"; var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); reqContextMock.Expect(x => x.GetHeader(partialReponseConfig.FieldsHeaderName)).Return(IdField); Assert.Equal( IdField, FieldsRetriever.FieldsFromHeader(reqContextMock, partialReponseConfig.FieldsHeaderName)); }
public void FieldsFromHeader_OneField_OneFieldReturned() { var partialReponseConfig = new DefaultPartialResponseConfig(); const string IdField = "id"; var request = MockRepository.GenerateStub <IRequest>(); StubHeaders(request, partialReponseConfig.FieldsHeaderName, IdField); Assert.Equal( IdField, FieldsRetriever.FieldsFromHeader(request, partialReponseConfig.FieldsHeaderName)); }
public void FieldsFromQueryString_OneField_OneFieldReturned() { var partialReponseConfig = new DefaultPartialResponseConfig(); const string IdField = "id"; IRequestContext reqContextMock = GenerateRequestMockWithQueryString(partialReponseConfig.FieldsQueryStringName, IdField); Assert.Equal( IdField, FieldsRetriever.FieldsFromQueryString(reqContextMock, partialReponseConfig.FieldsQueryStringName)); }
public void FieldsFromQueryString_NoFields_ReturnsEmptyString() { var mockRequestContext = MockRepository.GenerateStub <IRequestContext>(); var mockHttpRequest = MockRepository.GenerateStub <IHttpRequest>(); mockRequestContext.Expect(x => x.Get <IHttpRequest>()).Return(mockHttpRequest); Assert.Equal( string.Empty, FieldsRetriever.FieldsFromQueryString( mockRequestContext, new DefaultPartialResponseConfig().FieldsQueryStringName)); }
public void GetFields_HeaderOnlyOneFieldSet_RetrunsOneField() { IPartialResponseConfig partialReponseConfig = GetMockResponseConfig(FieldResolutionMethod.HeaderOnly); const string IdField = "id"; var request = MockRepository.GenerateStub <IRequest>(); StubHeaders(request, partialReponseConfig.FieldsHeaderName, IdField); Assert.Equal( IdField, FieldsRetriever.GetFields(request, partialReponseConfig)); }
public void GetFields_QueryStringOnlyHeaderSet_RetrunsEmptyString() { IPartialResponseConfig partialReponseConfig = GetMockResponseConfig(FieldResolutionMethod.QueryStringOnly); const string IdField = "id"; var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); var httpRequesttMock = MockRepository.GenerateStub <IHttpRequest>(); reqContextMock.Expect(x => x.Get <IHttpRequest>()).Return(httpRequesttMock); reqContextMock.Expect(x => x.GetHeader(partialReponseConfig.FieldsHeaderName)).Return(IdField); Assert.Equal(string.Empty, FieldsRetriever.GetFields(reqContextMock, partialReponseConfig)); }
public void GetFields_HeaderOnlyOneFieldSet_RetrunsOneField() { IPartialResponseConfig partialReponseConfig = GetMockResponseConfig(FieldResolutionMethod.HeaderOnly); const string IdField = "id"; var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); reqContextMock.Expect(x => x.GetHeader(partialReponseConfig.FieldsHeaderName)).Return(IdField); Assert.Equal( IdField, FieldsRetriever.GetFields(reqContextMock, partialReponseConfig)); }
public void FieldsFromQueryString_TwoFields_TwoFieldReturned() { var partialReponseConfig = new DefaultPartialResponseConfig(); const string IdField = "id"; const string NameField = "name"; var request = MockRepository.GenerateStub <IRequest>(); StubQueryString(request, partialReponseConfig.FieldsQueryStringName, IdField, NameField); Assert.Equal( string.Join(FieldSelectorConstants.MultipleFieldSeparator.ToString(), IdField, NameField), FieldsRetriever.FieldsFromQueryString(request, partialReponseConfig.FieldsQueryStringName)); }
public void FieldsFromHeader_TwoFields_TwoFieldReturned() { var partialReponseConfig = new DefaultPartialResponseConfig(); const string IdField = "id"; const string NameField = "name"; string joinedHeaderValues = string.Join(",", IdField, NameField); var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); reqContextMock.Expect(x => x.GetHeader(partialReponseConfig.FieldsHeaderName)).Return(joinedHeaderValues); Assert.Equal( joinedHeaderValues, FieldsRetriever.FieldsFromHeader(reqContextMock, partialReponseConfig.FieldsHeaderName)); }
public void GetFields_HeaderThenQueryStringBothSetDifferent_ReturnsHeaderFieldOnly() { IPartialResponseConfig partialReponseConfig = GetMockResponseConfig(FieldResolutionMethod.HeaderThenQueryString); const string IdField = "id"; const string NameField = "name"; var request = MockRepository.GenerateStub <IRequest>(); StubQueryString(request, partialReponseConfig.FieldsQueryStringName, IdField); StubHeaders(request, partialReponseConfig.FieldsHeaderName, NameField); Assert.Equal( NameField, FieldsRetriever.GetFields(request, partialReponseConfig)); }
public void GetFields_HeaderOnlyQueryStringSet_ReturnsEmptyString() { IPartialResponseConfig partialReponseConfig = GetMockResponseConfig(FieldResolutionMethod.HeaderOnly); const string IdField = "id"; var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); var httpRequesttMock = MockRepository.GenerateStub <IHttpRequest>(); reqContextMock.Expect(x => x.Get <IHttpRequest>()).Return(httpRequesttMock); httpRequesttMock.Expect(x => x.QueryString) .Return(new NameValueCollection { { partialReponseConfig.FieldsQueryStringName, IdField } }); Assert.Equal(string.Empty, FieldsRetriever.GetFields(reqContextMock, partialReponseConfig)); }
public void GetFields_QueryStringAndHeaderBothSet_ReturnsAllFields() { IPartialResponseConfig partialReponseConfig = GetMockResponseConfig(FieldResolutionMethod.QueryStringAndHeader); const string IdField = "id"; const string NameField = "name"; var request = MockRepository.GenerateStub <IRequest>(); StubQueryString(request, partialReponseConfig.FieldsQueryStringName, IdField); StubHeaders(request, partialReponseConfig.FieldsHeaderName, NameField); Assert.Equal( string.Join(FieldSelectorConstants.MultipleFieldSeparator.ToString(), NameField, IdField), FieldsRetriever.GetFields(request, partialReponseConfig)); }
public void GetFields_HeaderThenQueryStringBothSetDifferent_ReturnsHeaderFieldOnly() { IPartialResponseConfig partialReponseConfig = GetMockResponseConfig(FieldResolutionMethod.HeaderThenQueryString); const string IdField = "id"; const string NameField = "name"; var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); var httpRequesttMock = MockRepository.GenerateStub <IHttpRequest>(); reqContextMock.Expect(x => x.Get <IHttpRequest>()).Return(httpRequesttMock); httpRequesttMock.Expect(x => x.QueryString) .Return(new NameValueCollection { { partialReponseConfig.FieldsQueryStringName, IdField } }); reqContextMock.Expect(x => x.GetHeader(partialReponseConfig.FieldsHeaderName)).Return(NameField); Assert.Equal( NameField, FieldsRetriever.GetFields(reqContextMock, partialReponseConfig)); }
public void GetFields_QueryStringAndHeaderBothSet_ReturnsAllFields() { IPartialResponseConfig partialReponseConfig = GetMockResponseConfig(FieldResolutionMethod.QueryStringAndHeader); const string IdField = "id"; const string NameField = "name"; var reqContextMock = MockRepository.GenerateStub <IRequestContext>(); var httpRequesttMock = MockRepository.GenerateStub <IHttpRequest>(); reqContextMock.Expect(x => x.Get <IHttpRequest>()).Return(httpRequesttMock); httpRequesttMock.Expect(x => x.QueryString) .Return(new NameValueCollection { { partialReponseConfig.FieldsQueryStringName, IdField } }); reqContextMock.Expect(x => x.GetHeader(partialReponseConfig.FieldsHeaderName)).Return(NameField); Assert.Equal( string.Join(FieldSelectorConstants.MultipleFieldSeparator.ToString(), NameField, IdField), FieldsRetriever.GetFields(reqContextMock, partialReponseConfig)); }
public void GetFields_NoFields_ReturnsEmptyString() { var request = MockRepository.GenerateStub <IRequest>(); Assert.Equal(string.Empty, FieldsRetriever.GetFields(request, new DefaultPartialResponseConfig())); }