/// <summary>Creates UI or Data context depend on parameters.</summary> /// <param name="provider">The provider.</param> /// <param name="type">The type.</param> /// <param name="serverUrl">The server url.</param> /// <param name="web">The web.</param> /// <param name="credentials">The credentials.</param> /// <param name="connectionConfiguration">The connection configuration.</param> /// <returns>The <see cref="SpContext"/>.</returns> private SpContext CreateContext(SpContextProvider provider, ContextType type, string serverUrl, string web, ICredentials credentials = null, string connectionConfiguration = null) { switch (type) { case ContextType.Data: return(provider.CreateDataContext(serverUrl, web, credentials, connectionConfiguration)); case ContextType.Ui: return(provider.CreateUIContext(serverUrl, web, credentials, connectionConfiguration)); default: throw new InvalidOperationException("Unknown context type"); } }
public void should_fill_data_context_from_config_data() { // Arrange var provider = new SpContextProvider(); var configData = new IntegrationConfigData(SharepointServerUrl, "list", "template") { ConnectionConfiguration = ConnectionConfiguration, }; configData.SetCredentials("UserName", "Password"); // Act var context = provider.CreateDataContext(configData); // Assert context.ConnectionConfiguration.Should().Be(configData.ConnectionConfiguration); context.Credentials.Should().Be(configData.Credentials); context.Url.Should().BeEquivalentTo(configData.Server); }