public void AllowsCreatingContextWithoutSettingAccessor()
        {
            // Arrange
            var contextFactory = new HttpContextFactory(Options.Create(new FormOptions()));

            // Act & Assert
            var context = contextFactory.Create(new FeatureCollection());

            contextFactory.Dispose(context);
        }
        public void CreateHttpContextSetsHttpContextAccessor()
        {
            // Arrange
            var accessor       = new HttpContextAccessor();
            var contextFactory = new HttpContextFactory(Options.Create(new FormOptions()), accessor);

            // Act
            var context = contextFactory.Create(new FeatureCollection());

            // Assert
            Assert.True(ReferenceEquals(context, accessor.HttpContext));
        }
        public void CreateHttpContextSetsHttpContextAccessor()
        {
            // Arrange
            var accessor       = new HttpContextAccessor();
            var contextFactory = new HttpContextFactory(Options.Create(new FormOptions()), new MyServiceScopeFactory(), accessor);

            // Act
            var context = contextFactory.Create(new FeatureCollection());

            // Assert
            Assert.Same(context, accessor.HttpContext);
        }
Пример #4
0
        public void DisposeHttpContextSetsHttpContextAccessorToNull()
        {
            // Arrange
            var accessor       = new HttpContextAccessor();
            var contextFactory = new HttpContextFactory(Options.Create(new FormOptions()), accessor);

            // Act
            var context = contextFactory.Create(new FeatureCollection());

            // Assert
            Assert.Same(context, accessor.HttpContext);

            contextFactory.Dispose(context);

            Assert.Null(accessor.HttpContext);
        }