public void ShouldSerializeAndDeserializeSettings()
        {
            GraphSession.Initialize(() => new GraphSession());

            // Arrange
            GraphSession.Instance.DataStore = new MockDataStore();
            GraphSettings settings = new GraphSettings(ProtectedFileProvider.CreateFileProvider(Constants.SettingFilePath, FileProtection.SharedRead));

            GraphEnvironment userDefinedEnv = new GraphEnvironment
            {
                Name            = "TestCloud",
                Type            = GraphEnvironmentConstants.EnvironmentType.UserDefined,
                AzureADEndpoint = "https://tester.com",
                GraphEndpoint   = "https://tester.com"
            };

            settings.EnvironmentTable[userDefinedEnv.Name] = userDefinedEnv;

            // Act
            string serializedSettings = settings.ToString();

            settings.TryDeserializeObject(serializedSettings, out GraphSettings deserializedSettings, new GraphSettingsConverter());
            deserializedSettings.TryGetEnvironment(userDefinedEnv.Name, out IGraphEnvironment deserializedEnv);

            // Assert
            Assert.NotNull(deserializedSettings);
            Assert.NotNull(deserializedEnv);
            Assert.Equal(serializedSettings, deserializedSettings.ToString());
            Assert.Equal(userDefinedEnv.GraphEndpoint, deserializedEnv.GraphEndpoint);

            GraphSession.Reset();
        }
Ejemplo n.º 2
0
        public void CorrectData(string graphTitle, GraphSizes graphSizes, Color graphColor, GraphAxis graphAxis, string toString)
        {
            GraphSettings testObject = new GraphSettings(graphTitle, graphSizes, graphColor, graphAxis);

            Assert.Equal(graphTitle, testObject.Title);
            Assert.Equal(graphSizes, testObject.Sizes);
            Assert.Equal(graphColor, testObject.GraphColor);
            Assert.Equal(graphAxis, testObject.Axis);
            Assert.Equal(toString, testObject.ToString());
        }
Ejemplo n.º 3
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendLine("PHP Settings: ");
            sb.AppendLine(PHPSettings.ToString());
            sb.AppendLine("Graph Settings: ");
            sb.AppendLine(GraphSettings.ToString());
            sb.AppendLine("Component Settings:");
            sb.AppendLine(ComponentSettings.ToString());
            return(sb.ToString());
        }