Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 213f7b8

Browse files
committed
Add PopulateInstance test
1 parent 371a6c1 commit 213f7b8

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/ServiceStack.Text.Tests/AutoMappingObjectDictionaryTests.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,54 @@ public void FromObjectDictionary_does_Convert_long_to_TimeSpan()
350350
var dtoLong = map.FromObjectDictionary<ModelWithLong>();
351351
Assert.That(dtoLong.Time, Is.EqualTo(time.Ticks));
352352
}
353+
354+
public enum CefLogSeverity
355+
{
356+
Default,
357+
Verbose,
358+
Debug = Verbose,
359+
Info,
360+
Warning,
361+
Error,
362+
ErrorReport,
363+
Disable = 99,
364+
}
365+
366+
public class CefSettings
367+
{
368+
public CefLogSeverity LogSeverity { get; set; }
369+
}
370+
371+
public class CefConfig
372+
{
373+
public string WindowTitle { get; set; }
374+
public string Icon { get; set; }
375+
public string CefPath { get; set; }
376+
public string[] Args { get; set; }
377+
public CefSettings CefSettings { get; set; }
378+
public string StartUrl { get; set; }
379+
public int? X { get; set; }
380+
public int? Y { get; set; }
381+
public int Width { get; set; }
382+
public int Height { get; set; }
383+
public bool CenterToScreen { get; set; }
384+
public bool HideConsoleWindow { get; set; }
385+
}
386+
387+
[Test]
388+
public void Can_use_PopulateInstance_to_populate_enum()
389+
{
390+
var map = new Dictionary<string, object> {
391+
["LogSeverity"] = "Verbose"
392+
};
393+
394+
var config = new CefConfig { CefSettings = new CefSettings { LogSeverity = CefLogSeverity.Info } };
395+
map.PopulateInstance(config.CefSettings);
396+
397+
Assert.That(config.CefSettings.LogSeverity, Is.EqualTo(CefLogSeverity.Verbose));
398+
}
399+
400+
353401
}
354402

355403

0 commit comments

Comments
 (0)