public void TestAddUpdateServiceInstance_SavesWebProxyDetailsToDesignerDataAccordingToStoreWebProxyNetworkCredentials(string method, int edmxVersion, string generatorVersion, bool store) { var descriptorFactory = new TestCodeGenDescriptorFactory(); var serviceHandler = new ODataConnectedServiceHandler(descriptorFactory); const string username = "******"; const string password = "******"; var serviceConfig = new ServiceConfiguration() { EdmxVersion = new Version(edmxVersion, 0, 0, 0), ServiceName = "TestService", UseDataServiceCollection = false, MakeTypesInternal = true, IncludeWebProxy = true, IncludeWebProxyNetworkCredentials = true, WebProxyHost = "http://example.com:80", WebProxyNetworkCredentialsUsername = username, WebProxyNetworkCredentialsPassword = password, StoreWebProxyNetworkCredentials = store }; var tokenSource = new CancellationTokenSource(); var context = SetupContext(serviceConfig); (typeof(ODataConnectedServiceHandler).GetMethod(method).Invoke( serviceHandler, new object[] { context, tokenSource.Token }) as Task).Wait(); // WebProxy username and password should be null when StoreWebProxyNetworkCredentials is false since we are not saving them to DesignerData Assert.AreEqual(serviceConfig, context.SavedExtendedDesignData); Assert.AreEqual(serviceConfig.WebProxyNetworkCredentialsUsername, store ? username : null); Assert.AreEqual(serviceConfig.WebProxyNetworkCredentialsPassword, store ? password : null); }
public void TestAddUpdateServiceInstance_SavesCustomHttpHeadersToDesignerDataAccordingToStoreCustomHttpHeaders(string method, int edmxVersion, string generatorVersion, bool store) { var descriptorFactory = new TestCodeGenDescriptorFactory(); var serviceHandler = new ODataConnectedServiceHandler(descriptorFactory); const string headerValue = @"Authorization: Bearer xyz12345-randomstring"; var serviceConfig = new ServiceConfiguration() { EdmxVersion = new Version(edmxVersion, 0, 0, 0), ServiceName = "TestService", UseDataServiceCollection = false, MakeTypesInternal = true, IncludeCustomHeaders = true, CustomHttpHeaders = headerValue, StoreCustomHttpHeaders = store }; var tokenSource = new CancellationTokenSource(); var context = SetupContext(serviceConfig); (typeof(ODataConnectedServiceHandler).GetMethod(method).Invoke( serviceHandler, new object[] { context, tokenSource.Token }) as Task).Wait(); // CustomHttpHeaders should be null when StoreCustomHttpHeaders is false since we are not saving them to DesignerData Assert.AreEqual(serviceConfig, context.SavedExtendedDesignData); Assert.AreEqual(serviceConfig.CustomHttpHeaders, store ? headerValue : null); }
public void TestUpdateServiceInstance_GeneratesCodeAndSavesConfig(string method, int edmxVersion, string generatorVersion) { var descriptorFactory = new TestCodeGenDescriptorFactory(); var serviceHandler = new ODataConnectedServiceHandler(descriptorFactory); var serviceConfig = new ServiceConfiguration() { EdmxVersion = new Version(edmxVersion, 0, 0, 0), ServiceName = "TestService", UseDataServiceCollection = false, MakeTypesInternal = true }; var tokenSource = new CancellationTokenSource(); var context = SetupContext(serviceConfig); (typeof(ODataConnectedServiceHandler).GetMethod(method).Invoke( serviceHandler, new object[] { context, tokenSource.Token }) as Task).Wait(); var descriptor = descriptorFactory.CreatedInstance as TestCodeGenDescriptor; Assert.IsTrue(descriptor.AddedClientCode); Assert.IsTrue(descriptor.AddedNugetPackages); Assert.AreEqual(generatorVersion, descriptor.Version); Assert.AreEqual(serviceConfig, context.SavedExtendedDesignData); }