private void GenerateOutput() { if (!InitDone) { return; } if (!checkBoxSetBufferSize.Checked) { flexGUIConfig.bufferSizeSamples = null; } if (!checkBoxSetInputLatency.Checked) { flexGUIConfig.input.suggestedLatencySeconds = null; } if (!checkBoxSetOutputLatency.Checked) { flexGUIConfig.output.suggestedLatencySeconds = null; } if (!checkBoxWasapiInputSet.Checked) { flexGUIConfig.input.wasapiAutoConvert = null; flexGUIConfig.input.wasapiExclusiveMode = null; } if (!checkBoxWasapiOutputSet.Checked) { flexGUIConfig.output.wasapiAutoConvert = null; flexGUIConfig.output.wasapiExclusiveMode = null; } configOutput.Clear(); configOutput.Text = Toml.WriteString(flexGUIConfig); }
public void Write_WhenNestedTableIsInlineTable_NestedTableIsWrittenAsInlineTable() { // Arrange var root = Toml.Create(TomlTable.TableTypes.Dotted); var adat = new Dictionary <string, object>() { { "b", 1 }, { "c", 2 }, }; var a = root.Add("a", adat, TomlTable.TableTypes.Dotted).Added; var ndat = new Dictionary <string, object>() { { "x", 3 }, }; a.Add("n", ndat, TomlTable.TableTypes.Inline); // Act var written = Toml.WriteString(root); // Assert written.Should().BeAfterTransforms(StringTransformForComparison, @" a.b=1 a.c=2 a.n={x=3}"); }
public void WriteWithArrayOfTables_ProducesCorrectToml() { // Arrange var root = new RootTable(); root.SubTable.Values.AddRange(new[] { new SubTable.ListTable() { SomeValue = 1 }, new SubTable.ListTable() { SomeValue = 5 } }); const string expected = @" [SubTable] [[SubTable.Values]] SomeValue = 1 [[SubTable.Values]] SomeValue = 5"; // Act var tml = Toml.WriteString(root); // Assert tml.ShouldBeSemanticallyEquivalentTo(expected); }
public void WriteGuidToml() { var obj = new TableContainingMoney() { NotSupported = new Money() { Ammount = 9.99m, Currency = "EUR" } }; //var config = TomlConfig.Create(cfg => cfg // .ConfigureType<decimal>(type => type // .WithConversionFor<TomlFloat>(convert => convert // .ToToml(dec => (double)dec) // .FromToml(tf => (decimal)tf.Value)))); var config = TomlSettings.Create(cfg => cfg .ConfigureType <Money>(type => type .WithConversionFor <TomlString>(convert => convert .ToToml(custom => custom.ToString()) .FromToml(tmlString => Money.Parse(tmlString.Value))))); //var config = TomlConfig.Create(); var s = Toml.WriteString(obj, config); var read = Toml.ReadString <TableContainingMoney>(s, config); }
public void Setup() { var input = new InputData(); this.InputToml = Toml.WriteString(input); this.InputJson = JsonConvert.SerializeObject(input); }
public void WriteToml_WhenConfigHasConverter_ConverterGetsUsed() { // Arrange var config = TomlSettings.Create(cfg => cfg .ConfigureType <TestStruct>(ct => ct .WithConversionFor <TomlInt>(conv => conv .FromToml((m, ti) => new TestStruct() { Value = (int)ti.Value }) .ToToml(ts => ts.Value) ) .CreateInstance(() => new TestStruct()) .TreatAsInlineTable() ) ); var obj = new ConfigObject() { S = new TestStruct() { Value = 222 } }; // Act var ser = Toml.WriteString(obj, config); // Assert Assert.Equal("S = 222\r\n", ser); }
public void Write_WhenDottedTablesAreNested_WritesTablesAsDottedTables() { // Arrange var root = Toml.Create(TomlTable.TableTypes.Dotted); var adat = new Dictionary <string, object>() { { "b", 1 }, { "c", 2 }, }; var a = root.Add("a", adat, TomlTable.TableTypes.Dotted); var ndat = new Dictionary <string, object>() { { "x", 3 }, }; a.ConfigureAdded(n => n.Add("n", ndat, TomlTable.TableTypes.Dotted)); // Act var written = Toml.WriteString(root); // Assert written.Should().BeAfterTransforms(StringTransformForComparison, @" a.b=1 a.c=2 a.n.x=3"); }
public void foox() { var i = new SD(); var r = typeof(IDictionary).IsAssignableFrom(i.GetType()); // Arrange var entity = new TomlEntity(); var classA = new ClassA(); var classB = new ClassB(); entity.Dictionary.Add(nameof(ClassA), classA); entity.Dictionary.Add(nameof(ClassB), classB); var result = Toml.WriteString(entity); // act var settings = TomlSettings.Create(cfg => cfg .ConfigureType <IDictionary <string, ISomeInterface> >(ct => ct .CreateInstance(() => new Dictionary <string, ISomeInterface>())) .ConfigureType <ISomeInterface>(tc => tc .CreateInstance(ctx => ctx.Key switch { nameof(ClassA) => new ClassA(), nameof(ClassB) => new ClassB(), _ => throw new System.Exception($"Key '{ctx.Key}' not recognized as a 'ISomeInterface'."), })));
public void WriteValueWithUnit_ProducesCorrectTomlFragment() { // Act var t = Toml.WriteString(new Root(), CreateSettings()); // Assert t.Trim().Should().Be("X = 10.2 (EUR)"); }
public void WriteTomlStrings(StringType s, string expected) { // Act var written = Toml.WriteString(s); // Assert Assert.Equal(expected, written.Trim()); }
public string ToTOML(ITree content, ValueScheme scheme) { _scheme = scheme; Process(content, ConversionScheme.Object); var toml = Neutralize(Toml.WriteString(content)); return(toml); }
public void WriteValueWithUnit_WithArrayOfSuchValues_WritesCorrectArray() { // Act var t = Toml.WriteString(new Root2(), CreateSettings()); // Assert t.Trim().Should().Be("X = [1.5 ($), -1.6 (€)]"); }
public void WriteToml_WhenInputIsClassWithStaticProperty_StaticPropertyIsIgnored() { // Act var str = Toml.WriteString(new ClassWithStaticProperty()); // Assert str.Should().NotContain(ClassWithStaticProperty.StaticPropertyValue); }
public void WriteClassWithBoolCreatesCorrecToml() { var s = Toml.WriteString(new WithBoolProperty()); s.Should().Be( @"TheInt = 0 TheBool = false "); }
public void Write_WhenDictionaryValueTypeIsConfiguredAsInlineTable_ThatTypeIsWrittenAsAnInlineTable() { var config = TomlSettings.Create(cfg => cfg.ConfigureType <Item>(type => type.TreatAsInlineTable())); var s = Toml.WriteString(ItemDict.TwoItems, config); s.Should().Be(ItemDict.TwoItemsInlineSerialzed); }
public void Write_WhenTblArrayValueTypeIsConfiguredAsInlineTable_ThatTypeIsWrittenAsAnInlineTable() { var config = TomlSettings.Create(cfg => cfg.ConfigureType <Item>(type => type.TreatAsInlineTable())); var s = Toml.WriteString(InlineArray.TwoItems, config); s.Should().Be(InlineArray.ExpectedTwoItems); }
public void Write_WithEmptyInlineTableArray_WritesNothingToTheFile() { var config = TomlSettings.Create(cfg => cfg.ConfigureType <Item>(type => type.TreatAsInlineTable())); var s = Toml.WriteString(InlineArray.Empty, config); s.Should().Be(InlineArray.ExpectedEmpty); }
public void Write_WhenDictIsMarkedAsInline_WritesDictAsInlineAndItemsAutomaticallyAsNestedInlineTables() { var config = TomlSettings.Create(cfg => cfg.ConfigureType <Dictionary <string, Item> >(type => type.TreatAsInlineTable())); var s = Toml.WriteString(ItemDict.TwoItems, config); s.Should().Be(ItemDict.TwoItemsDictInlineSerialized); }
private void GenerateOutput() { if (!InitDone) { return; } configOutput.Clear(); configOutput.Text = Toml.WriteString(flexGUIConfig); }
public void WriteClassWithBoolCreatesCorrecToml() { var s = Toml.WriteString(new WithBoolProperty()); var exp = @"TheInt = 0 TheBool = false "; s.ShouldBeNormalizedEqualTo(exp); }
public void HandleComputedType() { var c = new Computed(); var config = TomlSettings.Create(cfg => cfg .ConfigureType <Computed>(type => type .IgnoreProperty(o => o.Z))); var w = Toml.WriteString(c, config); var r = Toml.ReadString <Computed>(w, config); }
public void Write_WithAppendComment_WritesObjectCorrectly() { // Arrange var tc = new WithAppendComment(); // Act var s = Toml.WriteString(tc); // Assert Assert.Equal("Commented = 0 #This is a comment\r\n", s); }
public void Write_WithMultilineComment_WritesObjectCorrectly() { // Arrange var tc = new WithMultilineComment(); // Act var s = Toml.WriteString(tc); // Assert s.Should().Be("#This is a\r\n# multiline comment\r\nCommentedA = 0\r\n#This is a \n#multiline comment\r\nCommentedB = 0\r\n"); }
public void Write_WithArray_WritesObjectCorrectly() { // Arrange var tc = new WithArray(); // Act var s = Toml.WriteString(tc); // Assert Assert.Equal("EmptyArray = []\r\nNonEmptyIntArray = [-100, 0, 100]\r\nStringList = [\"A\", \"B\", \"C\"]\r\n", s); }
public void WhenPluginConfigRegisteredAsDictionaryItGetsWritten() { // Arrange var cfg = ConfigWithPluginARegisteredAsDict(); // Act var s = Toml.WriteString(cfg); // Assert s.ShouldBeSemanticallyEquivalentTo(ExpectedConfigWrittenWhenARegistered); }
public void WriteTimespan_WritesTheTimepspansInGoLikeFormat(string span, string expected) { var t = new TimespanType() { Ts = TimeSpan.Parse(span) }; var written = Toml.WriteString(t); written.Should().Be($"Ts = {expected}\r\n"); }
public void Write_WithClassProperty_WritesObjectCorrectly() { // Arrange var tc = new WithClassProperty() { StringProp = "sp", IntProp = 10, ClassProp = new ClassProperty() { StringProp = "isp", IntProp = 100, IntList = new List <int>() { 1, 2 }, StringArray = new string[] { "A", "B" }, ConvProp = new ConvProp() { Prop = "cp" }, }, Acp = new List <ArrayClassProp>() { new ArrayClassProp() { V = 666 } }, }; var cfg = TomlSettings.Create(config => config .ConfigureType <ConvProp>(ct => ct .WithConversionFor <TomlString>(conv => conv .ToToml(cp => cp.Prop)))); // Act var exp = @"IntProp = 10 StringProp = ""sp"" [ClassProp] StringProp = ""isp"" IntProp = 100 IntList = [1, 2] StringArray = [""A"", ""B""] ConvProp = ""cp"" [[Acp]] V = 666 "; var s = Toml.WriteString(tc, cfg); // Assert Assert.Equal(exp.Trim(), s.Trim()); }
public void WriteToml_Issue16_Check() { // Arrange var obj = new WithUint(); // Act string output = Toml.WriteString(obj); // Assert output.Trim().Should().Be("Prop = 1"); }
public void ReadWriteCycle_WhenReadWithSpecificFormat_WritesAgainWithSameFormat(string tml, string expected) { // Arrange var read = Toml.ReadString(tml); // Act var written = Toml.WriteString(read); // Assert written.ShouldBeSemanticallyEquivalentTo(expected); }
public void Write_WhenIntIsReadWithSomeType_ItAlsoGetsWrittenBackWithTheSameType(string tml) { // Arrange var read = Toml.ReadString(tml); // Act var written = Toml.WriteString(read); // Assert written.ShouldBeSemanticallyEquivalentTo(tml); }