Xunit.Assert.IsType(object)

Here are the examples of the csharp api Xunit.Assert.IsType(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

652 Examples 7

19 View Source File : SqlWebHookStorePlainTextTests.cs
License : Apache License 2.0
Project Creator : aspnet

private static IWebHookStore CreateStore()
        {
            // Delete any existing DB
            string connectionString = ConfigurationManager.ConnectionStrings[WebHookStoreContext.ConnectionStringName].ConnectionString;
            Database.Delete(connectionString);

            // Initialize DB using code first migration
            var dbConfig = new EF.Configuration();
            var migrator = new DbMigrator(dbConfig);
            migrator.Update();

            HttpConfiguration config = new HttpConfiguration();
            config.InitializeCustomWebHooksSqlStorage(encryptData: false);
            IWebHookStore store = CustomServices.GetStore();
            replacedert.IsType<SqlWebHookStore>(store);
            return store;
        }

19 View Source File : DependencyScopeExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetFilterProviders_ReturnsDefaultInstances_IfNoneRegistered()
        {
            // Arrange
            _config.InitializeCustomWebHooks();

            // Act
            IEnumerable<IWebHookFilterProvider> actual = _resolverMock.Object.GetFilterProviders();

            // replacedert
            replacedert.IsType<WildcardWebHookFilterProvider>(actual.Single());
        }

19 View Source File : HttpConfigurationExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void InitializeSender_SetsSender()
        {
            // Arrange
            ILogger logger = new Mock<ILogger>().Object;
            HttpConfiguration config = new HttpConfiguration();

            // Act
            config.InitializeCustomWebHooksAzureQueueSender();
            IWebHookSender actual = CustomServices.GetSender(logger);

            // replacedert
            replacedert.IsType<AzureWebHookSender>(actual);
        }

19 View Source File : HttpConfigurationExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void Initialize_SetsStore()
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();

            // Act
            config.InitializeCustomWebHooksSqlStorage();
            IWebHookStore actual = CustomServices.GetStore();

            // replacedert
            replacedert.IsType<SqlWebHookStore>(actual);
        }

19 View Source File : AzureWebHookStorePLainTextTests.cs
License : Apache License 2.0
Project Creator : aspnet

private static IWebHookStore CreateStore()
        {
            HttpConfiguration config = new HttpConfiguration();
            config.InitializeCustomWebHooksAzureStorage(encryptData: false);
            IWebHookStore store = CustomServices.GetStore();
            replacedert.IsType<AzureWebHookStore>(store);
            return store;
        }

19 View Source File : WebHookRegistrationsControllerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public async Task Put_ReturnsBadRequest_IfNoRequestBody()
        {
            // Act
            var actual = await _controller.Put(TestUser, webHook: null);

            // replacedert
            replacedert.IsType<BadRequestResult>(actual);
        }

19 View Source File : DependencyScopeExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetFilterManager_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Arrange
            _config.InitializeCustomWebHooks();

            // Act
            IWebHookFilterManager actual = _resolverMock.Object.GetFilterManager();

            // replacedert
            replacedert.IsType<WebHookFilterManager>(actual);
        }

19 View Source File : UnityAdapterTest.cs
License : MIT License
Project Creator : aspnet

[Fact]
        public void AddUnity_Should_Register_WebObjectActivator_And_Return_UnityContainer()
        {
            var unityContainer = UnityAdapter.AddUnity();

            replacedert.NotNull(HttpRuntime.WebObjectActivator);
            replacedert.IsType<ContainerServiceProvider>(HttpRuntime.WebObjectActivator);
            replacedert.NotNull(unityContainer);
        }

19 View Source File : PropertyAssert.cs
License : Apache License 2.0
Project Creator : aspnet

public static void Roundtrips<TInstance, TProperty>(TInstance instance, Expression<Func<TInstance, TProperty>> propertyExpression, PropertySetter propertySetter, TProperty defaultValue = null, TProperty roundtripValue = null)
            where TInstance : clreplaced
            where TProperty : clreplaced
        {
            PropertyInfo property = GetPropertyInfo(propertyExpression);
            Func<TInstance, TProperty> getter = GetPropertyGetter<TInstance, TProperty>(property);
            Action<TInstance, TProperty> setter = GetPropertySetter<TInstance, TProperty>(property);

            switch (propertySetter)
            {
                case PropertySetter.NullRoundtrips:
                    replacedert.Equal(defaultValue, getter(instance));
                    TestRoundtrip(instance, getter, setter, roundtripValue: (TProperty)null);
                    break;

                case PropertySetter.NullDoesNotRoundtrip:
                    replacedert.NotNull(getter(instance));
                    setter(instance, null);
                    replacedert.NotNull(getter(instance));
                    break;

                case PropertySetter.NullSetsDefault:
                    replacedert.Equal(defaultValue, getter(instance));
                    TestRoundtrip(instance, getter, setter, roundtripValue: defaultValue);
                    break;

                case PropertySetter.NullThrows:
                    replacedert.Equal(defaultValue, getter(instance));
                    TargetInvocationException ex = replacedert.Throws<TargetInvocationException>(() => setter(instance, null));
                    replacedert.IsType<ArgumentNullException>(ex.InnerException);
                    ArgumentNullException argumentNullException = ex.InnerException as ArgumentNullException;
                    replacedert.Equal("value", argumentNullException.ParamName);
                    break;

                default:
                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Invalid '{0}' value", typeof(PropertySetter).Name));
            }

            if (roundtripValue != null)
            {
                TestRoundtrip(instance, getter, setter, roundtripValue);
            }
        }

19 View Source File : DependencyScopeExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetLogger_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Act
            ILogger actual = _resolverMock.Object.GetLogger();

            // replacedert
            replacedert.IsType<TraceLogger>(actual);
        }

19 View Source File : DependencyResolverExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetStore_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Act
            IWebHookStore actual = _resolverMock.Object.GetStore();

            // replacedert
            replacedert.IsType<MemoryWebHookStore>(actual);
        }

19 View Source File : AzureWebHookStoreTests.cs
License : Apache License 2.0
Project Creator : aspnet

private static IWebHookStore CreateStore()
        {
            HttpConfiguration config = new HttpConfiguration();
            config.InitializeCustomWebHooksAzureStorage();
            IWebHookStore store = CustomServices.GetStore();
            replacedert.IsType<AzureWebHookStore>(store);
            return store;
        }

19 View Source File : WebHookRegistrationsControllerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public async Task Post_ReturnsBadRequest_IfNoRequestBody()
        {
            // Act
            var actual = await _controller.Post(webHook: null);

            // replacedert
            replacedert.IsType<BadRequestResult>(actual);
        }

19 View Source File : HttpConfigurationExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Theory]
        [InlineData("Default", "dbo", "WebHooksTable")]
        [InlineData("Default", null, null)]
        [InlineData("", "", "")]
        [InlineData(null, null, null)]
        public void Initialize_SetsStore_WithCustomSettings(string nameOrConnectionString, string schemaName, string tableName)
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();

            // Act
            config.InitializeCustomWebHooksSqlStorage(true, nameOrConnectionString, schemaName, tableName);
            IWebHookStore actual = CustomServices.GetStore();

            // replacedert
            replacedert.IsType<SqlWebHookStore>(actual);
        }

19 View Source File : ContainerServiceProviderTest.cs
License : MIT License
Project Creator : aspnet

[Fact]
        public void GetService_Should_Cache_Type_That_Cannot_Be_Resolved_By_UnityContainer()
        {
            var containerSP = new ContainerServiceProvider(null);
            var resolvedObj = containerSP.GetService(typeof(TypeToResolveBase));

            replacedert.NotNull(resolvedObj);
            replacedert.IsType<TypeToResolveBase>(resolvedObj);
            replacedert.True(containerSP.TypeCannotResolveDictionary.ContainsKey(typeof(TypeToResolveBase)));
        }

19 View Source File : SqlWebHookStoreTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void CreateStore_WithCustomSettings_Succeeds()
        {
            // Arrange
            ILogger logger = new Mock<ILogger>().Object;

            // Act
            IWebHookStore actual = SqlWebHookStore.CreateStore(logger, true, WebHookStoreContext.ConnectionStringName, "WebHooks", "WebHooks");

            // replacedert
            replacedert.IsType<SqlWebHookStore>(actual);
        }

19 View Source File : WebHookRegistrationsControllerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public async Task Put_ReturnsOk_IfValidWebHook()
        {
            // Arrange
            var webHook = CreateWebHook();
            _regsMock.Setup(s => s.UpdateWebHookAsync(_principal, webHook, null))
                .ReturnsAsync(StoreResult.Success);

            // Act
            var actual = await _controller.Put(webHook.Id, webHook);

            // replacedert
            replacedert.IsType<OkResult>(actual);
        }

19 View Source File : DependencyScopeExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetManager_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Arrange
            _config.InitializeCustomWebHooks();

            // Act
            IWebHookManager actual = _resolverMock.Object.GetManager();

            // replacedert
            replacedert.IsType<WebHookManager>(actual);
        }

19 View Source File : Utilities.cs
License : Apache License 2.0
Project Creator : aspnet

internal static void Throws<TException>(Action action) where TException : Exception
        {
            try
            {
                action();
                replacedert.False(true, "No Exception");
            }
            catch (TargetInvocationException tex)
            {
                replacedert.IsType<TException>(tex.InnerException);
            }
            catch (TException)
            {
            }
        }

19 View Source File : WebHookReceiversControllerTests.cs
License : Apache License 2.0
Project Creator : aspnet

private async Task Action_Returns_NotFoundWhenReceiverDoesNotExist(Func<string, Task<IHttpActionResult>> action)
        {
            // Arrange
            _managerMock.Setup(m => m.GetReceiver(TestReceiver))
                .Returns((IWebHookReceiver)null)
                .Verifiable();

            // Act
            IHttpActionResult result = await action(TestReceiver);

            // replacedert
            _managerMock.Verify();
            replacedert.IsType<NotFoundResult>(result);
        }

19 View Source File : StorageManagerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public async Task ExecuteRetrieval_ReturnsData_IfFound()
        {
            // Arrange
            var table = InitializeTable();
            await CreateTableRows(table);

            // Act
            var actual = await _manager.ExecuteRetrievalAsync(table, TestParreplacedion, "data 0");

            // replacedert
            replacedert.NotNull(actual);
            replacedert.Equal(200, actual.HttpStatusCode);
            replacedert.IsType<DynamicTableEnreplacedy>(actual.Result);
            var actualEnreplacedy = (DynamicTableEnreplacedy)actual.Result;
            replacedert.Equal("data 0", actualEnreplacedy.RowKey);
            replacedert.Equal(TestParreplacedion, actualEnreplacedy.ParreplacedionKey);
        }

19 View Source File : AzureWebHookStorePLainTextTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void CreateStore_Succeeds()
        {
            // Arrange
            ILogger logger = new Mock<ILogger>().Object;

            // Act
            IWebHookStore actual = AzureWebHookStore.CreateStore(logger, encryptData: false);

            // replacedert
            replacedert.IsType<AzureWebHookStore>(actual);
        }

19 View Source File : TestServerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public async Task Disposed()
        {
            TestServer server = TestServer.Create(app =>
            {
                // Disposes the stream.
                app.UseWelcomePage();
            });

            HttpResponseMessage result = await server.HttpClient.GetAsync("/");
            replacedert.Equal(HttpStatusCode.OK, result.StatusCode);
            server.Dispose();
            AggregateException ex = replacedert.Throws<AggregateException>(() => server.HttpClient.GetAsync("/").Result);
            replacedert.IsType<ObjectDisposedException>(ex.GetBaseException());
        }

19 View Source File : AzureWebHookStoreTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void CreateStore_Succeeds()
        {
            // Arrange
            ILogger logger = new Mock<ILogger>().Object;

            // Act
            IWebHookStore actual = AzureWebHookStore.CreateStore(logger);

            // replacedert
            replacedert.IsType<AzureWebHookStore>(actual);
        }

19 View Source File : DependencyScopeExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetSettings_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Act
            SettingsDictionary actual = _resolverMock.Object.GetSettings();

            // replacedert
            replacedert.IsType<SettingsDictionary>(actual);
        }

19 View Source File : DependencyResolverExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetManager_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Act
            IWebHookManager actual = _resolverMock.Object.GetManager();

            // replacedert
            replacedert.IsType<WebHookManager>(actual);
        }

19 View Source File : DependencyResolverExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetFilterManager_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Arrange
            WebHooksConfig.Initialize(_config);

            // Act
            IWebHookFilterManager actual = _resolverMock.Object.GetFilterManager();

            // replacedert
            replacedert.IsType<WebHookFilterManager>(actual);
        }

19 View Source File : WebHookRegistrationsControllerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public async Task Lookup_ReturnsNotFound_IfNotFoundWebHook()
        {
            // Arrange
            _regsMock.Setup(r => r.LookupWebHookAsync(_principal, TestUser, It.IsAny<Func<string, WebHook, Task>>()))
                .ReturnsAsync(null)
                .Verifiable();

            // Act
            var actual = await _controller.Lookup(TestUser);

            // replacedert
            replacedert.IsType<NotFoundResult>(actual);
        }

19 View Source File : DependencyResolverExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetUser_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Act
            IWebHookUser actual = _resolverMock.Object.GetUser();

            // replacedert
            replacedert.IsType<WebHookUser>(actual);
        }

19 View Source File : ContainerServiceProviderTest.cs
License : MIT License
Project Creator : aspnet

[Fact]
        public void GetService_Should_Use_Saved_ServiceProvider_If_UnityContainer_Cannot_Resolve()
        {
            var existingSP = new Mock<IServiceProvider>();
            existingSP.Setup(sp => sp.GetService(typeof(TypeToResolveBase))).Returns(new TypeToResolve());
            var containerSP = new ContainerServiceProvider(existingSP.Object);
            var resolvedObj = containerSP.GetService(typeof(TypeToResolveBase));

            replacedert.NotNull(resolvedObj);
            replacedert.IsType<TypeToResolve>(resolvedObj);
        }

19 View Source File : HttpConfigurationExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Theory]
        [InlineData("Default")]
        [InlineData("")]
        [InlineData(null)]
        public void Initialize_SetsStore_WithCustomConnectionString(string nameOrConnectionString)
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();

            // Act
            config.InitializeCustomWebHooksSqlStorage(true, nameOrConnectionString);
            IWebHookStore actual = CustomServices.GetStore();

            // replacedert
            replacedert.IsType<SqlWebHookStore>(actual);
        }

19 View Source File : WebHookRegistrationsControllerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public async Task Post_ReturnsCreated_IfValidWebHook()
        {
            // Arrange
            var webHook = CreateWebHook();
            _regsMock.Setup(s => s.AddWebHookAsync(_principal, webHook, It.IsAny<Func<string, WebHook, Task>>()))
                .ReturnsAsync(StoreResult.Success);

            // Act
            var actual = await _controller.Post(webHook);

            // replacedert
            replacedert.IsType<CreatedAtRouteNegotiatedContentResult<WebHook>>(actual);
        }

19 View Source File : SqlWebHookStorePlainTextTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void CreateStore_Succeeds()
        {
            // Arrange
            ILogger logger = new Mock<ILogger>().Object;

            // Act
            IWebHookStore actual = SqlWebHookStore.CreateStore(logger, encryptData: false);

            // replacedert
            replacedert.IsType<SqlWebHookStore>(actual);
        }

19 View Source File : SystemWebIntegrationTests.cs
License : Apache License 2.0
Project Creator : aspnet

public void ModuleAndHandlerAsyncException(IAppBuilder app)
        {
            app.UseErrorPage();
            app.Use(async (context, next) =>
            {
                try
                {
                    // Expect async exception from the handler.
                    await next();
                    replacedert.True(false, "Handler exception expected");
                }
                catch (Exception ex)
                {
                    replacedert.IsType<AggregateException>(ex);
                    replacedert.IsType<NotFiniteNumberException>(ex.GetBaseException());
                }
            });

            RouteTable.Routes.MapOwinPath("/", app2 =>
            {
                app2.Run(context2 =>
                {
                    TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
                    tcs.TrySetException(new NotFiniteNumberException("Handler exception"));
                    return tcs.Task;
                });
            });
        }

19 View Source File : SqlWebHookStoreTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void CreateStore_Succeeds()
        {
            // Arrange
            ILogger logger = new Mock<ILogger>().Object;

            // Act
            IWebHookStore actual = SqlWebHookStore.CreateStore(logger);

            // replacedert
            replacedert.IsType<SqlWebHookStore>(actual);
        }

19 View Source File : WebHookRegistrationsControllerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public async Task Put_ReturnsBadRequest_IfWebHookIdDiffersFromUriId()
        {
            // Arrange
            var webHook = CreateWebHook();

            // Act
            var actual = await _controller.Put("unknown", webHook);

            // replacedert
            replacedert.IsType<BadRequestResult>(actual);
        }

19 View Source File : SqlWebHookStoreTests.cs
License : Apache License 2.0
Project Creator : aspnet

private static IWebHookStore CreateStore()
        {
            // Delete any existing DB
            string connectionString = ConfigurationManager.ConnectionStrings[WebHookStoreContext.ConnectionStringName].ConnectionString;
            Database.Delete(connectionString);

            // Initialize DB using code first migration
            var dbConfig = new EF.Configuration();
            var migrator = new DbMigrator(dbConfig);
            migrator.Update();

            HttpConfiguration config = new HttpConfiguration();
            config.InitializeCustomWebHooksSqlStorage();
            IWebHookStore store = CustomServices.GetStore();
            replacedert.IsType<SqlWebHookStore>(store);
            return store;
        }

19 View Source File : HttpApplicationExtensionsTest.cs
License : MIT License
Project Creator : aspnet

[Fact]
        public void AddUnity_Should_Register_WebObjectActivator_With_ContainerServiceProvider()
        {
            var app = new HttpApplication();
            var container = app.AddUnity();

            replacedert.NotNull(container);
            replacedert.NotNull(HttpRuntime.WebObjectActivator);
            replacedert.IsType<ContainerServiceProvider>(HttpRuntime.WebObjectActivator);
        }

19 View Source File : DependencyScopeExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetSender_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Arrange
            _config.InitializeCustomWebHooks();

            // Act
            IWebHookSender actual = _resolverMock.Object.GetSender();

            // replacedert
            replacedert.IsType<DataflowWebHookSender>(actual);
        }

19 View Source File : DependencyScopeExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetIdValidator_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Arrange
            _config.InitializeCustomWebHooks();

            // Act
            IWebHookIdValidator actual = _resolverMock.Object.GetIdValidator();

            // replacedert
            replacedert.IsType<DefaultWebHookIdValidator>(actual);
        }

19 View Source File : DependencyScopeExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetStore_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Arrange
            _config.InitializeCustomWebHooks();

            // Act
            IWebHookStore actual = _resolverMock.Object.GetStore();

            // replacedert
            replacedert.IsType<MemoryWebHookStore>(actual);
        }

19 View Source File : OwinHttpListenerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact, Trait("scheme", "https")]
        public async Task EndToEnd_HttpsGetRequest_Success()
        {
            OwinHttpListener listener = CreateServer(
                async env =>
                {
                    object obj;
                    replacedert.True(env.TryGetValue("ssl.LoadClientCertAsync", out obj));
                    replacedert.NotNull(obj);
                    replacedert.IsType(typeof(Func<Task>), obj);
                    var loadCert = (Func<Task>)obj;
                    await loadCert();
                    replacedert.True(env.TryGetValue("ssl.ClientCertificate", out obj));
                    replacedert.NotNull(obj);
                    replacedert.IsType<X509Certificate2>(obj);
                },
                HttpsServerAddress);

            X509Certificate2 clientCert = FindClientCert();
            replacedert.NotNull(clientCert);
            HttpResponseMessage response = await SendGetRequest(listener, HttpsClientAddress, clientCert);
            replacedert.Equal(HttpStatusCode.OK, response.StatusCode);
            replacedert.Equal(0, response.Content.Headers.ContentLength.Value);
        }

19 View Source File : OwinClientHandlerTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void ExceptionBeforeFirstWriteIsReported()
        {
            var handler = new OwinClientHandler(env =>
            {
                throw new InvalidOperationException("Test Exception");
            });
            var httpClient = new HttpClient(handler);
            AggregateException ex = replacedert.Throws<AggregateException>(() => httpClient.GetAsync("https://example.com/",
                HttpCompletionOption.ResponseHeadersRead).Result);
            replacedert.IsType<InvalidOperationException>(ex.InnerException);
        }

19 View Source File : HttpConfigurationExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void InitializeStore_SetsStore()
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();

            // Act
            config.InitializeCustomWebHooksAzureStorage();
            IWebHookStore actual = CustomServices.GetStore();

            // replacedert
            replacedert.IsType<AzureWebHookStore>(actual);
        }

19 View Source File : UnityAdapterTest.cs
License : MIT License
Project Creator : aspnet

[Fact]
        public void AddUnity_Should_Chain_Existing_WebObjectActivator()
        {
            var existingSP = new Mock<IServiceProvider>();
            HttpRuntime.WebObjectActivator = existingSP.Object;

            var unityContainer = UnityAdapter.AddUnity();

            replacedert.NotNull(HttpRuntime.WebObjectActivator);
            replacedert.IsType<ContainerServiceProvider>(HttpRuntime.WebObjectActivator);
            replacedert.Same(existingSP.Object, ((ContainerServiceProvider)HttpRuntime.WebObjectActivator).NextServiceProvider);
            replacedert.NotNull(unityContainer);
        }

19 View Source File : AzureAdB2CAuthenticationBuilderExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void AddAzureADB2C_ConfiguresAllOptions()
        {
            // Arrange
            var services = new ServiceCollection();
            services.AddSingleton<ILoggerFactory>(new NullLoggerFactory());

            // Act
            services.AddAuthentication()
                .AddAzureADB2C(o =>
                {
                    o.Instance = "https://login.microsoftonline.com/tfp";
                    o.ClientId = "ClientId";
                    o.ClientSecret = "ClientSecret";
                    o.CallbackPath = "/signin-oidc";
                    o.Domain = "domain.onmicrosoft.com";
                    o.SignUpSignInPolicyId = "B2C_1_SiUpIn";
                    o.ResetPreplacedwordPolicyId = "B2C_1_SSPR";
                    o.EditProfilePolicyId = "B2C_1_SiPe";
                });
            var provider = services.BuildServiceProvider();

            // replacedert
            var azureADB2COptionsMonitor = provider.GetService<IOptionsMonitor<AzureADB2COptions>>();
            replacedert.NotNull(azureADB2COptionsMonitor);
            var azureADB2COptions = azureADB2COptionsMonitor.Get(AzureADB2CDefaults.AuthenticationScheme);
            replacedert.Equal(AzureADB2CDefaults.OpenIdScheme, azureADB2COptions.OpenIdConnectSchemeName);
            replacedert.Equal(AzureADB2CDefaults.CookieScheme, azureADB2COptions.CookieSchemeName);
            replacedert.Equal("https://login.microsoftonline.com/tfp", azureADB2COptions.Instance);
            replacedert.Equal("ClientId", azureADB2COptions.ClientId);
            replacedert.Equal("ClientSecret", azureADB2COptions.ClientSecret);
            replacedert.Equal("/signin-oidc", azureADB2COptions.CallbackPath);
            replacedert.Equal("domain.onmicrosoft.com", azureADB2COptions.Domain);
            replacedert.Equal("B2C_1_SiUpIn", azureADB2COptions.SignUpSignInPolicyId);
            replacedert.Equal("B2C_1_SSPR", azureADB2COptions.ResetPreplacedwordPolicyId);
            replacedert.Equal("B2C_1_SiPe", azureADB2COptions.EditProfilePolicyId);

            var openIdOptionsMonitor = provider.GetService<IOptionsMonitor<OpenIdConnectOptions>>();
            replacedert.NotNull(openIdOptionsMonitor);
            var openIdOptions = openIdOptionsMonitor.Get(AzureADB2CDefaults.OpenIdScheme);
            replacedert.Equal("ClientId", openIdOptions.ClientId);
            replacedert.Equal($"https://login.microsoftonline.com/tfp/domain.onmicrosoft.com/B2C_1_SiUpIn/v2.0", openIdOptions.Authority);
            replacedert.True(openIdOptions.UseTokenLifetime);
            replacedert.Equal("/signin-oidc", openIdOptions.CallbackPath);
            replacedert.Equal(AzureADB2CDefaults.CookieScheme, openIdOptions.SignInScheme);
            replacedert.NotNull(openIdOptions.TokenValidationParameters);
            replacedert.Equal("name", openIdOptions.TokenValidationParameters.NameClaimType);
            replacedert.NotNull(openIdOptions.Events);
            var redirectHandler = openIdOptions.Events.OnRedirectToIdenreplacedyProvider;
            replacedert.NotNull(redirectHandler);
            replacedert.IsType<AzureADB2COpenIDConnectEventHandlers>(redirectHandler.Target);
            var remoteFailureHanlder = openIdOptions.Events.OnRemoteFailure;
            replacedert.NotNull(remoteFailureHanlder);
            replacedert.IsType<AzureADB2COpenIDConnectEventHandlers>(redirectHandler.Target);
        }

19 View Source File : ServerFactoryLoaderTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Theory]
        [InlineData("Microsoft.Owin.Host.HttpListener")]
        [InlineData("Microsoft.Owin.Host.HttpListener.OwinServerFactory")]
        public void LoadWithDefaults_LoadreplacedemblyAndDiscoverFactory(string data)
        {
            var loader = new ServerFactoryLoader(new ServerFactoryActivator(ServicesFactory.Create()));
            IServerFactoryAdapter serverFactory = loader.Load(data);
            replacedert.NotNull(serverFactory);
            IAppBuilder builder = new AppBuilder();
            serverFactory.Initialize(builder);
            replacedert.IsType<OwinHttpListener>(builder.Properties[typeof(OwinHttpListener).FullName]);
        }

19 View Source File : ContainerServiceProviderTest.cs
License : MIT License
Project Creator : aspnet

[Fact]
        public void GetService_Should_Resolve_Type_EvenIf_Unity_Cannot_Resolve()
        {
            var containerSP = new ContainerServiceProvider(null);
            var resolvedObj = containerSP.GetService(typeof(TypeToResolveBase));

            replacedert.NotNull(resolvedObj);
            replacedert.IsType<TypeToResolveBase>(resolvedObj);
        }

19 View Source File : TypeUtilitiesTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetInstances_CreatesExpectedInstances()
        {
            // Arrange
            var replacedemblies = AppDomain.CurrentDomain.Getreplacedemblies();

            // Act
            var actual = TypeUtilities.GetInstances<ITestType>(replacedemblies, t => TypeUtilities.IsType<ITestType>(t));

            // replacedert
            replacedert.Equal(1, actual.Count);
            replacedert.IsType<TestType>(actual.Single());
        }

19 View Source File : DependencyResolverExtensionsTests.cs
License : Apache License 2.0
Project Creator : aspnet

[Fact]
        public void GetSender_ReturnsDefaultInstance_IfNoneRegistered()
        {
            // Act
            IWebHookSender actual = _resolverMock.Object.GetSender();

            // replacedert
            replacedert.IsType<DataflowWebHookSender>(actual);
        }

See More Examples