Пример #1
0
        public void CreateResponseForSingleFileByCriteriaWithOutRange()
        {
            // arrange
            const long NumberOfObjectInResponse = 3;
            Mock<IHttpRequest> mockedRequest;
            Mock<IHttpResponse> mockedResponse;
            var mockedRequestContext = MockedRequestContext(out mockedRequest, out mockedResponse);
            mockedRequest.Setup(x => x.Headers).Returns(new NameValueCollection { { "Content-Range", "3" } });
            var sut = new FileServiceBase { RequestContext = mockedRequestContext.Object };

            // act
            sut.InsertRangeInResponse(NumberOfObjectInResponse);

            // assert
            mockedResponse.Verify(
                x => x.AddHeader("Content-Range", NumberOfObjectInResponse.ToString(CultureInfo.InvariantCulture)));
        }
Пример #2
0
        public void CreateResponseForFilesByCriteriaWithOutElements()
        {
            // arrange
            const int NumberOfFiles = 0;
            var repositoryMock = new Mock<IRepository<File>>();
            var files = new List<File> { new File()};
            repositoryMock.SetupIQueryable( files.AsQueryable());
            var specficication = new Specification<File>(x => true);
            var file = new File();
            var sut = new FileServiceBase { Repository = repositoryMock.Object };

            // act
            var result = sut.CreateResponseForSingleFileByCriteria(file, specficication) as HttpResult;

            // assert
            //TODO REVIEW
            Assert.NotNull(result);
            Assert.Equal(result.StatusCode, HttpStatusCode.NotFound);
        }
Пример #3
0
        public void CreateResponseForSingleFileByCriteriaWithRange()
        {
            // arrange
            const long NumberOfObjectInResponse = 3;
            Mock<IHttpRequest> mockedRequest;
            Mock<IHttpResponse> mockedResponse;
            Mock<IRequestContext> mockedRequestContext = MockedRequestContext(out mockedRequest, out mockedResponse);
            var sut = new FileServiceBase { RequestContext = mockedRequestContext.Object };

            // act
            sut.InsertRangeInResponse(NumberOfObjectInResponse);

            // assert
            mockedResponse.Verify(
                x =>
                    x.AddHeader(
                        "Content-Range",
                        NumberOfObjectInResponse.ToString(CultureInfo.InvariantCulture) + "/10"));
        }